feat(ahorcado): facelift — branding, solo play, idle timeout, win/lose colors#58
Merged
Conversation
…e colors
- title prefixed with 🎯 (distinct from /ruleta's 🔫); end-state title swaps
to 🏆 on win and 💀 on loss
- color: fun yellow during play; signal-carrying green (#57F287) on victory
and mod red (#ED4245) on defeat — same convention exception as /imc, /ruleta
- footer 'Xiza Bot vX.Y.Z' on every embed
- inline embed objects → EmbedBuilder, helpers extracted (buildKickoffEmbed,
buildTurnEmbed, buildEndEmbed, buildAbandonedEmbed)
functional fixes:
- player2 now optional. Solo play allowed only when bot_picks_word:true
(otherwise you'd be guessing your own word — rejected with ephemeral notice)
- duplicate player rejection (covers 'player2 == player3' and 'player2 == self'),
matching the /ruleta validation
- collector idle timeout 5min, then '⌛ Ahorcado abandonado' embed —
fixes the same dangling-collector issue we hit in /ruleta
- explicit collector.stop('end') on win/lose so 'idle' end reason is clean
other:
- description neutral Spanish: 'Tú eliges' → 'Eliges' (drops the explicit
pronoun — both are neutral but Eliges flows better)
- WORD_PICK_TIMEOUT_MS named constant for the DM word-picking phase
tests: +4 (solo allowed, solo+pick=false rejected, duplicate rejection,
self-as-player2)
The DM-with-menu word-picking flow was a friction wall to start a game. Most plays just want to roll into the round; flipping the default makes `/ahorcado` single-tap to launch and `/ahorcado bot_picks_word:false` the explicit opt-in for the DM-picks path. - default: false → true - description and examples updated (`/ahorcado` now lists '/ahorcado', '/ahorcado player2:@bob', '/ahorcado player2:@bob bot_picks_word:false') - bot_picks_word option description spells out the new default - solo+false rejection text updated ('No pongas bot_picks_word:false') - tests: solo no-args path renamed and exercises the default; explicit bot_picks_word:false test exercises the rejection branch
death-games' Hangman constructor throws 'Debes proporcionar mínimo 2 ID's en la opcion jugadores' when given a single-element array. Solo play with the new bot_picks_word=true default crashed at runtime. Workaround: when solo, duplicate the player's ID for the library (libPlayerIds = [id, id]) while keeping the user-facing display as a single player. Turn rotation alternates between two slots that resolve to the same user, so the collector filter (msg.author.id === game.turno) keeps matching and the player just gets every turn — which is what solo play means. Tests passed because the death-games mock skips the validation; only real Discord runtime hit the throw.
… semantics Three fixes in one pass — the user reported (1) and (2), and I caught (3) while rewriting the turn loop. 1. Repeated letter no longer consumes a life The death-games library decrements 'vidas' every time find() sees a letter that's already in letrasUsadas (covers BOTH correct and incorrect repeats — library code lines 56-62 and 83-87). Adding the dedup check on our side before calling find() means typing 'b' twice no longer eats a second life. The repeating player keeps their turn and gets a friendly notice instead. 2. Wrong full-word guess eliminates the player The library treats multi-char input as just letra[0] (line 52: 'letra = letra[0]'), so a wrong full-word guess silently became a single-letter guess of the first character. Now we intercept full-word guesses ourselves: correct → win path (revealing every letter); wrong → eliminate that player (Set<string>, ignored by collector filter, skipped in turn rotation). When everyone is eliminated, game ends with a dedicated all-eliminated embed (red, 💀). 3. Turn-tracker semantics swap (latent bug from the facelift) My earlier refactor pre-rotated 'turn' after the kickoff and used it as the current-turn index in the filter — so kickoff said 'Empieza A' but the filter expected B's input. Solo play hid this because libPlayerIds are duplicated; multi-player would have stalled on the very first guess. Now 'turn' = the CURRENT player whose turn it is. Kickoff uses turn=0, collect handler uses turn for the filter, advances after processing. Helpers added: - buildSkipEmbed — 'X ya probó la letra Y, sigue su turno' - buildEliminationEmbed — '☠️ Jugador eliminado' with the failed guess - buildAllEliminatedEmbed — '💀 Todos eliminados' end embed - peekNextTurn(from) — returns the next non-eliminated index, or loops if every slot is eliminated (caller checks aliveUnique.size beforehand) Tests: +1 (filter matches the current-turn player, not pre-rotated). The dedup/elimination paths are integration-tested; the unit-test mocks would need a major rewrite to capture the constructed Hangman instance and trigger the collect handler in isolation. The user validates in Discord.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Octavo y último comando del facelift de fun.
/ahorcadoes el más complejo del bot (DM con StringSelectMenu para elegir palabra, collector con turnos, ascii art, GIF de derrota). Este PR aplica la convención de branding y agrega los mismos arreglos funcionales que hicimos en/ruleta.Branding
🎯 Ahorcado(emoji distinto a🔫de ruleta)🏆 Ahorcado — Victoriao💀 Ahorcado — Derrota/imcy/ruletaXiza Bot vX.Y.Zen todos los embedsEmbedBuilder+ helpers extraídosFuncionales
player2ahora opcional (solo play)bot_picks_word:truepermitido. Solo +falserechazado (estarías adivinando tu propia palabra)new Setcheck, mismo patrón que/ruleta. Cubre 'player2==player3' y 'player2==self'collector.stop('end')explícito en win/loseMantenido intacto
shared/data/words)Test plan
pnpm test→ 230/230 (was 226, +4 nuevos)tsc --noEmit→ limpio/ahorcado bot_picks_word:true(solo) → "jugando solo" en kickoff/ahorcado(sin args) → rechazo "necesitas bot_picks_word:true"/ahorcado player2:@bob bot_picks_word:true→ flow normal/ahorcado player2:@bob(sin bot_picks) → DM con menú de 25 palabras, 20s/ahorcado player2:@bob player3:@bob bot_picks_word:true→ rechazo duplicado