-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstatuses_test.go
More file actions
58 lines (53 loc) · 1.92 KB
/
Copy pathstatuses_test.go
File metadata and controls
58 lines (53 loc) · 1.92 KB
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
package idlerpg
import (
"context"
"testing"
)
func TestPoisonSapsAndFades(t *testing.T) {
m, _, st := newMgr()
ctx := context.Background()
m.Handle(chanMsg("alice", "!rpg"))
st.HSet(ctx, sheetKey("net|alice"), "level", 20)
p := player{network: "net", nick: "alice", channel: "#chan", key: "net|alice"}
m.applyPoison(ctx, p, 2)
if s, _ := st.HGetAll(ctx, sheetKey("net|alice")); !poisoned(s) {
t.Fatal("alice should be poisoned")
}
// two ticks of status: damage accrues, poison counts down to 0
m.tickStatus(ctx, p)
if s, _ := st.HGetAll(ctx, sheetKey("net|alice")); s["dmg"] <= 0 {
t.Fatal("poison should deal damage")
}
m.tickStatus(ctx, p)
if s, _ := st.HGetAll(ctx, sheetKey("net|alice")); poisoned(s) {
t.Fatal("poison should have worn off after its duration")
}
}
func TestQuaffCuresPoison(t *testing.T) {
m, r, st := newMgr()
ctx := context.Background()
m.Handle(chanMsg("alice", "!rpg"))
st.HSet(ctx, sheetKey("net|alice"), "pots", 1)
st.HSet(ctx, sheetKey("net|alice"), "poison", 3)
m.Handle(chanMsg("alice", "!rpg quaff")) // healthy but poisoned → still allowed
if !r.has("venom is purged") {
t.Fatalf("quaff should cure poison, got %q", r.last())
}
if s, _ := st.HGetAll(ctx, sheetKey("net|alice")); poisoned(s) {
t.Fatal("poison should be cured after quaffing")
}
}
func TestVenomousMonsterPoisons(t *testing.T) {
m, _, st := newMgr()
ctx := context.Background()
m.Handle(chanMsg("alice", "!rpg"))
st.HSet(ctx, sheetKey("net|alice"), "level", 1) // low HP so it takes damage
sheet, _ := st.HGetAll(ctx, sheetKey("net|alice"))
p := player{network: "net", nick: "alice", channel: "#chan", key: "net|alice"}
// a venomous foe strong enough to land hits
mon := monster{Name: "a will-o'-wisp", AC: 30, Atk: 30, DmgDie: 4, HP: 100}
m.resolveFight(ctx, p, sheet, "", mon)
if s, _ := st.HGetAll(ctx, sheetKey("net|alice")); !poisoned(s) {
t.Fatal("a venomous foe that drew blood should leave poison")
}
}