Compare commits

...

2 Commits

Author SHA1 Message Date
Branden J Brown 29265a18b7 add status messages for new items 2024-04-07 21:55:49 -05:00
Branden J Brown d0b3cbd47a add adrenaline to dto 2024-04-07 21:27:32 -05:00
5 changed files with 45 additions and 26 deletions

View File

@ -277,6 +277,7 @@ func (g *Match) DTO(id player.ID, deadline time.Time) serve.Game {
Round: g.round, Round: g.round,
Dealer: g.CurrentPlayer() == &g.players[0], Dealer: g.CurrentPlayer() == &g.players[0],
Damage: g.damage, Damage: g.damage,
Adrenaline: g.adrenaline,
Shell: g.Peek(id), Shell: g.Peek(id),
Previous: g.prev, Previous: g.prev,
Deadline: deadline.UnixMilli(), Deadline: deadline.UnixMilli(),

View File

@ -32,6 +32,7 @@ func TestNewGame(t *testing.T) {
{g.hp < 2 || g.hp > 4, "hp is %d, want 2-4", []any{g.hp}}, {g.hp < 2 || g.hp > 4, "hp is %d, want 2-4", []any{g.hp}},
{g.damage != 1, "damage is %d, want 1", []any{g.damage}}, {g.damage != 1, "damage is %d, want 1", []any{g.damage}},
{g.reveal, "revealed at start", nil}, {g.reveal, "revealed at start", nil},
{g.adrenaline, "adrenaline at start", nil},
{g.prev != nil, "already discharged", nil}, {g.prev != nil, "already discharged", nil},
} }
for _, c := range checks { for _, c := range checks {
@ -60,6 +61,7 @@ func TestGameStartRound(t *testing.T) {
{g.hp < 2 || g.hp > 4, "hp is %d, want 2-4", []any{g.hp}}, {g.hp < 2 || g.hp > 4, "hp is %d, want 2-4", []any{g.hp}},
{g.damage != 1, "damage is %d, want 1", []any{g.damage}}, {g.damage != 1, "damage is %d, want 1", []any{g.damage}},
{g.reveal, "revealed at start", nil}, {g.reveal, "revealed at start", nil},
{g.adrenaline, "adrenaline at start", nil},
{g.prev != nil, "already discharged", nil}, {g.prev != nil, "already discharged", nil},
} }
for _, c := range checks { for _, c := range checks {
@ -95,6 +97,7 @@ func TestGameStartGroup(t *testing.T) {
{g.turn != 1, "turn is %d, want 1", []any{g.turn}}, {g.turn != 1, "turn is %d, want 1", []any{g.turn}},
{g.damage != 1, "damage is %d, want 1", []any{g.damage}}, {g.damage != 1, "damage is %d, want 1", []any{g.damage}},
{g.reveal, "revealed at start", nil}, {g.reveal, "revealed at start", nil},
{g.adrenaline, "adrenaline at start", nil},
{g.prev != nil, "already discharged", nil}, {g.prev != nil, "already discharged", nil},
} }
for _, c := range checks { for _, c := range checks {
@ -128,6 +131,7 @@ func TestGameNextTurn(t *testing.T) {
{g.turn != i, "turn is %d, want %d", []any{g.turn, i}}, {g.turn != i, "turn is %d, want %d", []any{g.turn, i}},
{g.damage != 1, "damage is %d, want 1", []any{g.damage}}, {g.damage != 1, "damage is %d, want 1", []any{g.damage}},
{g.reveal, "revealed at start", nil}, {g.reveal, "revealed at start", nil},
{g.adrenaline, "adrenaline at start", nil},
{g.CurrentPlayer().cuffs != uncuffed, "cuffs is %d, want %d", []any{g.CurrentPlayer().cuffs, uncuffed}}, {g.CurrentPlayer().cuffs != uncuffed, "cuffs is %d, want %d", []any{g.CurrentPlayer().cuffs, uncuffed}},
} }
for _, c := range checks { for _, c := range checks {
@ -451,6 +455,7 @@ func TestGameDTO(t *testing.T) {
Round: g.round, Round: g.round,
Dealer: false, Dealer: false,
Damage: g.damage, Damage: g.damage,
Adrenaline: false,
Shell: nil, Shell: nil,
Previous: nil, Previous: nil,
Live: len(g.shells) / 2, Live: len(g.shells) / 2,
@ -477,6 +482,7 @@ func TestGameDTO(t *testing.T) {
Round: g.round, Round: g.round,
Dealer: true, Dealer: true,
Damage: g.damage, Damage: g.damage,
Adrenaline: false,
Shell: nil, Shell: nil,
Previous: &g.shellArray[0], Previous: &g.shellArray[0],
Live: 0, Live: 0,

View File

@ -17,6 +17,8 @@ type Game struct {
Dealer bool `json:"dealer"` Dealer bool `json:"dealer"`
// Damage is the damage a live shell will deal this turn. // Damage is the damage a live shell will deal this turn.
Damage int8 `json:"damage"` Damage int8 `json:"damage"`
// Adrenaline indicates whether the current player has adrenaline.
Adrenaline bool `json:"adrenaline"`
// Shell gives whether the current shell is live if it is revealed. // Shell gives whether the current shell is live if it is revealed.
// Undefined if this game state is not for the current player or if the // Undefined if this game state is not for the current player or if the
// current player hasn't revealed it. // current player hasn't revealed it.

View File

@ -48,6 +48,11 @@ const actionMessages: Record<Game["action"], (game: Game) => string> = {
Beer: (game) => `THE ${game.dealer ? "DEALER" : "CHALLENGER"} TAKES A SIP AND A ${game.previous ? "LIVE SHELL" : "BLANK"} CLATTERS ON THE TABLE`, Beer: (game) => `THE ${game.dealer ? "DEALER" : "CHALLENGER"} TAKES A SIP AND A ${game.previous ? "LIVE SHELL" : "BLANK"} CLATTERS ON THE TABLE`,
Cuff: (game) => `THE ${game.dealer ? "DEALER" : "CHALLENGER"} HANDS CUFFS ACROSS THE TABLE`, Cuff: (game) => `THE ${game.dealer ? "DEALER" : "CHALLENGER"} HANDS CUFFS ACROSS THE TABLE`,
Knife: (game) => `THE ${game.dealer ? "DEALER" : "CHALLENGER"} CUTS THE BARREL SHORT`, Knife: (game) => `THE ${game.dealer ? "DEALER" : "CHALLENGER"} CUTS THE BARREL SHORT`,
Adrenaline: (game) => `THE ${game.dealer ? "DEALER" : "CHALLENGER"} INJECTS ADRENALINE`,
Inverter: (game) => `THE ${game.dealer ? "DEALER" : "CHALLENGER"} CRANKS A POLARITY INVERTER`,
Phone: (game) => `THE ${game.dealer ? "DEALER" : "CHALLENGER"} LISTENS TO THE WHISPERS`,
PillsHeal: (game) => `THE ${game.dealer ? "DEALER" : "CHALLENGER"} INHALES A PILL... AND SMILES`,
PillsHurt: (game) => `THE ${game.dealer ? "DEALER" : "CHALLENGER"} INHALES A PILL... AND COLLAPSES`,
DealerConcedes: () => `THE DEALER SUDDENLY TURNS TO DUST`, DealerConcedes: () => `THE DEALER SUDDENLY TURNS TO DUST`,
ChallengerConcedes: () => `THE CHALLENGER SUDDENLY TURNS TO DUST`, ChallengerConcedes: () => `THE CHALLENGER SUDDENLY TURNS TO DUST`,
} }

View File

@ -13,6 +13,7 @@ export interface Game {
action: "Start" action: "Start"
| "Shoot" | "GameEnd" | "BeerGameEnd" | "ChallengerWins" | "DealerWins" | "Shoot" | "GameEnd" | "BeerGameEnd" | "ChallengerWins" | "DealerWins"
| "Lens" | "Cig" | "Beer" | "Cuff" | "Knife" | "Lens" | "Cig" | "Beer" | "Cuff" | "Knife"
| "Adrenaline" | "Phone" | "Inverter" | "PillsHeal" | "PillsHurt"
| "DealerConcedes" | "ChallengerConcedes" | "DealerConcedes" | "ChallengerConcedes"
/** /**
* Match winner. * Match winner.
@ -30,6 +31,10 @@ export interface Game {
* Damage that a live round will deal this turn. * Damage that a live round will deal this turn.
*/ */
damage: number; damage: number;
/**
* Current player's adrenaline state.
*/
adrenaline: boolean;
/** /**
* Deadline for the current player's next action in milliseconds since the * Deadline for the current player's next action in milliseconds since the
* Unix epoch. * Unix epoch.