Carl Worth [Tue, 7 Jul 2020 06:26:43 +0000 (23:26 -0700)]
Score each mini glyph and render the winner for each
At this point the game is almost totally complete. All that is missing
is the final-score indication of the majority winner and the
super-glyph winner.
Carl Worth [Tue, 7 Jul 2020 06:10:53 +0000 (23:10 -0700)]
Prep for stashing final scores against each mini grid
By turning each mini grid into an object rather than just an array of
squares. This new object now has a place to lodge scores and a final
winner for each mini grid, (though we aren't populating those yet).
This commit is intended to have no visible change on the game.
Carl Worth [Tue, 7 Jul 2020 05:58:12 +0000 (22:58 -0700)]
Add support for detecting glyph shapes
And color the background of each cell that is part fo a glyph in a
player-specific color.
Note: I'm not at all convinced that this is a good way to style
things, but the actual functionality is here now, and I'll be happy to
improve the specific styling in the future.
Carl Worth [Tue, 7 Jul 2020 02:08:32 +0000 (19:08 -0700)]
Scribe: Prep game state for detection of glyphs
There's not any detection of glyphs here yet, there's simply a new
slot in each of the squares: Where we used to just have a textual
ymbol for each occupied square, we now have an object:
{
symbol: '+' or 'o',
glyph: true or false
}
And the glyph Boolean is used to add a class to the HTML square
element as well.
Carl Worth [Sun, 5 Jul 2020 18:31:54 +0000 (11:31 -0700)]
Stop ignoring .gitattributes
We're implementing a cleaner approach for this where the nogit script will provide its own .gitattributes data as needed, (and the lmno-todo repository won't need to).
Carl Worth [Sat, 4 Jul 2020 14:53:32 +0000 (07:53 -0700)]
empathy: Don't force active:true when adding state for a new player
This fixes the bug where reloading the interface would cause inactive,
grayed-out player names to appear solid instead of grayed out.
What I had been thinking when writing this code is that this function
would be called only when a new player joins the game, (and by
definition, a newly joined player must be active). But this function
can also be called when a player reloads their interface, and at that
point player-join events are received for all players whether active
or not.
Meanwhile, the server is now explicitly providing the active bit for
players, so we get the right information without doing anything.
Carl Worth [Tue, 30 Jun 2020 00:09:31 +0000 (17:09 -0700)]
Display (grayed out) inactive players with non-zero scores
This issue came up with playtesting last night: We had a player who
finished in the top three overall, but dropped out for the last couple
of rounds. But we still wanted to see their score in the final
results. So, here we keep track of active and inactive players and
display the inactive ones (if they have non-zero score) with 50%
opacity.
Carl Worth [Tue, 30 Jun 2020 00:05:17 +0000 (17:05 -0700)]
Only consider active players when counting players needed for prompt voting
Now that the server is sending us inactive players, we don't want to
consider them when computing how many votes we need to go forward with
a category.
Carl Worth [Mon, 29 Jun 2020 22:19:07 +0000 (15:19 -0700)]
Add the KUDOS SLAM and GREAT MINDS achievements
At this point, I've implemented all of the achievements we originally
thought of, (except for TWINNER which is going to take a bit more code
to find cases where it applies).
Carl Worth [Mon, 29 Jun 2020 21:56:16 +0000 (14:56 -0700)]
Fix category voting to select among only those with the most votes
Previously, the code was selecting randomly among all categories with
at least a quorum of votes. With this commit, the code now does what
was intended, by selecting randomly only among the categories that are
tied for the most votes.
Carl Worth [Mon, 29 Jun 2020 21:54:31 +0000 (14:54 -0700)]
Change category voting to require fewer votes when there are more categories
Now, at the beginning, it's no longer enough for there to be a
majority of votes on a single prompt. Instead, the number of votes
required is the number of players minus the number of available
prompts.
Carl Worth [Mon, 29 Jun 2020 21:28:35 +0000 (14:28 -0700)]
Display kudos (as stars) in the per-round scores
Now that the server gives us this information, let's display it,
(otherwise, the players could be very confused about why some ties
were apparently broken in the sorting).
Carl Worth [Mon, 29 Jun 2020 17:49:22 +0000 (10:49 -0700)]
Add a QUIRKSTER achievement
This one recognizes the dubious achievement of submitting an entire
docket of answers with no matches with anyone else at all. Thanks to
Andrew for naming it.
Carl Worth [Mon, 29 Jun 2020 15:55:29 +0000 (08:55 -0700)]
Rename "label" to "achievement"
The word "label" was far too generic to capture the stlying needs for
this class. Thanks to Andrew for pointing out that this feature is
really what games today call an "achievement".
in our game last night, which ended up scribbling over the rows above
and below in the judging view. This fix chops things off vertically,
(which doesn't solve the case if someone is _legitimately_ trying to
get such text to appear—we can address that case when it appears).
Carl Worth [Mon, 29 Jun 2020 15:32:51 +0000 (08:32 -0700)]
Reword the Move On button when we're not waiting for anyone specific
This case arises when there are additional players still connected to
the game, but that haven't even started typing any answers.
In this case, the view looks like this:
Submission received
The following players have submitted their answers: <list>
In this case, wording of "Move On Without Their Answers" suggests the
exact opposite, (as if "their" is referring to the submitted players
rather than those not listed on this page). The new wording in this
case, "Move On Without Anyone Else" makes it more clear what the
behavior is.
Carl Worth [Mon, 29 Jun 2020 15:29:51 +0000 (08:29 -0700)]
Define the move_on button after the still_waiting component
This is just code movement here with no intended logical change. The
motivation here is so that the "Move On" button can be worded
differently depending on who we're waiting for.
Carl Worth [Sun, 28 Jun 2020 23:25:29 +0000 (16:25 -0700)]
empathy: Add the ability to star one favorite item
The client isn't currently saving information about which words the
player themself submitted, so it isn't yet preventing the user from
sending kudos to an item they submitted themself.
Carl Worth [Sun, 28 Jun 2020 22:55:46 +0000 (15:55 -0700)]
empathy: Pre-group words according to common patterns
Specifically, the following will be considered identical and
pre-grouped:
<word> = <word>s
<word> = a <word>
<word> = an <word>
<word> = the <word>
Unlike the server-side canonicalization of case differences, which are
not visible, the above matching words are all still made available to
the player and simply pre-grouped. So, the player can decide whether
to leave them grouped or to separate them back out.
Carl Worth [Sun, 28 Jun 2020 21:44:47 +0000 (14:44 -0700)]
Drop extra PromptOption state for not showing a specific prompt
It was fun for me to learn about how to use the useState hook,
but this only code path was only necessary for when I was not
planning to distribute negative votes through the server to
other clients.
I ended up distributing that state after all, which has the benefit
that hidden prompts stay hidden when reloading (and from one round to
the next). [One potential downside is that hidden prompts are
permanently hidden---they can't be made to appear again. Oh well!]
And now that the server is telling us about the prompts we've already
voted against, and we're already not dispalying those, we don't need
the additional state here to hide things on the client side before we
receive that notification from the server.
Carl Worth [Sun, 28 Jun 2020 16:08:06 +0000 (09:08 -0700)]
Add a containing div element to the "still waiting" component chunks
And drop the use of a list.
The list was annoying because it was triggering the React warning:
Each child in a list should have a unique "key" prop
And in this case, it seemed really silly to have to name/distinguish
the <p> element from the following <ul> element.
And this new <div> does give us a logical place to treat this chunk of
the document as a single element if needed, so this is the logically
correct thing to do.
Carl Worth [Sun, 28 Jun 2020 15:21:41 +0000 (08:21 -0700)]
Eliminate lead-in text when there is nothing following
I was often annoyed to see the text "Still waiting for the following
players:" when it was followed by no players at all.
It would have been really awkward to try to achieve the result of this
commit withing the final return statement. It's funny how often I
forget that JSX doesn't require all content to be contained in a
single return statement. I often find myself migrating to an approach
that can be seen in this commit, and I seem to prefer it:
* Conditions are captured in JavaScript code, (and not within JSX)
* Various React componenents are each captured in separate JSX chunks
* The final return statement is often just listing previously
constructed components
Carl Worth [Sun, 28 Jun 2020 15:17:58 +0000 (08:17 -0700)]
empathy: Add some missing whitespace
JSX is sometimes annoyingly aggressive about eliminating whitespace
between textual content and component content. I'm not sure if this
solution is the best approach, but it works at least.
Carl Worth [Sun, 28 Jun 2020 00:34:06 +0000 (17:34 -0700)]
Stop abusing the JavaScript back-tick syntax within JSX
JSX already lets us implicitly combine adjacent string literals
together so it's simpler to not use the JavaScript back-tick syntax
but instead simply pop back to JSX when we need some literal string
content.
Carl Worth [Sat, 27 Jun 2020 23:32:05 +0000 (16:32 -0700)]
Implement voting for the "New Game" button
Making this phase advance much like the other phases, and dependent on
a majority of the players rather than just letting one player stomp
all over things.
Beyond this, we still do want to allow players to inspect the state of
past rounds, but the UI for that that will have to come later.
Carl Worth [Sat, 27 Jun 2020 18:07:49 +0000 (11:07 -0700)]
empathy: Track the player-exit event
Now that the server is correctly noticing when a client drops it
connection, and notifying clients when a player has dropped every
connection, we now listen for that and drop players from our list
when they have left the game.
Carl Worth [Sun, 21 Jun 2020 16:19:53 +0000 (09:19 -0700)]
Fix square to not be active if occupied
Thanks to Scott who noticed yesterday he could tap on an occupied
square and get an error message including "Square is already
occupied". It's good the server catches that case and sends an
error. And it's good the client presentes that cleanly.
But the client shouldn't ever even let the user submit a move that the
client already know is not legal.
In this commit we appropriately set a square to not be active if it is
already occupied. This fixes the case described above, and further
makes it so that hovering over an occupied square won't even present
the user with a cursor suggesting the square is "clickable".
Carl Worth [Sun, 21 Jun 2020 16:16:29 +0000 (09:16 -0700)]
Rename local variable from "active" to "grid_active"
There is an "active" property up and down our component stack, (at the
board level, whether it's the current players turn; further at the
mini-grid level, whether it's a legal mini-grid; further still at the
square level, whether the square is unoccupied). It's clear enough to
uses a props name of "active" at each level.
But when using a local variable to compute the child's "active" prop
while in a current component with its own "active" prop, this can get
confusing.
So, at the board level, use a local variable of "grid_active" to
compute the "active" prop for the child grid.
Carl Worth [Sat, 20 Jun 2020 18:01:33 +0000 (11:01 -0700)]
Move definition of Scribe glyphs to an array of objects
And loop over this with map() to generate a list of React elements.
This is instead of the previous list of literal React elements we had
before.
This doesn't have any immediate impact, but makes the glyph data
available if other code wants to access it in the future, (such as
code that is scoring a mini grid).
Carl Worth [Sat, 20 Jun 2020 17:51:04 +0000 (10:51 -0700)]
Don't center glyph-and-name contents vertically
This led to the text names of the single-row glyphs ("Single",
"Double" and "Line") appearing lower than the names of "Pipe" and
"Squat-T" in the same row.
With this fix, all glyph names are aligned within a row.
Carl Worth [Sat, 20 Jun 2020 17:48:26 +0000 (10:48 -0700)]
Don't waste space for glyphs that are not full height.
For "Single" through" Squat-T" only two rows of dots are needed to
display the full glyph, so it's wasteful to have a full-size glyph. We
fix this by dynamically computing a correct viewBox for the glyph's
SVG given the dots that are present, and then letting the "glyph"
class styling automatically determine a height based on its children,
rather than explicitly setting it to the full height, assuming a
square.
Carl Worth [Sat, 20 Jun 2020 17:28:34 +0000 (10:28 -0700)]
Add a reference diagram of the 19 glyphs of Scribe
Trying my hand at using the <svg> element within HTML for the first
time. It's actually quite nice and I might start using it more
frequently rather than trying to fight browser layout mechanisms when
I'm trying to draw something very explicit, (like a board game).
Carl Worth [Sat, 20 Jun 2020 17:21:32 +0000 (10:21 -0700)]
Use an array spread syntax instead of .fill(null)
I don't really need null items. In fact, the copy here with the appray
spread syntax gives undefined, not null items. All I need is items
that map() will actually act on. The initial Array(9) gives only
"empty" items which map() ignores.
Carl Worth [Sun, 14 Jun 2020 23:43:49 +0000 (16:43 -0700)]
Don't display the answering "Move On" button until the server reports idle
By waiting until the server reports that things are idle, it's safer
to display this button. (Displaying it early might result in a a user
being considered a majority of just the group of that player alone,
which is not what is desired.)
Carl Worth [Sun, 14 Jun 2020 22:14:44 +0000 (15:14 -0700)]
Fix to use server-sent state for whether player has answered/judged
Previously we were using a component state Boolean "submitted" for
this information, but that's fundamentally broken since if the client
reloads the page that state is lost, resulting in the user being
presented with the form as to submit a second time (which is not
allowed by the game).
So, now the rendering looks to see whether the current player's name
is in the list of submitted players, and if so, it does not display
the form. This is exactly what we want.
Carl Worth [Sun, 14 Jun 2020 22:00:04 +0000 (15:00 -0700)]
Copy several game-state members into client state
The server has been telling us (or trying to at least: see recent bug
fixes with JSON serialization of Set objects) the lists of players who
are in the process of answering or judging within the game-state
object, but the client has been ignoring this.
Without this fix, reloading of a status page could cause names to
disappear from the "still waiting" lists or the "move on" buttons.
Carl Worth [Sun, 14 Jun 2020 19:22:54 +0000 (12:22 -0700)]
Fix bug preventing a user from being able to "unselect" a word while judging
Previously, the selection was accidentally "sticky" unless the player
went on to group a word with another. So if the user accidentally
clicked a word there was no way to unselect it without maging a bogus
grouping and then undoing that.
Carl Worth [Sun, 14 Jun 2020 18:01:18 +0000 (11:01 -0700)]
Tweak the error message when submitting results of judging
I wanted this when debugging a confusing case of this error text
appearing, (and we had the same text in two places). So having unique
text here will help.
In the end, the bug I was dealing with was from my Android browser
having a persistent cache of a stale JavaScript file.
Carl Worth [Sat, 13 Jun 2020 22:02:14 +0000 (15:02 -0700)]
Add a "Move On" button to the end of both the answering and judging phases
These use the same voting style as the prompt voting, and allow the
game to proceed once a majority of players have voted to move on. This
should help avoid the game being locked out just because a single
player has decided not to play anymore, or somehow became disconnected
(which has already happened in practice more than once).
With this change, we're also now displaying the actual names of the
players that have already answered/judged (as opposed to just the
count as we were displaying previously). And we've written code to
also display the list of player names who are still in the
answering/judging process but that list is not yet being populated
(we'll need just a little more plumbing to have the client send an
activity ping to the server when typing/tapping/clicking before
submitting).
Carl Worth [Fri, 12 Jun 2020 00:53:20 +0000 (17:53 -0700)]
empathy: Fix judging interface to properly merge two entire groups
Previously, when selecting an item that was a part of a larger group,
it could get pulled out of that group to be merged with the other
selected item. This was absolutely bewildering to players.
Instead, the right thing is to entirely merge the two groups to which
each of the two selected items belong. That's what we do here, and
using Set objects rather than simply arrays as we had before.
Carl Worth [Fri, 12 Jun 2020 00:08:02 +0000 (17:08 -0700)]
Add clean support for rejecting categories that are too large
This is clean in the sense that it prints a message if the server
rejects the submission, but before that it will even do the nice thing
of checking the number on the client side, (and reporting this with
the HTML5 validity API).
Carl Worth [Thu, 11 Jun 2020 14:25:15 +0000 (07:25 -0700)]
Add support for judging of equivalent answers
This involves receiving a list of unique words that were submitted and
then allowing the user to group them into words that should be scored
as if identical. The interface implemented here uses sequential
clicking, but maybe it would be more intuitive to do drag-and-drop
instead? I may have to experiement with that.
Carl Worth [Thu, 11 Jun 2020 01:04:16 +0000 (18:04 -0700)]
Avoid unnecessary use of fill(null)
Where we can just use a spread-syntax array copy for the same effect,
(namely, ensuring an array has actual items (even if undefined) rather
than "empty" so that map() actually does something).
Carl Worth [Wed, 10 Jun 2020 14:57:08 +0000 (07:57 -0700)]
Empathy: When receiving a game-state event overwrite all prompts
Originally this cod was written to add each received prompt, but that
does the wrong thing when the game-state object is trying to set a
subset of the prompts we already have, (for example, to drop the
prompt we just finished playing when starting a new game).
Carl Worth [Wed, 10 Jun 2020 02:46:28 +0000 (19:46 -0700)]
Empathy: Add support for submitting answers to a prompy
For this we convert ActivePrompt from a function to a class-based
React component. Then we use the "uncontrolled components" technique
again to arrange for an array to hold the form values.
Finally, when answers are submitted successfully we display a simple,
static message. Eventually, we'll want to display some dynamic updates
as other players vote, (but for that, we'll also need the server to
give us that information).
Carl Worth [Tue, 9 Jun 2020 14:59:41 +0000 (07:59 -0700)]
Add a button to advance from prompt voting to playing the actual game
Once a majority of the players have voted a new button appears (for
everyone) that when pressed tells the server that it's time to start
the game.
Then, when the client receives a "start" event from the server with
the prompt the server chose, the client replaces the entire interface
with a form for entering the responses to the prompt.
The submit button for that form is currently inert.
Carl Worth [Mon, 8 Jun 2020 16:15:00 +0000 (09:15 -0700)]
Add display of votes on top of each prompt's vote button
This is a simple bit of feedback so players can see which options are
being voted on by other players. I won't claim that there's anything
inspired about the stlying or color selection here. Maybe Karen will
have some suggestions to improve this later.
Carl Worth [Mon, 8 Jun 2020 16:13:43 +0000 (09:13 -0700)]
Restrict :hover styling to when a media query says hover is fully supported
Otherwise, on my phone I was seeing "sticky" hover effects, (after I
clicked a button it stayed looking like it was still being pressed
after I let go which was very confusing).
Carl Worth [Mon, 8 Jun 2020 16:11:03 +0000 (09:11 -0700)]
Add a new color --text-fg-on-accent-bright
For allowing the designer to select what color text should be when on
a background of --accent-color-bright.
Note: The value for this color happens to match the color of
previously-defined values currently, but that's just me throwing
programmer-art colors in place. That's why we don't reference an
existing variable in the value here, even though the color is
currently identical to a previous one, (we wouldn't want a designer to
think they are necessarily linked).
Carl Worth [Mon, 8 Jun 2020 13:54:16 +0000 (06:54 -0700)]
Empathy: Send prompt suggestions to server and display received prompts
The received prompts can come in an initial list as part of the
"game-state" event sent when first connecting, and they can also come
in subsequent "prompt" events when a player submits a category
suggestion. These are all displayed as large buttons.
Clicking a button also sends a vote to the server, but received votes
are not yet displayed in any way.
Carl Worth [Mon, 8 Jun 2020 13:51:56 +0000 (06:51 -0700)]
style: Add a new variable: --text-fg-on-accent
This removes a hard-coded "white" from the styling of the
button. Instead, the theme designer can now choose an appropriate
color for text that is displayed against a background of
--accent-color.