2024-01-20 23:06:56 -05:00
|
|
|
package game
|
|
|
|
|
|
|
|
type Item int8
|
|
|
|
|
|
|
|
const (
|
|
|
|
ItemNone Item = iota
|
|
|
|
ItemLens
|
|
|
|
ItemCig
|
|
|
|
ItemBeer
|
|
|
|
ItemCuff
|
|
|
|
ItemKnife
|
|
|
|
)
|
|
|
|
|
|
|
|
func NewItem(rng *RNG) Item {
|
|
|
|
return Item(rng.Intn(5)) + 1
|
|
|
|
}
|
2024-01-20 23:52:44 -05:00
|
|
|
|
2024-01-28 13:42:42 -05:00
|
|
|
func (i Item) Apply(g *Match) bool {
|
2024-01-20 23:52:44 -05:00
|
|
|
switch i {
|
|
|
|
case ItemNone:
|
|
|
|
return false
|
|
|
|
case ItemLens:
|
2024-02-03 12:44:11 -05:00
|
|
|
// Lenses are always used, even if they have no effect.
|
|
|
|
g.action = actLens
|
2024-01-21 05:16:48 -05:00
|
|
|
g.reveal = true
|
2024-01-20 23:52:44 -05:00
|
|
|
return true
|
|
|
|
case ItemCig:
|
2024-01-21 00:39:59 -05:00
|
|
|
cur := g.CurrentPlayer()
|
2024-01-21 05:16:48 -05:00
|
|
|
if cur.hp < g.hp {
|
|
|
|
cur.hp++
|
2024-01-21 19:41:43 -05:00
|
|
|
// Cigs are always used, even if they have no effect.
|
2024-01-20 23:52:44 -05:00
|
|
|
}
|
2024-02-03 12:44:11 -05:00
|
|
|
g.action = actCig
|
2024-01-21 19:41:43 -05:00
|
|
|
return true
|
2024-01-20 23:52:44 -05:00
|
|
|
case ItemBeer:
|
2024-01-28 13:42:42 -05:00
|
|
|
g.popShell()
|
2024-02-03 12:44:11 -05:00
|
|
|
g.action = actBeer
|
2024-01-20 23:52:44 -05:00
|
|
|
if g.Empty() {
|
2024-02-03 12:44:11 -05:00
|
|
|
g.action = actBeerGameEnd
|
2024-01-28 13:42:42 -05:00
|
|
|
g.NextGame()
|
2024-01-20 23:52:44 -05:00
|
|
|
}
|
|
|
|
return true
|
|
|
|
case ItemCuff:
|
|
|
|
opp := g.Opponent()
|
2024-01-21 05:16:48 -05:00
|
|
|
if opp.cuffs != Uncuffed {
|
2024-01-20 23:52:44 -05:00
|
|
|
return false
|
|
|
|
}
|
2024-02-03 12:44:11 -05:00
|
|
|
g.action = actCuff
|
2024-01-21 05:16:48 -05:00
|
|
|
opp.cuffs = Cuffed
|
2024-01-20 23:52:44 -05:00
|
|
|
return true
|
|
|
|
case ItemKnife:
|
2024-01-21 05:16:48 -05:00
|
|
|
if g.damage != 1 {
|
2024-01-20 23:52:44 -05:00
|
|
|
return false
|
|
|
|
}
|
2024-02-03 12:44:11 -05:00
|
|
|
g.action = actKnife
|
2024-01-21 05:16:48 -05:00
|
|
|
g.damage = 2
|
2024-01-20 23:52:44 -05:00
|
|
|
return true
|
|
|
|
default:
|
|
|
|
panic("shotgun: unknown item")
|
|
|
|
}
|
|
|
|
}
|
2024-01-21 01:47:12 -05:00
|
|
|
|
2024-02-03 12:44:11 -05:00
|
|
|
var itemNames = [...]string{"", "🔍", "🚬", "🍺", "👮", "🔪"}
|
|
|
|
|
2024-01-21 01:47:12 -05:00
|
|
|
func (i Item) String() string {
|
2024-02-03 12:44:11 -05:00
|
|
|
return itemNames[i]
|
2024-01-21 01:47:12 -05:00
|
|
|
}
|