games: the clock beats the walk button, and the rack isn't betting

The trivia ladder handled a walk before it looked at the clock, so the
timeout only ever bit if the browser volunteered it. Sit on a question,
look it up, answer if you find it and walk if you don't, and you never
lose a ladder. The clock is now the first thing that happens to a move.

The house's chip rack was wired up as bet buttons on blackjack and
hangman: it's four spans with data-chip on them and nothing said the
handler only wanted the real ones. Clicking the house's money raised
your bet.

Hangman had two definitions of "a letter you'd guess" — unicode in the
engine, ASCII in the renderer — and a phrase with an accent in it would
have had no tile to fill and no key to fill it with. One definition now.

Plus: trivia's countdown no longer freezes at zero when the server turns
down a timeout report it was early for, questions whose wrong answer
decodes into the right one are dropped at the door, and hangman bets on
PeteFX's spot like every other table instead of its own copy of it.
This commit is contained in:
prosolis
2026-07-14 06:28:38 -07:00
parent 2d653bf439
commit 3e9b93af55
8 changed files with 120 additions and 87 deletions

View File

@@ -154,16 +154,21 @@ func start(bet int64, t Tier, phrase string, rakePct float64) (State, []Event, e
// Spaces and punctuation are never guessed — they start face up, because a
// row of blanks with the word breaks hidden is a puzzle about typography.
for i, r := range rs {
if !isGuessable(r) {
if !Guessable(r) {
s.Shown[i] = true
}
}
return s, []Event{{Kind: "start"}}, nil
}
// isGuessable reports whether a rune is one you'd guess: a letter or a digit.
// Guessable reports whether a rune is one you'd guess: a letter or a digit.
// Everything else is scaffolding and is shown from the start.
func isGuessable(r rune) bool {
//
// Exported because the renderer needs the same answer — a rune you'd guess is a
// rune that gets a tile to guess it into. Asking the drawing side to decide that
// for itself is how you get a board with no tile for a letter the engine is
// waiting on, and a phrase that cannot be finished.
func Guessable(r rune) bool {
return unicode.IsLetter(r) || unicode.IsDigit(r)
}
@@ -188,7 +193,7 @@ func ApplyMove(s State, m Move) (State, []Event, error) {
// applyLetter guesses one letter.
func applyLetter(s State, letter string) (State, []Event, error) {
rs := []rune(strings.ToLower(strings.TrimSpace(letter)))
if len(rs) != 1 || !isGuessable(rs[0]) {
if len(rs) != 1 || !Guessable(rs[0]) {
return s, nil, ErrNotALetter
}
g := rs[0]
@@ -373,7 +378,7 @@ func (s State) clone() State {
func normalize(s string) string {
var b strings.Builder
for _, r := range strings.ToLower(s) {
if isGuessable(r) {
if Guessable(r) {
b.WriteRune(r)
}
}