Closed s4dmw closed 8 years ago
"Chess won't stay dead."
Time for a reboot. Chess won't defeat us! We're trying again, and this time, we'll win.
First, reset your tests.js
and main.js
. Wipe everything clean, except your 8x8 grid.
Use the Starting Point provided and write tests with mocha
and chai
in the browser for the API described; put the mocha
boilerplate in a new file called tests.html
. The tests should really have their own file, too; let's call it js/tests.js
. What happens when you use browser-sync
to view tests.html
...? Maybe link some <scripts>
, and don't forget the chai
!
Start with tested Model-layer code that represents the current state of the board and each move in the game. How can we navigate through the game, move by move? How could we back up a step? Start over? Skip to the finish?
Feel free to use tracer
bullets and interactive debugging to help you understand the internal state of the application, but don't leave breakpoints or tracer bullets lying around in your submitted code, please. Always start with "EnglishScript" -- pseudocode -- that explains your intent, so you have something to submit.
The next step is wiring up that core game logic to the visual representation of the board in HTML. How can we update the HTML -- the View-layer -- when a change occurs in the Model-layer? How can we signal the Model-layer that an interactive event -- clicking a button -- has occurred in the View-layer? That sounds like View Helpers and Controllers to me!
Write pseudocode for some of the Controllers -- Event Listeners and their associated callbacks -- and View Helpers -- Functions that just update the View. We'll need both of them to make this ship sail!
Can you write tested code for those View Helpers? How would you even write tests for that? Hmm... Give it a swing and document what approach you took in code comments. You'll may run into some difficulty; don't bulldog it. Write up your experience and what challenges you encountered.
Journal and Tutorial: https://github.com/s4dmw/s4dmw.github.io/pull/18
TIY-Assignments: https://github.com/s4dmw/TIY-Assignments/pull/33
TIY-Chessboard - redux: https://github.com/s4dmw/TIY-Chessboard/pull/3
Continue Improving given because:
Please review and close...
TIY-Assignments
named18--night-of-the-chessboard
frommaster
USERNAME.GitHub.io:journal-week-4
journal-week-4.md
or something creativetutorial-week-4.md
or something creativeTIY-Assignments:18--night-of-the-chessboard
CheatSheets/GitHubAPI.md
TIY-Chessboard:chess-2.0
USERNAME.GitHub.io
fromjournal-week-4
intomaster
TIY-Assignments
from18--night-of-the-chessboard
intomaster
TIY-Chessboard:chess-2.0
js/main.js
tests.html
(see below)chai
intests.html
... CDN, anyone?require
won't work here... justmocha.it
!game.board
...? What does it do?game.reset
? What does it return? Any side-effects?game.applyMove
?game.applyMove
is cheating;game.next
...!game.reset
is more interesting?game.next
but can yougame.prev
...?game.end
is really a lot ofgame.next
...game.play
, tho... How U evensetInterval
?