Files
bl/logic/controller/fight.go
昔念 52d35119c8 feat(fight): 重构战斗模块并添加新功能
- 重构了战斗动作处理逻辑,增加了新的战斗动作类型
- 新增了逃跑、使用药剂、系统放弃等战斗动作
- 优化了战斗回合循环和动作执行顺序
- 增加了战斗结束处理逻辑
- 调整了玩家和AI的战斗行为
-增加精灵捕捉
2025-09-05 22:40:36 +08:00

82 lines
2.2 KiB
Go

package controller
import (
"blazing/common/socket/errorcode"
"blazing/logic/service"
"blazing/logic/service/fight"
"blazing/logic/service/fight/info"
"blazing/modules/blazing/model"
"github.com/jinzhu/copier"
)
func (h Controller) OnPlayerFightNpcMonster(data *fight.FightNpcMonsterInboundInfo, c *service.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
ttt := info.NoteReadyToFightInfo{
FightId: 3,
}
copier.Copy(&ttt.OurInfo, &c.Info)
len := len(c.Info.PetList)
ttt.OurPetList = make([]info.ReadyFightPetInfo, len)
for i := 0; i < len; i++ {
err := copier.CopyWithOption(&ttt.OurPetList[i], &c.Info.PetList[i], copier.Option{IgnoreEmpty: true, DeepCopy: true})
if err != nil {
panic(err)
}
}
ttt.OpponentInfo = info.FightUserInfo{UserID: 0}
refpet := c.OgreInfo.Data[data.Number]
mo := model.GenPetInfo(
int(refpet.Id), []int{0, 31},
[]int{0, 24},
[]int{0}, //野怪没特性
[]int{int(refpet.Shiny)},
[]int{int(refpet.Lv)})
ttt.OpponentPetList = make([]info.ReadyFightPetInfo, 1)
err1 := copier.CopyWithOption(&ttt.OpponentPetList[0], &mo, copier.Option{IgnoreEmpty: true, DeepCopy: true})
if err1 != nil {
panic(err)
}
if c.FightC != nil {
return nil, -1
}
c.FightC = &service.FightC{}
c.FightC.NewFight(&ttt, c) //把两个玩家都传进去
c.FightC.OwnerID = c.Info.UserID
return nil, -1
}
// 准备战斗
func (h Controller) OnReadyToFight(data *fight.ReadyToFightInboundInfo, c *service.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
c.FightC.ReadyFight(c)
return nil, -1
}
// 接收战斗或者取消战斗的包
func (h Controller) OnPlayerHandleFightInvite(data *fight.HandleFightInviteInboundInfo, c *service.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
return nil, -1
}
// 使用技能包
func (h Controller) UseSkill(data *fight.UseSkillInboundInfo, c *service.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
c.FightC.UseSkill(c, data.SkillId)
return nil, 0
}
// 战斗逃跑
func (h Controller) Escape(data *fight.EscapeFightInboundInfo, c *service.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
c.FightC.Escape(c)
return nil, 0
}