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.
Carl Worth [Sun, 17 May 2020 16:35:43 +0000 (09:35 -0700)]
empires: Rename all files (html, js, and css) to game.*
These are all the files for manipulating a single instance of a
game. We're moving this away from index.html so that we can have a
separate page at index.html for giving game instructions and allowing
users to host a new game.
So, along with the new name of game.html, we also rename supporting
files to game.css and game.js to be consistent.
Carl Worth [Sun, 17 May 2020 16:13:37 +0000 (09:13 -0700)]
make deploy: Go back to deleting any pre-existing files on the server
We stopped doing this back in commit 0bce98367c70c43eaa425aad101e15ed3db612a8 specifically because I was
concerned about a deployment of the top-level "lmno.games" content
obliterating lower-level content (such as that deployed by the
"empires-html" repository).
But now, I've switched to hosting the empires HTML content in this
same repository where it will be deployed together. And that's my plan
going forward, to house all static HTML content here in this
lmno.games repository. So in this commit we start passing the --delete
flag to rsync again.
The one exception is the "flempires" directory where Kevin is
currently experimenting. In the future, we'll likely incorporate that
content into this repository as well. But for now, we simply
explicitly exclude it so that deployments here won't destroy anything
he has deployed there.
Carl Worth [Sun, 17 May 2020 15:58:04 +0000 (08:58 -0700)]
Add some comments on the CSS for styling the empires client
At this point, all of the generic styling, (for paragraphs, forms,
etc.), has been moved up to the top level. So the only styling left at
the level of the empires directory are things to set very
empires-specific things, (such as showing/hiding elements for
particular game states).
Carl Worth [Sun, 17 May 2020 15:56:54 +0000 (08:56 -0700)]
Use named color to set the character of the character-reveal element
This makes me so happy! With these named colors, a low-level style
file like this one now has no explicit color values in it, but instead
simply inherits the defined, named colors from the theme above.
Carl Worth [Sun, 17 May 2020 15:52:25 +0000 (08:52 -0700)]
Move input sizing from empires to top-level
There's no reason the empires client should be overriding the size of
input fields. These should be consistent across all games.
And we choose the size of 40 that the empires client had, which is
slightly smaller than what we were getting otherwise, (which looked
just a tiny bit, comically large).
Carl Worth [Sun, 17 May 2020 15:47:54 +0000 (08:47 -0700)]
Apply our selected text color to haeaders (h1 and h2)
This was previously happening in the empires client, but now we move
this up to the top-level.
Note that we don't use the selected text color at minimal font sizes
(such as in the "body" element in general). This is because we want a
high contrast there for maximal legibility. So we introduce an
additional named --text-fo-color-max-contrast which is set to pure
black.
Carl Worth [Sun, 17 May 2020 15:43:19 +0000 (08:43 -0700)]
Use CSS custom properties to define named colors
Hurrah! I've only wanted this feature for decades.
Thanks to Richard for pointing out that it's now been well-supported
long enough that I can reliably use it. This will really help so that
I can change colors in one place and have the entire style follow the
scheme.
Carl Worth [Sun, 17 May 2020 15:30:32 +0000 (08:30 -0700)]
Insert a line break before the "Players in the game" section
It would be more semantic to have actual "sections" in the content and
some styling that sets proper spacing between sections. But that feels
like overkill given the current simplicity of the page, and the
current problem that there was just too little space at this one
point.
If we do make the page more complex in the future, we can certainly
add semantic sections.
Carl Worth [Sun, 17 May 2020 15:25:06 +0000 (08:25 -0700)]
Fix the page width to allow the content to be a full 720px wide
The code that was written here with numeric values of 720px was
assuming that the page interior would be as wide as 720px and that
padding would not be counted in that. But when we brought this code to
lmno we violated that assumption by using "box-sizing: border-box" on
the page, (making the padding be counted in computing the width of the
page.
The result of that was that the actual content of the page was only
620px and with actual paragraphs of text included now as part of the
empires client, it's clear that that was narrower than we really want.
So, in this commit, we account for the border-box semantics by using a
maximum page width of 820px (padding inclusive) so that the actual
page contents can be as wide as 720px.
Carl Worth [Sun, 17 May 2020 15:23:41 +0000 (08:23 -0700)]
Tweak the line-height down a bit
Now that we've added some actual paragraphs of text, (with the empires
client), it's plain to see that a line spacing of 1.5 is just a bit
too much. It just looks better a bit smaller like this.