refactor: 重构战斗初始化传递宠物列表
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful

This commit is contained in:
xinian
2026-03-22 23:41:51 +08:00
committed by cnb
parent 61b0d6093f
commit 4fb5653c28
9 changed files with 65 additions and 68 deletions

View File

@@ -8,14 +8,13 @@ import (
"blazing/logic/service/fight/info"
"blazing/logic/service/fight/input"
"blazing/logic/service/player"
"blazing/modules/config/service"
"blazing/modules/player/model"
"math/rand"
"time"
)
// 创建新战斗,邀请方和被邀请方,或者玩家和野怪方
func NewFight(p1, p2 common.PlayerI, fn func(model.FightOverInfo)) (*FightC, errorcode.ErrorCode) {
func NewFight(p1, p2 common.PlayerI, b1, b2 []model.PetInfo, fn func(model.FightOverInfo)) (*FightC, errorcode.ErrorCode) {
// fmt.Println("NewFight", p1.GetInfo().UserID)
f := &FightC{}
@@ -33,17 +32,15 @@ func NewFight(p1, p2 common.PlayerI, fn func(model.FightOverInfo)) (*FightC, err
//这里应该挪到玩家初始化执行
f.ReadyInfo.Status = f.Info.Status
if f.Info.Mode == info.BattleMode.PET_MELEE {
f.Melee = service.NewMELEEService().Def()
}
var err errorcode.ErrorCode
f.Our, err = f.initplayer(p1)
f.Our, err = f.initplayer(p1, b1)
if err > 0 {
return nil, err
}
f.Opp, err = f.initplayer(p2)
f.Opp, err = f.initplayer(p2, b2)
if err > 0 {
return nil, err