refactor(fightc): 优化战斗准备逻辑
- 调整了 1v1 战斗和野怪战斗中宠物实体的创建时机 - 修复了部分情况下宠物实体未正确创建的问题 - 优化了战斗准备流程,提高了代码的可读性和稳定性
This commit is contained in:
@@ -91,20 +91,21 @@ func (f *FightC) ReadyFight(c PlayerI) {
|
||||
case 1: // 1v1
|
||||
if c == f.Our {
|
||||
f.AFinished = true
|
||||
f.OurCurrentPet = info.CreateBattlePetEntity(f.Info.OurPetList[0])
|
||||
|
||||
if f.BFinished {
|
||||
|
||||
rrsult()
|
||||
}
|
||||
} else {
|
||||
f.Opp = c
|
||||
f.OppCurrentPet = info.CreateBattlePetEntity(f.Info.OpponentPetList[0])
|
||||
f.BFinished = true
|
||||
if f.AFinished {
|
||||
rrsult()
|
||||
}
|
||||
}
|
||||
case 3: // 野怪战斗
|
||||
|
||||
f.OppCurrentPet = info.CreateBattlePetEntity(f.Info.OpponentPetList[0])
|
||||
//判断捕捉率大于0
|
||||
if gconv.Int(xmlres.PetMAP[int(f.Info.OpponentPetList[0].ID)].CatchRate) > 0 {
|
||||
rett.Info2.Catchable = 1
|
||||
@@ -129,7 +130,7 @@ func (f *FightC) NewFight(i *info.NoteReadyToFightInfo, plays PlayerI) {
|
||||
f.Info = i
|
||||
f.StartTime = time.Now()
|
||||
f.actionChan = make(chan info.BattleActionI, 2) // 初始化全局操作通道
|
||||
|
||||
f.OurCurrentPet = info.CreateBattlePetEntity(f.Info.OurPetList[0])
|
||||
switch i.FightId {
|
||||
case 1:
|
||||
// 1v1,等双方进入
|
||||
|
||||
Reference in New Issue
Block a user