feat(fight): 添加旧组队协议支持并优化战斗系统 - 实现了旧组队协议相关功能,包括GroupReadyFightFinish、GroupUseSkill、 GroupUseItem、GroupChangePet和GroupEscape方法 - 新增组队战斗相关的入站信息结构体定义 - 实现了组队BOSS战斗逻辑,添加groupBossSlotLimit常量 - 重构宠物技能设置逻辑,调整金币消耗时机 - 优化战斗循环逻辑,添加对无行动槽位的处理 - 改进AI行动逻辑,增加多位置目标选择
This commit is contained in:
@@ -69,12 +69,6 @@ func (h Controller) GetPetLearnableSkills(
|
||||
func (h Controller) SetPetSkill(data *ChangeSkillInfo, c *player.Player) (result *pet.ChangeSkillOutInfo, err errorcode.ErrorCode) {
|
||||
const setSkillCost = 50
|
||||
|
||||
if !c.GetCoins(setSkillCost) {
|
||||
return nil, errorcode.ErrorCodes.ErrSunDouInsufficient10016
|
||||
}
|
||||
|
||||
c.Info.Coins -= setSkillCost
|
||||
|
||||
_, currentPet, ok := c.FindPet(data.CatchTime)
|
||||
if !ok {
|
||||
return nil, errorcode.ErrorCodes.ErrSystemBusy
|
||||
@@ -93,28 +87,39 @@ func (h Controller) SetPetSkill(data *ChangeSkillInfo, c *player.Player) (result
|
||||
return nil, errorcode.ErrorCodes.ErrSystemBusy
|
||||
}
|
||||
|
||||
_, _, ok = utils.FindWithIndex(currentPet.SkillList, func(item model.SkillInfo) bool { //已经存在技能
|
||||
_, _, ok = utils.FindWithIndex(currentPet.SkillList, func(item model.SkillInfo) bool {
|
||||
return item.ID == data.ReplaceSkill
|
||||
})
|
||||
if ok {
|
||||
return nil, errorcode.ErrorCodes.ErrSystemBusy
|
||||
}
|
||||
|
||||
maxPP := uint32(skillInfo.MaxPP)
|
||||
if data.HasSkill == 0 && len(currentPet.SkillList) >= 4 {
|
||||
return nil, errorcode.ErrorCodes.ErrSystemBusy
|
||||
}
|
||||
|
||||
if data.HasSkill != 0 {
|
||||
// 查找要学习的技能并替换
|
||||
_, targetSkill, found := utils.FindWithIndex(currentPet.SkillList, func(item model.SkillInfo) bool {
|
||||
_, _, found := utils.FindWithIndex(currentPet.SkillList, func(item model.SkillInfo) bool {
|
||||
return item.ID == data.HasSkill
|
||||
})
|
||||
if !found {
|
||||
return nil, errorcode.ErrorCodes.ErrSystemBusy
|
||||
}
|
||||
}
|
||||
|
||||
if !c.GetCoins(setSkillCost) {
|
||||
return nil, errorcode.ErrorCodes.ErrSunDouInsufficient10016
|
||||
}
|
||||
|
||||
c.Info.Coins -= setSkillCost
|
||||
maxPP := uint32(skillInfo.MaxPP)
|
||||
if data.HasSkill != 0 {
|
||||
_, targetSkill, _ := utils.FindWithIndex(currentPet.SkillList, func(item model.SkillInfo) bool {
|
||||
return item.ID == data.HasSkill
|
||||
})
|
||||
targetSkill.ID = data.ReplaceSkill
|
||||
targetSkill.PP = maxPP
|
||||
} else {
|
||||
if len(currentPet.SkillList) >= 4 {
|
||||
return nil, errorcode.ErrorCodes.ErrSystemBusy
|
||||
}
|
||||
currentPet.SkillList = append(currentPet.SkillList, model.SkillInfo{
|
||||
ID: data.ReplaceSkill,
|
||||
PP: maxPP,
|
||||
@@ -130,12 +135,6 @@ func (h Controller) SetPetSkill(data *ChangeSkillInfo, c *player.Player) (result
|
||||
func (h Controller) SortPetSkills(data *C2S_Skill_Sort, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
||||
const skillSortCost = 50
|
||||
|
||||
if !c.GetCoins(skillSortCost) {
|
||||
return nil, errorcode.ErrorCodes.ErrSunDouInsufficient10016
|
||||
}
|
||||
|
||||
c.Info.Coins -= skillSortCost
|
||||
|
||||
_, currentPet, ok := c.FindPet(data.CapTm)
|
||||
if !ok {
|
||||
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
|
||||
@@ -175,6 +174,12 @@ func (h Controller) SortPetSkills(data *C2S_Skill_Sort, c *player.Player) (resul
|
||||
if len(newSkillList) > 4 {
|
||||
newSkillList = newSkillList[:4]
|
||||
}
|
||||
|
||||
if !c.GetCoins(skillSortCost) {
|
||||
return nil, errorcode.ErrorCodes.ErrSunDouInsufficient10016
|
||||
}
|
||||
|
||||
c.Info.Coins -= skillSortCost
|
||||
currentPet.SkillList = newSkillList
|
||||
|
||||
return nil, 0
|
||||
|
||||
Reference in New Issue
Block a user