GITLAB PAGE: https://anapowa.gitlab.io/hanoi
TEAM: ANA RUIZ TOVAR CHRIS STRANGER
PURPOSE: Create "game pieces" that follow a set of rules:
- only one disk can be moved at a time.
- Only upper disk from one of the stacks can be moved by placing it on top of another stack.
- No disk can be placed on top of a smaller disk.
DEVELOPMENT PLAN
-
Move a game piece at a time from one tower to a different tower.
-
make 4 containers of different sizes/colors
- create divs for each with data attributes of different values.
- id=“disc1” data-width=“1”
- Use query selector to access data in DOM
- Have a click handler on each tower
- create divs for each with data attributes of different values.
-
Click on a piece to "pick it up".
- Get a hold of the top piece using the click handler.
- tower.lastElementChild
- Get a hold of the top piece using the click handler.
-
Click on a tower to "set down" the piece on a different location.
- when dropping a piece, only allow a smaller one on top of a bigger one.
- using data-width attribute, compare size, if smaller than the current "top piece", then drop on top.
- e.g. disc1.dataset.width < disc3.dataset.width
- add piece to desired tower.
- tower.appendChild(disc#)
- when dropping a piece, only allow a smaller one on top of a bigger one.
-
-
Keep track of the game moves.
-
Have a way of identifying when the game is complete.
- when all pieces are moved from 1 tower to another.
- Alert "You won!"
- when all pieces are moved from 1 tower to another.