Skip to content

Commit

Permalink
fix goconst linting issues (genshinsim#1736)
Browse files Browse the repository at this point in the history
  • Loading branch information
srliao authored Oct 31, 2023
1 parent e652557 commit f596aa4
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 22 deletions.
10 changes: 6 additions & 4 deletions internal/weapons/catalyst/emeraldorb/emeraldorb.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,12 @@ func NewWeapon(c *core.Core, char *character.CharWrapper, p info.WeaponProfile)
return false
}

c.Events.Subscribe(event.OnVaporize, addBuff, "emeraldorb-"+char.Base.Key.String())
c.Events.Subscribe(event.OnElectroCharged, addBuff, "emeraldorb-"+char.Base.Key.String())
c.Events.Subscribe(event.OnFrozen, addBuff, "emeraldorb-"+char.Base.Key.String())
c.Events.Subscribe(event.OnSwirlHydro, addBuff, "emeraldorb-"+char.Base.Key.String())
subKey := "emeraldorb-" + char.Base.Key.String()

c.Events.Subscribe(event.OnVaporize, addBuff, subKey)
c.Events.Subscribe(event.OnElectroCharged, addBuff, subKey)
c.Events.Subscribe(event.OnFrozen, addBuff, subKey)
c.Events.Subscribe(event.OnSwirlHydro, addBuff, subKey)

return w, nil
}
12 changes: 7 additions & 5 deletions pipeline/pkg/data/avatar/load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import (
"testing"
)

const dmSrc = "../../../data/ExcelBinOutput/"

func TestLoadAvatarExcel(t *testing.T) {
const src = "../../../data/ExcelBinOutput/" + AvatarExcelConfigData
const src = dmSrc + AvatarExcelConfigData

res, err := loadAvatarExcel(src)
if err != nil {
Expand All @@ -26,7 +28,7 @@ func TestLoadAvatarExcel(t *testing.T) {
}

func TestLoadAvatarSkillDepot(t *testing.T) {
const src = "../../../data/ExcelBinOutput/" + AvatarSkillDepotExcelConfigData
const src = dmSrc + AvatarSkillDepotExcelConfigData

res, err := loadAvatarSkillDepot(src)
if err != nil {
Expand All @@ -39,7 +41,7 @@ func TestLoadAvatarSkillDepot(t *testing.T) {
}

func TestLoadAvatarSkillExcel(t *testing.T) {
const src = "../../../data/ExcelBinOutput/" + AvatarSkillExcelConfigData
const src = dmSrc + AvatarSkillExcelConfigData

res, err := loadAvatarSkillExcel(src)
if err != nil {
Expand All @@ -52,7 +54,7 @@ func TestLoadAvatarSkillExcel(t *testing.T) {
}

func TestLoadFetterInfo(t *testing.T) {
const src = "../../../data/ExcelBinOutput/" + FetterInfoExcelConfigData
const src = dmSrc + FetterInfoExcelConfigData

res, err := loadAvatarFetterInfo(src)
if err != nil {
Expand All @@ -65,7 +67,7 @@ func TestLoadFetterInfo(t *testing.T) {
}

func TestLoadPromotData(t *testing.T) {
const src = "../../../data/ExcelBinOutput/" + AvatarPromoteExcelConfigData
const src = dmSrc + AvatarPromoteExcelConfigData

res, err := loadAvatarPromoteData(src)
if err != nil {
Expand Down
12 changes: 7 additions & 5 deletions pkg/conditional/character.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ func evalCharacter(c *core.Core, key keys.Char, fields []string) (any, error) {
return evalCharacterAbil(c, char, act, fields[2])
}

charCat := "character " + typ

switch typ {
case "id":
return int(char.Base.Key), nil
Expand All @@ -46,27 +48,27 @@ func evalCharacter(c *core.Core, key keys.Char, fields []string) (any, error) {
case "weapon":
return int(char.Weapon.Key), nil
case "status":
if err := fieldsCheck(fields, 3, "character "+typ); err != nil {
if err := fieldsCheck(fields, 3, charCat); err != nil {
return 0, err
}
return char.StatusDuration(fields[2]), nil
case "mods":
if err := fieldsCheck(fields, 3, "character "+typ); err != nil {
if err := fieldsCheck(fields, 3, charCat); err != nil {
return 0, err
}
return char.StatusDuration(fields[2]), nil
case "infusion":
if err := fieldsCheck(fields, 3, "character "+typ); err != nil {
if err := fieldsCheck(fields, 3, charCat); err != nil {
return 0, err
}
return c.Player.WeaponInfuseIsActive(char.Index, fields[2]), nil
case "tags":
if err := fieldsCheck(fields, 3, "character "+typ); err != nil {
if err := fieldsCheck(fields, 3, charCat); err != nil {
return 0, err
}
return char.Tag(fields[2]), nil
case "stats":
if err := fieldsCheck(fields, 3, "character "+typ); err != nil {
if err := fieldsCheck(fields, 3, charCat); err != nil {
return 0, err
}
return evalCharacterStats(char, fields[2])
Expand Down
6 changes: 3 additions & 3 deletions pkg/core/combat/absorb.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func (h *Handler) AbsorbCheck(p AttackPattern, prio ...attributes.Element) attri
}
if collision, _ := t.AttackWillLand(p); collision && t.AuraContains(e) {
h.Log.NewEvent(
"infusion check picked up "+e.String(),
"infusion check (e) picked up "+e.String(),
glog.LogElementEvent,
-1,
).
Expand All @@ -31,7 +31,7 @@ func (h *Handler) AbsorbCheck(p AttackPattern, prio ...attributes.Element) attri
}
if collision, _ := t.AttackWillLand(p); collision && t.AuraContains(e) {
h.Log.NewEvent(
"infusion check picked up "+e.String(),
"infusion check (g) picked up "+e.String(),
glog.LogElementEvent,
-1,
).
Expand All @@ -43,7 +43,7 @@ func (h *Handler) AbsorbCheck(p AttackPattern, prio ...attributes.Element) attri
if t, ok := h.player.(TargetWithAura); ok {
if collision, _ := t.AttackWillLand(p); collision && t.AuraContains(e) {
h.Log.NewEvent(
"infusion check picked up "+e.String(),
"infusion check (p) picked up "+e.String(),
glog.LogElementEvent,
-1,
).
Expand Down
12 changes: 7 additions & 5 deletions pkg/core/construct/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"github.com/genshinsim/gcsim/pkg/core/glog"
)

const destroyedMsg = "construct destroyed: "

type Handler struct {
constructs []Construct
consNoLimit []Construct
Expand Down Expand Up @@ -60,7 +62,7 @@ func (h *Handler) NewConstruct(c Construct, refresh bool, constructs *[]Construc
// if length > 3, then destruct the beginning ones
for i := 0; i < len((*constructs))-3; i++ {
(*constructs)[i].OnDestruct()
h.log.NewEventBuildMsg(glog.LogConstructEvent, -1, "construct destroyed: "+(*constructs)[i].Type().String()).
h.log.NewEventBuildMsg(glog.LogConstructEvent, -1, destroyedMsg+(*constructs)[i].Type().String()).
Write("key", (*constructs)[i].Key()).
Write("type", (*constructs)[i].Type())
(*constructs)[i] = nil
Expand Down Expand Up @@ -88,7 +90,7 @@ func (h *Handler) Tick() {
for _, v := range h.constructs {
if v.Expiry() == *h.f {
v.OnDestruct()
h.log.NewEventBuildMsg(glog.LogConstructEvent, -1, "construct destroyed: "+v.Type().String()).
h.log.NewEventBuildMsg(glog.LogConstructEvent, -1, destroyedMsg+v.Type().String()).
Write("key", v.Key()).
Write("type", v.Type())
} else {
Expand All @@ -101,7 +103,7 @@ func (h *Handler) Tick() {
for i, v := range h.consNoLimit {
if v.Expiry() == *h.f {
h.consNoLimit[i].OnDestruct()
h.log.NewEventBuildMsg(glog.LogConstructEvent, -1, "construct destroyed: "+v.Type().String()).
h.log.NewEventBuildMsg(glog.LogConstructEvent, -1, destroyedMsg+v.Type().String()).
Write("key", v.Key()).
Write("type", v.Type())
} else {
Expand Down Expand Up @@ -212,7 +214,7 @@ func (h *Handler) Destroy(key int) bool {
if v.Key() == key {
v.OnDestruct()
ok = true
h.log.NewEventBuildMsg(glog.LogConstructEvent, -1, "construct destroyed: "+v.Type().String()).
h.log.NewEventBuildMsg(glog.LogConstructEvent, -1, destroyedMsg+v.Type().String()).
Write("key", v.Key()).
Write("type", v.Type())
} else {
Expand All @@ -229,7 +231,7 @@ func (h *Handler) Destroy(key int) bool {
if v.Key() == key {
h.consNoLimit[i].OnDestruct()
ok = true
h.log.NewEventBuildMsg(glog.LogConstructEvent, -1, "construct destroyed: "+v.Type().String()).
h.log.NewEventBuildMsg(glog.LogConstructEvent, -1, destroyedMsg+v.Type().String()).
Write("key", v.Key()).
Write("type", v.Type())
} else {
Expand Down

0 comments on commit f596aa4

Please sign in to comment.