diff --git a/modules/config/model/base_pet.go b/modules/config/model/base_pet.go index a26a4c03..a4345ac3 100644 --- a/modules/config/model/base_pet.go +++ b/modules/config/model/base_pet.go @@ -28,7 +28,7 @@ type PetBaseConfig struct { Nature int32 `gorm:"not null;default:0;comment:'BOSS属性-性格'" json:"nature"` Effect []uint32 `gorm:"type:jsonb;not null;default:'[]';comment:'BOSS特性'" json:"effect"` Lv int32 `gorm:"not null;comment:'BOSS等级(LvHpMatchUser非0时此配置无效)'" json:"lv"` - Color string `gorm:"comment:'BOSS颜色'" json:"color"` + ColorID uint32 `gorm:"not null;default:0;comment:'BOSS颜色配置ID'" json:"color_id"` Skin int32 `gorm:"not null;default:0;comment:'BOSS皮肤ID'" json:"skin"` Hp int32 `gorm:"comment:'BOSS血量值(LvHpMatchUser非0时此配置无效)'" json:"hp"` diff --git a/modules/config/model/boss_pet.go b/modules/config/model/boss_pet.go index 6fbf7a66..9b66d4d7 100644 --- a/modules/config/model/boss_pet.go +++ b/modules/config/model/boss_pet.go @@ -2,6 +2,7 @@ package model import ( "blazing/cool" + "context" "encoding/json" "fmt" "strings" @@ -161,8 +162,9 @@ func bindBossScriptFunctions(vm *goja.Runtime, hookAction any) { }) _ = vm.Set("debug", func(call goja.FunctionCall) goja.Value { + logCtx := context.Background() if len(call.Arguments) == 0 { - g.Log().Debugf(ctx, "[boss-script] debug() called with no arguments") + g.Log().Debugf(logCtx, "[boss-script] debug() called with no arguments") return goja.Undefined() } @@ -176,7 +178,7 @@ func bindBossScriptFunctions(vm *goja.Runtime, hookAction any) { parts = append(parts, arg.String()) } - g.Log().Debugf(ctx, "[boss-script] %s", strings.Join(parts, " ")) + g.Log().Debugf(logCtx, "[boss-script] %s", strings.Join(parts, " ")) return goja.Undefined() }) } diff --git a/modules/player/model/pet.go b/modules/player/model/pet.go index 788b189c..60a5c973 100644 --- a/modules/player/model/pet.go +++ b/modules/player/model/pet.go @@ -5,7 +5,6 @@ import ( "blazing/common/data/xmlres" "blazing/common/utils" "blazing/cool" - "encoding/json" "blazing/modules/config/model" "blazing/modules/config/service" @@ -154,11 +153,10 @@ type PetInfo struct { } func (pet *PetInfo) ConfigBoss(bm model.PetBaseConfig) { - var color data.GlowFilter - err := json.Unmarshal([]byte(bm.Color), &color) - if err == nil && color.Alpha != 0 { - pet.ShinyInfo = append(pet.ShinyInfo, color) - + if bm.ColorID > 0 { + if color := service.NewShinyService().GetShiny(int(bm.ColorID)); color != nil { + pet.ShinyInfo = append(pet.ShinyInfo, *color) + } } if bm.Skin > 0 { pet.SkinID = uint32(bm.Skin)