forked from genshinsim/gcsim
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfinaleofthedeepgalleries.go
More file actions
119 lines (101 loc) · 3.21 KB
/
Copy pathfinaleofthedeepgalleries.go
File metadata and controls
119 lines (101 loc) · 3.21 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
package finaleofthedeepgalleries
import (
"fmt"
"github.com/genshinsim/gcsim/pkg/core"
"github.com/genshinsim/gcsim/pkg/core/attacks"
"github.com/genshinsim/gcsim/pkg/core/attributes"
"github.com/genshinsim/gcsim/pkg/core/event"
"github.com/genshinsim/gcsim/pkg/core/glog"
"github.com/genshinsim/gcsim/pkg/core/info"
"github.com/genshinsim/gcsim/pkg/core/keys"
"github.com/genshinsim/gcsim/pkg/core/player/character"
"github.com/genshinsim/gcsim/pkg/modifier"
)
const (
normalDebuffKey = "deep-galleries-4pc-normal-debuff"
burstDebuffKey = "deep-galleries-4pc-burst-debuff"
)
func init() {
core.RegisterSetFunc(keys.FinaleOfTheDeepGalleries, NewSet)
}
type Set struct {
Index int
Count int
c *core.Core
char *character.CharWrapper
}
func (s *Set) SetIndex(idx int) { s.Index = idx }
func (s *Set) GetCount() int { return s.Count }
func (s *Set) Init() error { return nil }
func NewSet(c *core.Core, char *character.CharWrapper, count int, param map[string]int) (info.Set, error) {
s := Set{
Count: count,
c: c,
char: char,
}
s.pc2()
s.pc4()
return &s, nil
}
func (s *Set) pc2() {
if s.Count < 2 {
return
}
m := make([]float64, attributes.EndStatType)
m[attributes.CryoP] = 0.15
s.char.AddStatMod(character.StatMod{
Base: modifier.NewBase("deep-galleries-2pc", -1),
AffectedStat: attributes.CryoP,
Amount: func() ([]float64, bool) {
return m, true
},
})
}
func (s *Set) pc4() {
if s.Count < 4 {
return
}
procDurNormal := 360 // 6s * 60
procDurBurst := 360 // 6s * 60
m := make([]float64, attributes.EndStatType)
m[attributes.DmgP] = 0.6
s.char.AddAttackMod(character.AttackMod{
Base: modifier.NewBase("deep-galleries-4pc", -1),
Amount: func(atk *info.AttackEvent, t info.Target) ([]float64, bool) {
if s.char.Energy != 0 {
return nil, false
}
if atk.Info.AttackTag != attacks.AttackTagNormal && atk.Info.AttackTag != attacks.AttackTagElementalBurst {
return nil, false
}
if atk.Info.AttackTag == attacks.AttackTagNormal && s.char.StatusIsActive(normalDebuffKey) {
return nil, false
}
if atk.Info.AttackTag == attacks.AttackTagElementalBurst && s.char.StatusIsActive(burstDebuffKey) {
return nil, false
}
return m, true
},
})
s.c.Events.Subscribe(event.OnEnemyDamage, func(args ...interface{}) bool {
// If attack does not belong to the equipped character then ignore
atk := args[1].(*info.AttackEvent)
if atk.Info.ActorIndex != s.char.Index {
return false
}
// If this is not a normal attack or elemental burst then ignore
if atk.Info.AttackTag != attacks.AttackTagNormal && atk.Info.AttackTag != attacks.AttackTagElementalBurst {
return false
}
if atk.Info.AttackTag == attacks.AttackTagNormal {
s.char.AddStatus(burstDebuffKey, procDurBurst, true)
s.c.Log.NewEvent("deep galleries 4pc stop playing", glog.LogArtifactEvent, s.char.Index).
Write("burst_buff_stop_expiry", s.c.F+procDurBurst)
} else {
s.char.AddStatus(normalDebuffKey, procDurNormal, true)
s.c.Log.NewEvent("deep galleries 4pc stop playing", glog.LogArtifactEvent, s.char.Index).
Write("normal_buff_stop_expiry", s.c.F+procDurNormal)
}
return false
}, fmt.Sprintf("deep-galleries-4pc-%v", s.char.Base.Key.String()))
}