]> git.cworth.org Git - lmno.games/commitdiff
tictactoe: Implement a minimally-functional multi-player game
authorCarl Worth <cworth@cworth.org>
Wed, 27 May 2020 04:13:49 +0000 (21:13 -0700)
committerCarl Worth <cworth@cworth.org>
Wed, 27 May 2020 04:13:49 +0000 (21:13 -0700)
Now that there's a server implemented at lmno.games/tictactoe/LMNO/
it's a simple matter to break the call chain at handleClick() to
not do any state updates, but instead hit the /move API, then wait
for data to come back from the /events API and only when the server
returns with that, _then_ to update the state.

So, with multiple clients connected, each client will now seem the
game state updated with each move.

As far as the gameplay of Tic Tac Toe, the only major feature missing
is that players are not yet restricted to play as either X or O but
can instead send events for either player. Obviously, that won't be
hard to fix.

Then, as far as implementation, this code copies the add_message()
function from lmno.js, so we'll want to find a better way to do
that. And there may be some refactoring to be done for event handling
as well, (to reduce code duplication between game implementations).

But this code does use the fetch() API which does seem easier to use
than XMLHttpRequest so that's something we will probably want to
switch to in existing code.


No differences found