diff --git a/game/action.go b/game/action.go index a5f199c..5da6c30 100644 --- a/game/action.go +++ b/game/action.go @@ -17,6 +17,11 @@ const ( actBeer // note prev indicates whether the shell was live actCuff actKnife + actAdrenaline + actPhone + actInverter + actPillsHeal + actPillsHurt actDealerConcedes // dealer concedes actChallengerConcedes // challenger concedes diff --git a/game/action_string.go b/game/action_string.go index 87b3f68..abbd329 100644 --- a/game/action_string.go +++ b/game/action_string.go @@ -19,13 +19,18 @@ func _() { _ = x[actBeer-8] _ = x[actCuff-9] _ = x[actKnife-10] - _ = x[actDealerConcedes-11] - _ = x[actChallengerConcedes-12] + _ = x[actAdrenaline-11] + _ = x[actPhone-12] + _ = x[actInverter-13] + _ = x[actPillsHeal-14] + _ = x[actPillsHurt-15] + _ = x[actDealerConcedes-16] + _ = x[actChallengerConcedes-17] } -const _action_name = "StartShootGameEndBeerGameEndChallengerWinsDealerWinsLensCigBeerCuffKnifeDealerConcedesChallengerConcedes" +const _action_name = "StartShootGameEndBeerGameEndChallengerWinsDealerWinsLensCigBeerCuffKnifeAdrenalinePhoneInverterPillsHealPillsHurtDealerConcedesChallengerConcedes" -var _action_index = [...]uint8{0, 5, 10, 17, 28, 42, 52, 56, 59, 63, 67, 72, 86, 104} +var _action_index = [...]uint8{0, 5, 10, 17, 28, 42, 52, 56, 59, 63, 67, 72, 82, 87, 95, 104, 113, 127, 145} func (i action) String() string { if i >= action(len(_action_index)-1) { diff --git a/game/item.go b/game/item.go index c5e0fb6..c76722a 100644 --- a/game/item.go +++ b/game/item.go @@ -11,10 +11,14 @@ const ( itemBeer itemCuff itemKnife + itemAdrenaline + itemPhone + itemInverter + itemPill ) func newItem() item { - return item(rand.IntN(5)) + 1 + return item(rand.IntN(9)) + 1 } func (i item) apply(g *Match) bool { @@ -57,12 +61,45 @@ func (i item) apply(g *Match) bool { g.action = actKnife g.damage = 2 return true + case itemAdrenaline: + g.action = actAdrenaline + // TODO(zeph): implement + return true + case itemPhone: + g.action = actPhone + // TODO(zeph): implement + return true + case itemInverter: + g.action = actInverter + g.shells[0] = !g.shells[0] + return true + case itemPill: + cur := g.CurrentPlayer() + if rand.Uint64() <= (1<<65)/5 { + g.action = actPillsHeal + cur.hp = min(cur.hp+2, g.hp) + } else { + g.action = actPillsHurt + cur.hp-- + } + return true default: panic("shotgun: unknown item") } } -var itemNames = [...]string{"", "🔍", "🚬", "🍺", "👮", "🔪"} +var itemNames = [...]string{ + itemNone: "", + itemLens: "🔍", + itemCig: "🚬", + itemBeer: "🍺", + itemCuff: "👮", + itemKnife: "🔪", + itemAdrenaline: "💉", + itemPhone: "📱", + itemInverter: "🧲", + itemPill: "💊", +} func (i item) String() string { return itemNames[i] diff --git a/game/item_test.go b/game/item_test.go index 482dd26..965a6a0 100644 --- a/game/item_test.go +++ b/game/item_test.go @@ -13,6 +13,10 @@ func TestItemStrings(t *testing.T) { {itemBeer, "🍺"}, {itemCuff, "👮"}, {itemKnife, "🔪"}, + {itemAdrenaline, "💉"}, + {itemPhone, "📱"}, + {itemInverter, "🧲"}, + {itemPill, "💊"}, } for _, c := range cases { got := c.item.String()