diff --git a/logic/controller/fight_塔.go b/logic/controller/fight_塔.go index 3aa00723..5612200b 100644 --- a/logic/controller/fight_塔.go +++ b/logic/controller/fight_塔.go @@ -13,7 +13,6 @@ import ( "sync/atomic" - "github.com/gogf/gf/v2/util/gconv" "github.com/jinzhu/copier" ) @@ -207,32 +206,8 @@ func buildTowerMonsterInfo(towerBoss configmodel.BaseTowerConfig) (*model.Player monsterInfo := &model.PlayerInfo{Nick: towerBoss.Name} for i, boss := range bosses { monster := model.GenPetInfo(int(boss.MonID), 24, int(boss.Nature), 0, int(boss.Lv), nil, 0) - if boss.Hp != 0 { - monster.Hp = uint32(boss.Hp) - monster.MaxHp = uint32(boss.Hp) - } - - for statIdx, prop := range boss.Prop { - if prop != 0 { - monster.Prop[statIdx] = prop - } - } - - for skillIdx := 0; skillIdx < len(monster.SkillList) && skillIdx < len(boss.SKill); skillIdx++ { - if boss.SKill[skillIdx] != 0 { - monster.SkillList[skillIdx].ID = boss.SKill[skillIdx] - } - } - - effects := service.NewEffectService().Args(boss.Effect) - for _, effect := range effects { - monster.EffectInfo = append(monster.EffectInfo, model.PetEffectInfo{ - Idx: uint16(effect.ID), - EID: gconv.Uint16(effect.Eid), - Args: gconv.Ints(effect.Args), - }) - } - + monster.ConfigBoss(boss.PetBaseConfig) + appendPetEffects(monster, boss.Effect) monster.CatchTime = uint32(i) monsterInfo.PetList = append(monsterInfo.PetList, *monster) } diff --git a/modules/config/model/boss_pet.go b/modules/config/model/boss_pet.go index 270a63d1..6fbf7a66 100644 --- a/modules/config/model/boss_pet.go +++ b/modules/config/model/boss_pet.go @@ -2,10 +2,12 @@ package model import ( "blazing/cool" + "encoding/json" "fmt" "strings" "github.com/dop251/goja" + "github.com/gogf/gf/v2/frame/g" ) const ( @@ -157,6 +159,26 @@ func bindBossScriptFunctions(vm *goja.Runtime, hookAction any) { ctx.SwitchPetFn(uint32(catchTime)) return goja.Undefined() }) + + _ = vm.Set("debug", func(call goja.FunctionCall) goja.Value { + if len(call.Arguments) == 0 { + g.Log().Debugf(ctx, "[boss-script] debug() called with no arguments") + return goja.Undefined() + } + + parts := make([]string, 0, len(call.Arguments)) + for _, arg := range call.Arguments { + exported := arg.Export() + if bytes, err := json.Marshal(exported); err == nil { + parts = append(parts, string(bytes)) + continue + } + parts = append(parts, arg.String()) + } + + g.Log().Debugf(ctx, "[boss-script] %s", strings.Join(parts, " ")) + return goja.Undefined() + }) } func defaultHookActionResult(hookAction any) bool { diff --git a/modules/player/model/pet.go b/modules/player/model/pet.go index 3414d342..788b189c 100644 --- a/modules/player/model/pet.go +++ b/modules/player/model/pet.go @@ -160,6 +160,9 @@ func (pet *PetInfo) ConfigBoss(bm model.PetBaseConfig) { pet.ShinyInfo = append(pet.ShinyInfo, color) } + if bm.Skin > 0 { + pet.SkinID = uint32(bm.Skin) + } if bm.Hp != 0 { pet.Hp = uint32(bm.Hp) pet.MaxHp = uint32(bm.Hp) @@ -178,7 +181,7 @@ func (pet *PetInfo) ConfigBoss(bm model.PetBaseConfig) { if len(bm.SKill) != 0 { - for i := 0; i < 4; i++ { + for i := 0; i < 4 && i < len(bm.SKill); i++ { if bm.SKill[i] != 0 { pet.SkillList[i].ID = bm.SKill[i] }