Compare commits
2 Commits
93716a7f0f
...
29265a18b7
Author | SHA1 | Date | |
---|---|---|---|
|
29265a18b7 | ||
|
d0b3cbd47a |
@ -277,6 +277,7 @@ func (g *Match) DTO(id player.ID, deadline time.Time) serve.Game {
|
||||
Round: g.round,
|
||||
Dealer: g.CurrentPlayer() == &g.players[0],
|
||||
Damage: g.damage,
|
||||
Adrenaline: g.adrenaline,
|
||||
Shell: g.Peek(id),
|
||||
Previous: g.prev,
|
||||
Deadline: deadline.UnixMilli(),
|
||||
|
@ -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.damage != 1, "damage is %d, want 1", []any{g.damage}},
|
||||
{g.reveal, "revealed at start", nil},
|
||||
{g.adrenaline, "adrenaline at start", nil},
|
||||
{g.prev != nil, "already discharged", nil},
|
||||
}
|
||||
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.damage != 1, "damage is %d, want 1", []any{g.damage}},
|
||||
{g.reveal, "revealed at start", nil},
|
||||
{g.adrenaline, "adrenaline at start", nil},
|
||||
{g.prev != nil, "already discharged", nil},
|
||||
}
|
||||
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.damage != 1, "damage is %d, want 1", []any{g.damage}},
|
||||
{g.reveal, "revealed at start", nil},
|
||||
{g.adrenaline, "adrenaline at start", nil},
|
||||
{g.prev != nil, "already discharged", nil},
|
||||
}
|
||||
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.damage != 1, "damage is %d, want 1", []any{g.damage}},
|
||||
{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}},
|
||||
}
|
||||
for _, c := range checks {
|
||||
@ -451,6 +455,7 @@ func TestGameDTO(t *testing.T) {
|
||||
Round: g.round,
|
||||
Dealer: false,
|
||||
Damage: g.damage,
|
||||
Adrenaline: false,
|
||||
Shell: nil,
|
||||
Previous: nil,
|
||||
Live: len(g.shells) / 2,
|
||||
@ -477,6 +482,7 @@ func TestGameDTO(t *testing.T) {
|
||||
Round: g.round,
|
||||
Dealer: true,
|
||||
Damage: g.damage,
|
||||
Adrenaline: false,
|
||||
Shell: nil,
|
||||
Previous: &g.shellArray[0],
|
||||
Live: 0,
|
||||
|
@ -17,6 +17,8 @@ type Game struct {
|
||||
Dealer bool `json:"dealer"`
|
||||
// Damage is the damage a live shell will deal this turn.
|
||||
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.
|
||||
// Undefined if this game state is not for the current player or if the
|
||||
// current player hasn't revealed it.
|
||||
|
@ -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`,
|
||||
Cuff: (game) => `THE ${game.dealer ? "DEALER" : "CHALLENGER"} HANDS CUFFS ACROSS THE TABLE`,
|
||||
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`,
|
||||
ChallengerConcedes: () => `THE CHALLENGER SUDDENLY TURNS TO DUST`,
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ export interface Game {
|
||||
action: "Start"
|
||||
| "Shoot" | "GameEnd" | "BeerGameEnd" | "ChallengerWins" | "DealerWins"
|
||||
| "Lens" | "Cig" | "Beer" | "Cuff" | "Knife"
|
||||
| "Adrenaline" | "Phone" | "Inverter" | "PillsHeal" | "PillsHurt"
|
||||
| "DealerConcedes" | "ChallengerConcedes"
|
||||
/**
|
||||
* Match winner.
|
||||
@ -30,6 +31,10 @@ export interface Game {
|
||||
* Damage that a live round will deal this turn.
|
||||
*/
|
||||
damage: number;
|
||||
/**
|
||||
* Current player's adrenaline state.
|
||||
*/
|
||||
adrenaline: boolean;
|
||||
/**
|
||||
* Deadline for the current player's next action in milliseconds since the
|
||||
* Unix epoch.
|
||||
|
Loading…
Reference in New Issue
Block a user