-
Notifications
You must be signed in to change notification settings - Fork 0
/
witch.go
59 lines (46 loc) · 960 Bytes
/
witch.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package roles
import (
"fmt"
"github.com/GSamuel/werewolves-of-millers-hollow/events"
"github.com/GSamuel/werewolves-of-millers-hollow/game"
)
type Witch struct {
*BaseRole
potionOfLife bool
poison bool
}
func (w *Witch) Name() string {
return WITCH
}
func (w *Witch) OnPlayerDead(g *game.Game, e *events.PlayerDeadEvent) {
if !w.Alive() {
return
}
if !e.WerewolfAttack() {
return
}
p := g.Player(w.ID())
if w.potionOfLife {
fmt.Printf("Witch %v: safe %v with life potion? ", w.ID(), e.ID())
revive := p.ReadBool()
if revive {
e.PreventDeath()
w.potionOfLife = false
fmt.Println("death prevented by witch")
}
}
if !w.poison {
return
}
fmt.Printf("Witch %v: want to use poison?", w.ID())
useIt := p.ReadBool()
if !useIt {
return
}
fmt.Printf("Witch %v:", w.ID())
i := p.ReadInt(func(i int) bool {
return Alive(g, i) && NotEqual(g, i, p.ID())
})
g.Player(i).Die(g, false)
w.poison = false
}