Files
bl/logic/controller/fight.go
昔念 1405bf5ee9 refactor(fight): 重构战斗模块
- 移除 BattleStateMachine 和 BattleUnit 相关代码
- 新增 BattleContainer 和 DamageContext 结构体
- 重构伤害计算逻辑,使用高精度 decimal 进行计算
- 更新随机数生成器,支持基于用户和时间的种子生成
- 优化战斗信息结构,增加 OwnerID 字段
2025-08-25 12:58:08 +08:00

71 lines
1.8 KiB
Go

package controller
import (
"blazing/common/data/entity"
"blazing/common/socket/errorcode"
"blazing/common/socket/handler"
"blazing/logic/service/fight"
"blazing/logic/service/fight/info"
"blazing/modules/blazing/model"
)
func (h Controller) OnPlayerFightNpcMonster(data *fight.FightNpcMonsterInboundInfo, c *entity.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
c.IsFighting = true
t1 := handler.NewTomeeHeader(2503, c.UserID)
ttt := info.NoteReadyToFightInfo{
OwnerID: data.Head.UserID,
FightId: 3,
}
ttt.OurInfo = info.FightUserInfo{UserID: c.UserID}
ttt.OurPetList = []info.ReadyFightPetInfo{{ID: 300,
Level: 100,
MaxHp: 100,
Hp: 100,
SkillListLen: 4,
}}
for i := 0; i < 4; i++ {
ttt.OurPetList[0].SkillList[i] = model.SkillInfo{ID: 10001, Pp: 1}
}
ttt.OpponentInfo = info.FightUserInfo{UserID: 0}
ttt.OpponentPetList = []info.ReadyFightPetInfo{{ID: 1,
Level: 100,
MaxHp: 100,
SkillListLen: 4,
Hp: 100}}
for i := 0; i < 4; i++ {
ttt.OpponentPetList[0].SkillList[i] = model.SkillInfo{ID: 10001, Pp: 1}
}
c.SendPack(t1.Pack(&ttt))
return nil, -1
}
func (h Controller) OnReadyToFight(data *fight.ReadyToFightInboundInfo, c *entity.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
t1 := handler.NewTomeeHeader(2504, c.UserID)
rett := fight.FightStartOutboundInfo{
IsCanAuto: 0,
Info1: fight.FightPetInfo{PetID: 300,
UserID: c.UserID,
Hp: 1000,
MaxHp: 1000,
Level: 1,
CatchTime: 0,
Catchable: 1,
BattleLV: [6]byte{1, 1, 1, 1, 1, 1},
},
Info2: fight.FightPetInfo{
UserID: 0,
PetID: 1,
Hp: 1000,
MaxHp: 1000,
Level: 1,
CatchTime: 0,
Catchable: 1,
BattleLV: [6]byte{1, 1, 1, 1, 1, 1}},
}
c.SendPack(t1.Pack(&rett))
return nil, -1
}