feat(fight): 添加 BOSS 战斗逻辑与地图交互功能

- 在 fight_boss.go 中增加对 BOSS 血量是否为 0 的判断,避免无效赋值
- 在 map.go 中移除旧的测试代码,并将 Canmon 状态设置移至 MapList 方法中
- 新增 Attack_Boss 接口方法用于处理玩家攻击 BOSS 请求
- 修改 MapBossInfo 结构体字段类型
This commit is contained in:
2025-12-09 14:52:55 +08:00
parent 2633402b52
commit f6a305de77
9 changed files with 214 additions and 28 deletions

View File

@@ -84,8 +84,10 @@ func (h Controller) PlayerFightBoss(data *fight.ChallengeBossInboundInfo, c *pla
0,
bm.Lv)
mo.CatchTime = uint32(i)
mo.Hp = uint32(bm.Hp)
mo.MaxHp = uint32(bm.Hp)
if bm.Hp != 0 {
mo.Hp = uint32(bm.Hp)
mo.MaxHp = uint32(bm.Hp)
}
for _, v := range strings.Split(bm.NewSeIdxs, " ") {
idx := gconv.Uint16(v)

View File

@@ -4,6 +4,7 @@ import (
"blazing/common/socket/errorcode"
"sync/atomic"
"blazing/logic/service/fight"
"blazing/logic/service/maphot"
"blazing/logic/service/maps"
"blazing/logic/service/maps/info"
@@ -21,27 +22,9 @@ func (h *Controller) MapEnter(data *maps.InInfo, c *player.Player) (result *info
result = info.NewOutInfo()
c.Info.Pos = data.Point
copier.Copy(result, c.Info)
atomic.StoreUint32(&c.Canmon, 2)
defer c.GetSpace().EnterMap(c)
// go func() {
// for {
// <-time.After(time.Second * 5)
// var t info.MapBossSInfo
// t.INFO = make([]info.MapBossInfo, 0)
// t.INFO = append(t.INFO, info.MapBossInfo{
// Id: 47,
// Hp: 1,
// Pos: 1,
// })
// c.SendPackCmd(2021, &t)
// }
// }()
return result, 0
}
func (h Controller) MapHot(data *maphot.InInfo, c *player.Player) (result *maphot.OutInfo, err errorcode.ErrorCode) {
@@ -68,10 +51,18 @@ func (h *Controller) MapLeave(data *maps.LeaveMapInboundInfo, c *player.Player)
return
}
func (h *Controller) MapList(data *maps.ListMapPlayerInboundInfo, c *player.Player) (result *info.ListMapPlayerOutboundInfo, err errorcode.ErrorCode) { //这个时候player应该是空的
atomic.StoreUint32(&c.Canmon, 2)
result = &info.ListMapPlayerOutboundInfo{
Player: c.GetSpace().GetInfo(),
}
return
}
func (h *Controller) Attack_Boss(data *maps.AttackBossInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) { //这个时候player应该是空的
if atomic.LoadInt32(&c.GetSpace().MapBossInfo.Hp) > 0 {
atomic.AddInt32(&c.GetSpace().MapBossInfo.Hp, -1)
}
return
}