-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathdisciple.go
More file actions
83 lines (75 loc) · 2.19 KB
/
disciple.go
File metadata and controls
83 lines (75 loc) · 2.19 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package disciple
import (
"github.com/simimpact/srsim/pkg/engine"
"github.com/simimpact/srsim/pkg/engine/equip/relic"
"github.com/simimpact/srsim/pkg/engine/event"
"github.com/simimpact/srsim/pkg/engine/info"
"github.com/simimpact/srsim/pkg/engine/modifier"
"github.com/simimpact/srsim/pkg/engine/prop"
"github.com/simimpact/srsim/pkg/key"
"github.com/simimpact/srsim/pkg/model"
)
const (
check = "longevous-disciple"
crbuff = "longevous-disciple-cr-buff"
)
// 2pc: Increases Max HP by 12%.
// 4pc: When the wearer is hit or has their HP consumed by an ally or themselves,
// their CRIT Rate increases by 8% for 2 turn(s) and up to 2 stacks.
// TO-DO: in onHPChange, assumes e.Target means source; check whether this is correct
func init() {
relic.Register(key.LongevousDisciple, relic.Config{
Effects: []relic.SetEffect{
{
MinCount: 2,
Stats: info.PropMap{prop.HPPercent: 0.12},
CreateEffect: nil,
},
{
MinCount: 4,
Stats: nil,
CreateEffect: func(engine engine.Engine, owner key.TargetID) {
engine.AddModifier(owner, info.Modifier{
Name: check,
Source: owner,
})
},
},
},
})
modifier.Register(check, modifier.Config{
Listeners: modifier.Listeners{
OnHPChange: onHPChange,
OnAfterBeingAttacked: onAfterBeingAttacked,
},
})
modifier.Register(crbuff, modifier.Config{
Stacking: modifier.ReplaceBySource,
StatusType: model.StatusType_STATUS_BUFF,
CanDispel: true,
MaxCount: 2,
CountAddWhenStack: 1,
Duration: 2,
Listeners: modifier.Listeners{
OnAdd: onAdd,
},
})
}
func onHPChange(mod *modifier.Instance, e event.HPChange) {
// source is friendly, not HP change by damage, hp change is negative
if mod.Engine().IsCharacter(e.Target) && !e.IsHPChangeByDamage && e.NewHP < e.OldHP {
mod.Engine().AddModifier(mod.Owner(), info.Modifier{
Name: crbuff,
Source: mod.Owner(),
})
}
}
func onAfterBeingAttacked(mod *modifier.Instance, e event.AttackEnd) {
mod.Engine().AddModifier(mod.Owner(), info.Modifier{
Name: crbuff,
Source: mod.Owner(),
})
}
func onAdd(mod *modifier.Instance) {
mod.AddProperty(prop.ATKPercent, 0.08*mod.Count())
}