feat(fight): 添加旧组队协议支持并优化战斗系统 - 实现了旧组队协议相关功能,包括GroupReadyFightFinish、GroupUseSkill、 GroupUseItem、GroupChangePet和GroupEscape方法 - 新增组队战斗相关的入站信息结构体定义 - 实现了组队BOSS战斗逻辑,添加groupBossSlotLimit常量 - 重构宠物技能设置逻辑,调整金币消耗时机 - 优化战斗循环逻辑,添加对无行动槽位的处理 - 改进AI行动逻辑,增加多位置目标选择
This commit is contained in:
@@ -18,7 +18,8 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
rewardItemExpPool = 3
|
||||
rewardItemExpPool = 3
|
||||
groupBossSlotLimit = 3
|
||||
)
|
||||
|
||||
// PlayerFightBoss 挑战地图boss
|
||||
@@ -50,7 +51,7 @@ func (Controller) PlayerFightBoss(req *ChallengeBossInboundInfo, p *player.Playe
|
||||
ai.AddBattleProp(0, 2)
|
||||
|
||||
var fightC *fight.FightC
|
||||
fightC, err = fight.NewFight(p, ai, p.GetPetInfo(100), ai.GetPetInfo(0), func(foi model.FightOverInfo) {
|
||||
fightC, err = startMapBossFight(mapNode, p, ai, func(foi model.FightOverInfo) {
|
||||
if mapNode.WinBonusID == 0 {
|
||||
return
|
||||
}
|
||||
@@ -65,6 +66,63 @@ func (Controller) PlayerFightBoss(req *ChallengeBossInboundInfo, p *player.Playe
|
||||
return nil, -1
|
||||
}
|
||||
|
||||
func startMapBossFight(
|
||||
mapNode *configmodel.MapNode,
|
||||
p *player.Player,
|
||||
ai *player.AI_player,
|
||||
fn func(model.FightOverInfo),
|
||||
) (*fight.FightC, errorcode.ErrorCode) {
|
||||
ourPets := p.GetPetInfo(100)
|
||||
oppPets := ai.GetPetInfo(0)
|
||||
if mapNode != nil && mapNode.IsGroupBoss != 0 {
|
||||
ourSlots := buildGroupBossPetSlots(ourPets, groupBossSlotLimit)
|
||||
oppSlots := buildGroupBossPetSlots(oppPets, groupBossSlotLimit)
|
||||
if len(ourSlots) > 0 && len(oppSlots) > 0 {
|
||||
return fight.NewLegacyGroupFightSingleControllerN(p, ai, ourSlots, oppSlots, fn)
|
||||
}
|
||||
}
|
||||
return fight.NewFight(p, ai, ourPets, oppPets, fn)
|
||||
}
|
||||
|
||||
func buildGroupBossPetSlots(pets []model.PetInfo, slotLimit int) [][]model.PetInfo {
|
||||
if len(pets) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
slots := make([][]model.PetInfo, 0, slotLimit)
|
||||
for _, pet := range pets {
|
||||
if pet.Hp == 0 {
|
||||
continue
|
||||
}
|
||||
if slotLimit <= 0 {
|
||||
slotLimit = 3
|
||||
}
|
||||
if len(slots) < slotLimit {
|
||||
slots = append(slots, []model.PetInfo{pet})
|
||||
continue
|
||||
}
|
||||
break
|
||||
}
|
||||
if len(slots) == 0 {
|
||||
return nil
|
||||
}
|
||||
var idx int = 0
|
||||
for _, pet := range pets[len(slots):] {
|
||||
if pet.Hp == 0 {
|
||||
continue
|
||||
}
|
||||
for step := 0; step < len(slots); step++ {
|
||||
slotIdx := (idx + step) % len(slots)
|
||||
if len(slots[slotIdx]) < 6 {
|
||||
slots[slotIdx] = append(slots[slotIdx], pet)
|
||||
idx = (slotIdx + 1) % len(slots)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return slots
|
||||
}
|
||||
|
||||
// OnPlayerFightNpcMonster 战斗野怪
|
||||
func (Controller) OnPlayerFightNpcMonster(req *FightNpcMonsterInboundInfo, p *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
||||
if err = p.CanFight(); err != 0 {
|
||||
|
||||
Reference in New Issue
Block a user