-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathguard.go
More file actions
67 lines (62 loc) · 1.63 KB
/
guard.go
File metadata and controls
67 lines (62 loc) · 1.63 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
package guard
import (
"github.com/simimpact/srsim/pkg/engine"
"github.com/simimpact/srsim/pkg/engine/equip/relic"
"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 (
guard = "guard-of-wuthering-snow"
heal = "guard-of-wuthering-snow-heal"
energy = "guard-of-wuthering-snow-energy"
)
// 2pc: Reduces DMG taken by 8%.
// 4pc: At the beginning of the turn, if the wearer's HP is equal to or less than 50%,
// restores HP equal to 8% of their Max HP and regenerates 5 Energy.
func init() {
relic.Register(key.GuardOfWutheringSnow, relic.Config{
Effects: []relic.SetEffect{
{
MinCount: 2,
Stats: info.PropMap{prop.AllDamageReduce: 0.08},
CreateEffect: nil,
},
{
MinCount: 4,
Stats: nil,
CreateEffect: func(engine engine.Engine, owner key.TargetID) {
engine.AddModifier(owner, info.Modifier{
Name: guard,
Source: owner,
})
},
},
},
})
modifier.Register(guard, modifier.Config{
Listeners: modifier.Listeners{
OnPhase1: onPhase1,
},
})
}
func onPhase1(mod *modifier.Instance) {
// If above 50% HP, bypass
if mod.Engine().HPRatio(mod.Owner()) > 0.5 {
return
}
mod.Engine().Heal(info.Heal{
Key: heal,
Targets: []key.TargetID{mod.Owner()},
Source: mod.Owner(),
BaseHeal: info.HealMap{model.HealFormula_BY_TARGET_MAX_HP: 0.08},
})
mod.Engine().ModifyEnergy(info.ModifyAttribute{
Key: energy,
Target: mod.Owner(),
Source: mod.Owner(),
Amount: 5.0,
})
}