1. It was inserting a "deps/" into the URL for downloading, (which
doesn't exist---we only have "deps/" in the local filesystem.
2. It wasn't distinguishing "react-dom@16" from "react@16" in the
URL, (half of the files we download need one, and half the
other).
This commit fixes both. The first by using a "substitution reference"
with the $@ variable to remove the "deps/" from its value when
constructing the URL. And the second by splitting the existing rule
into two rules.
Whle here, we also replace the use of the patsubt function in the
SHA512 recipe with the simpler substitution reference exactly as we
are now using it in the line before.
Carl Worth [Fri, 5 Jun 2020 14:48:31 +0000 (07:48 -0700)]
Add a simple player-info div
This is populated by the player-info event that is streamed to us when
we first conenct to /events and should also be updated by any
subsequent player-update events for our specific player.
Carl Worth [Fri, 5 Jun 2020 01:19:41 +0000 (18:19 -0700)]
tictactoe: Add a simple game-info div
This is populated dynamically by the server sending the game-info
event and contains both the game ID as well as the URL.
We're not yet doing any interesting styling here, (it should get
tucked up into the upper-left corner as just a button with the game
ID, and when clicked on it will expand to show the URL to share).
Carl Worth [Fri, 5 Jun 2020 00:36:23 +0000 (17:36 -0700)]
Rename reset_state() to reset_board()
It's not resetting _all_ state, just the board.
In the past, these two notions were basically the same, (since the
board was the only state we hadd), but soon we'll be adding players
and other information outside the board, so this new naming is more
clear.
Carl Worth [Thu, 4 Jun 2020 23:40:30 +0000 (16:40 -0700)]
Rename several internal names from ICantReadThis to much_better_thanks
I'm not entirely sure this is a good idea with the number of library
functions that we're calling that still use camel case, (such as
addEventListener, and perhaps most significantly, onClick), but the
code was even more mixed before, so it's maybe at least more
consistent in its inconsistency now, or something?
Carl Worth [Thu, 4 Jun 2020 00:37:59 +0000 (17:37 -0700)]
tictactoe: Don't let the user send an illegal move
The client already knows which squares are occupied, and when the game
is won, so it's pointless to ever send a move we know is going to be
rejected. And in fact, we shouldn't even give the user a hover
indication as if they could move there.
That's all implemented in this commit. The hover highlight and the
pointer cursor are both disabled for squares that are already
occupied, and for all squares once the game is over.
Carl Worth [Mon, 1 Jun 2020 17:52:19 +0000 (10:52 -0700)]
tictactoe: Adapt to new server event type: game-state
Previously, when a client joined a game in progress the server would
send all previous moves as "move" events (just the same as if a player
were making those moves live).
The server was recently changed to instead a single "game-state" event
in this case, (which also does contain the entire move history). So
when we receive that, we reset the game state, then replay the moves
from that history.
Carl Worth [Wed, 27 May 2020 04:20:22 +0000 (21:20 -0700)]
Drop the game history interface.
Not that it's bad to let the user go back and forth to see what
happened, but the interface here was particularly clunky, (both for
being rendered as a list of buttons and also for allowing the user to
fire off new moves wen viewing old history state).
This commit simply guts the rendering of the "moves" list. It doesn't
yet remove the jumpTo code that's now dead.
Carl Worth [Wed, 27 May 2020 04:13:49 +0000 (21:13 -0700)]
tictactoe: Implement a minimally-functional multi-player game
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.
Carl Worth [Wed, 27 May 2020 04:05:03 +0000 (21:05 -0700)]
Makefile: Don't remove write permission from .js build artifacts
The intent behind this was to act as a clue to the developer that they
shouldn't edit the .js file, but it caused a problem that subsequent
build would fail because the output files were read-only. So we give
up on this idea.
Carl Worth [Tue, 26 May 2020 03:45:58 +0000 (20:45 -0700)]
tictactoe: Put in place the standard top-level page
Specifically, one which allows for hosting a new game, (using the
generic lmno_new function). Meanwhile, the game-specific page is moved
to tictactoe/game.html.
Carl Worth [Tue, 26 May 2020 03:02:12 +0000 (20:02 -0700)]
tictactoe: Integrate the standard LMNO styling
Include the LMNO CSS files and add a header. The LMNO button styling
looks better here than I expected. Just required a couple of padding
tweaks to get things looking correct.
Carl Worth [Tue, 26 May 2020 00:13:11 +0000 (17:13 -0700)]
Correct various meta viewport tags
I don't know where this cargo cult started, but the semicolon
separator was just wrong, (should be a comma), and the
maximum-scale=1.0 and user-scalable=0 were really just rude, (if a
user needs to/wants to zoom in on a page for accessibility purposes,
who are we to say they can't or shouldn't?).
Carl Worth [Mon, 25 May 2020 23:55:52 +0000 (16:55 -0700)]
Provide any downloaded deps/*.js files to git clone during deployment
This is simply so that the deploy process doesn't need to download
anything that we might already have downloaded. We do explicitly call
"make deps" still to force verification of the checksums of the .js
files (even though we didn't just download them). This ensures that
these resource (which aren't otherwise tracked in git) haven't been
modified.
Carl Worth [Mon, 25 May 2020 21:20:38 +0000 (14:20 -0700)]
Rework Makefile to force sha512 verification of downloaded files
We had sha512 checksums here, but no automation was happening for the
verification, (instead there was only a "make checksums" file that
would have to be called manually).
We rework things here so that the checksum is verified on every file
that is downloaded. The rework simplifies the recipe for
download/verification to a single recipe for all dependencies (rather
than 4 recipes with a lot of duplicated logic).
The "make checksums" target is also renamed to "make deps" since it
can be used to force the downloading of all dependencies, (and it is
given the .PHONY treatment so that it always performs checksum
verification even if there is nothing new to download).
Carl Worth [Mon, 25 May 2020 20:37:10 +0000 (13:37 -0700)]
Add a simple tictactoe game, implemented with React
This isn't a proper LMNO game, (it's not networked at all), but it's a
starting point for seeing how we might structure a React-based client
(and we can develop this into a proper LMNO game).
In fact, the source code here came directly from the React tutorial
here:
https://reactjs.org/tutorial/tutorial.html
Note that I've not pulled in the 1000+ npm modules that would have
come from using create-react-app as recommended in that tutorial. As
can be seen here, by example, none of them are needed. The only build
tool requireed is something to compile JSX and we've got that working
via the Debian-provided babel packages (as seen in the most recent
commits here).
Carl Worth [Mon, 25 May 2020 19:18:42 +0000 (12:18 -0700)]
Makefile: Add support to use babel to compile React code using JSX
This is in preparation for starting to use React to implement LMNO
game clients.
In this commit, the previous "make dev" target is now simply "make",
and the previous "make prod" target is now "make LMNO_BUILD=production".
This latter command is definitely annoying to remember, but should
almost never need to be executed manually; instead the developer will
likely invoke "make deploy" which knows how to do a production build.
Carl Worth [Mon, 25 May 2020 10:46:08 +0000 (03:46 -0700)]
Extend Makefile with "deps", "dev", and "prod" targets
The "make deps" target downloads 3rd-party JavaScript resources that
are used by the site, (currently React and React-Dom). The "make dev"
installs the development versions locally while "made prod" installs
the production versions.
All three targets verify the integrity of the downloaded files via
SHA512 sums that are added in this commit.
And all three targets are documented in the README file added in this
commit.
Carl Worth [Sun, 24 May 2020 15:43:13 +0000 (08:43 -0700)]
Fix padding calculations for intermediate widths
I just noticed that at some intermediate browser widths the page
padding was entirely missing. Fortunately, "git bisect" was very
useful and pointed me to the exact problematic commit:
In that commit we were trying to move the range of media block from
620:720 to instead be 720:820 (to account for the change in the
box-sizing parameter now including 100 units of padding).
But that commit was botched in a couple of ways, (applying from
620:820 and also miscalculating everything within that range).
This commit corrects things and is verified to act as desired when
applied to the broken commit mentioned above and when applied at the
current point in the code history.
Carl Worth [Sun, 24 May 2020 15:27:09 +0000 (08:27 -0700)]
Add handling for a spectators list in addition to the players list
The model is that when people initially join the game, (providing a
name for themselves), they are a spectator. They then move from the
spectator list to the player list when then they choose a character
name.
The server isn't very clever about this. It has distinct endpoints for
adding/removing players and adding/removing spectators. So in this
code we have to explicitly remove ourselves as a spectator when we add
ourselves as a player.
Carl Worth [Sun, 24 May 2020 15:06:11 +0000 (08:06 -0700)]
empires: Construct reliable paths for all game API endpoints
By appending to window.location we can ensure that we're always
hitting an endpoint one level below the game ID, (and not replacing
the game ID), regardless of whether the current path ends in a
trailing slash or not.
Kevin Worth [Mon, 18 May 2020 12:24:31 +0000 (08:24 -0400)]
Prepare directories for merge into lmno.games
In order to merge this (flutterempires) repo into the lmno.games repo,
it will be much cleaner to have all of the files in the top level
directory named flutterempires in order to avoid conflicts with
top-level files in lmno.games.
Kevin Worth [Fri, 8 May 2020 13:07:17 +0000 (09:07 -0400)]
Clean up some leftover hello flutter code
The hello flutter code has button which increments a number on the
screen and this has just been cluttering things up. This will likely be
a good place to put the logic we'll need for submitting the user's
name and character, so we won't get rid of it completely.
Kevin Worth [Mon, 4 May 2020 11:53:03 +0000 (07:53 -0400)]
Rename directory flutterfamilies to flutterempires
Originally the flutter app was created in a directory called flutterfamilies
and this should take care of the final references still pointing to that old
directory now that it's renamed to flutterempires
Kevin Worth [Fri, 8 May 2020 12:58:03 +0000 (08:58 -0400)]
Display total number of players
Setting up a new widget to display the list of players, but for the
time being (for simplicity's sake) it's just displaying the size of the
returned list of players.
Kevin Worth [Fri, 8 May 2020 12:52:02 +0000 (08:52 -0400)]
Stop using dart:js in player.dart
This "web only" package was preventing the app from being built on
Android and iOS, so now that we have a method for parsing the player
list, we no longer need to use the (albeit simpler) JsArray type.
...where we took a shortcut by removing a bunch of stuff just to get
things to work, now we're putting it back in the broken state and some
following commits will fix it.
Kevin Worth [Mon, 4 May 2020 02:39:44 +0000 (22:39 -0400)]
Change fetchPlayer to fetchFirstPlayer
Initially I was going to fix the logic in this method to fit the name,
but instead - for the time being - I'll simply make the name more
accurately describe what the method is doing.
Kevin Worth [Mon, 4 May 2020 00:21:31 +0000 (20:21 -0400)]
Add initState to start the async call to fetch player
initState is a good place to do asynchronous calls that we just
need to happen one time at the beginning.
So, in initStart we fetch the player and put it in a Future, and then
when (each and every time) build gets called, it uses what has
been fetched or shows the spinner if the fetch hasn't completed
successfully yet.
Kevin Worth [Sun, 3 May 2020 19:31:41 +0000 (15:31 -0400)]
Add a FutureBuilder widget to hold a fetched player
Rather than doing a fetch within this build method (which gets called repeatedly),
we use a FutureBuilder to show a spinner until the player has finished being
fetched asynchronously.
Kevin Worth [Fri, 8 May 2020 15:01:21 +0000 (11:01 -0400)]
Rip out column and just show player list view
This was the easiest thing to do quickly, because a list view does not
play nicely inside of a column widget (can't put a scrollable inside of
a scrollable, sort of thing...)
Eventually, we need to combine the views or make separate screens for
each one.
Carl Worth [Sat, 23 May 2020 13:00:25 +0000 (06:00 -0700)]
lmno.js: Drop the lmno_login and lmno_login_loadend functions
These were supporting some code in a separate repository (lmno-server)
but that repository has now gotten smart enough to host its own
JavaScript code so this is currently serving no purpose here.
Carl Worth [Thu, 21 May 2020 17:14:55 +0000 (10:14 -0700)]
Use absolute references for CSS and JS files
I wouldn't expect this to have a behavioral change, but I recently got
a bug report from some users who where unable to get these resources,
(their browser was trying to fetch them from
https://lmno.games/game.css instead of
https://lmno.games/epires/game.css).
Carl Worth [Tue, 19 May 2020 15:44:34 +0000 (08:44 -0700)]
Actually make the top-level "join game" button work.
Embarrassingly enough, when I first implemented the handling of this
form, I only tested that it gave a proper error message for an invalid
ID. Somehow I totally neglected to even test (let alone implement!)
the handling of a valid ID.
Fortunately, the missing implementation is _very_ easy. Just send the
browser to the URL for the game ID that was entered.
Carl Worth [Sun, 17 May 2020 22:37:32 +0000 (15:37 -0700)]
empirs: Switch to using local server to handle all game events
The local server is now much more capable than the old one at
https://families.cworth.org/api (since the local one can now
handle multiple simultaneous games each with a different ID).
Carl Worth [Sun, 17 May 2020 22:13:24 +0000 (15:13 -0700)]
empires: Fix references to "local" CSS and JS files
While it's tempting to just treat these as coming from the current
directory, in practice this HTMl page will be served from a dynamic
path that includes the game ID as a path component. So we have to
look up one directory to find these resources.
Carl Worth [Sun, 17 May 2020 22:10:08 +0000 (15:10 -0700)]
empires: Add a top-level static page for the Empires game
This has a basic description of the game along with a button to host a
new instance of the game.
There is a tiny bit of JavaScript added to support the new button,
(simply calling the server API to generate a new game and then
redirecting to the new game ID or else generating an error message).
Carl Worth [Sun, 17 May 2020 16:39:05 +0000 (09:39 -0700)]
empires: Fix indentation of game.html
There were a couple of misguided attempts to keep content closer to
the left column here, but were in fact just inconsistent
indentation. Fix things up to be consistently indented according to
the actual document structure.