feat(fight_boss): 修复Boss挑战功能中的参数传递和效果处理逻辑 - 修复PlayerFightBoss方法中参数名错误(data -> data1) - 修正BossId获取路径,使用正确的参数引用 - 重构特效处理逻辑,从循环解析改为批量获取 - 添加宠物闪光效果初始化支持 fix(fight_塔): 修复试炼塔相关战斗逻辑错误 - 修正Boss获取逻辑,从单个对象改为数组切片访问 - 调整塔级Boss获取接口
This commit is contained in:
@@ -21,7 +21,7 @@ import (
|
||||
// data: 包含挑战Boss信息的输入数据
|
||||
// player: 当前玩家对象
|
||||
// 返回: 战斗结果和错误码
|
||||
func (Controller) PlayerFightBoss(data *fight.ChallengeBossInboundInfo, p *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
||||
func (Controller) PlayerFightBoss(data1 *fight.ChallengeBossInboundInfo, p *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
||||
r := p.CanFight()
|
||||
if p.CanFight() != 0 {
|
||||
return nil, r
|
||||
@@ -29,7 +29,7 @@ func (Controller) PlayerFightBoss(data *fight.ChallengeBossInboundInfo, p *playe
|
||||
var monster *model.PetInfo
|
||||
monsterInfo := &model.PlayerInfo{}
|
||||
|
||||
mdata := service.NewMapNodeService().GetDataNode(p.Info.MapID, data.BossId)
|
||||
mdata := service.NewMapNodeService().GetDataNode(p.Info.MapID, data1.BossId)
|
||||
if mdata == nil {
|
||||
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
|
||||
}
|
||||
@@ -56,24 +56,20 @@ func (Controller) PlayerFightBoss(data *fight.ChallengeBossInboundInfo, p *playe
|
||||
monster.MaxHp = uint32(bm.Hp)
|
||||
}
|
||||
|
||||
for _, v := range bm.Effect {
|
||||
idx := gconv.Uint16(v)
|
||||
effects := service.NewEffectService().Args(bm.Effect)
|
||||
|
||||
if idx == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
EID, args := service.NewEffectService().Args(uint32(idx))
|
||||
for _, v := range effects {
|
||||
monster.EffectInfo = append(monster.EffectInfo, model.PetEffectInfo{
|
||||
Idx: idx,
|
||||
EID: gconv.Uint16(EID),
|
||||
Args: gconv.Ints(args),
|
||||
Idx: uint16(v.SeIdx),
|
||||
EID: gconv.Uint16(v.Eid),
|
||||
Args: gconv.Ints(v.Args),
|
||||
})
|
||||
}
|
||||
|
||||
monsterInfo.PetList = append(monsterInfo.PetList, *monster)
|
||||
}
|
||||
if bosinfo[0].IsCapture == 1 {
|
||||
|
||||
monsterInfo.PetList[0].ShinyInfo = make([]data.GlowFilter, 0)
|
||||
if grand.Meet(1, 500) {
|
||||
monsterInfo.PetList[0].RandomByWeightShiny()
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ func (h Controller) FreshOpen(data *fight.C2S_OPEN_DARKPORTAL, c *player.Player)
|
||||
c.Info.CurrentStage = utils.Max(c.Info.CurrentStage, 1)
|
||||
boss := service.NewTower110Service().Boss(uint32(data.Level))
|
||||
result = &fight.S2C_OPEN_DARKPORTAL{}
|
||||
r := service.NewBossService().Get(boss.BossIds[0])
|
||||
r := service.NewBossService().Get(boss[0].BossIds[0])
|
||||
result.CurBossID = uint32(r[0].MonID)
|
||||
// for _, v := range r {
|
||||
// r := service.NewBossService().Get(boss.BossIds[0])
|
||||
@@ -67,7 +67,7 @@ func (h Controller) FreshChoiceFightLevel(data *fight.C2S_FRESH_CHOICE_FIGHT_LEV
|
||||
}
|
||||
|
||||
}
|
||||
var boss *configmodel.BaseTowerConfig
|
||||
var boss []configmodel.BaseTowerConfig
|
||||
switch data.Head.CMD {
|
||||
case 2428: //试炼之塔
|
||||
|
||||
@@ -82,7 +82,8 @@ func (h Controller) FreshChoiceFightLevel(data *fight.C2S_FRESH_CHOICE_FIGHT_LEV
|
||||
|
||||
}
|
||||
if boss != nil {
|
||||
r := service.NewBossService().Get(boss.BossIds[0])
|
||||
//单节点,取获取到的一个,然后因为不是剧情,所以只有一层
|
||||
r := service.NewBossService().Get(boss[0].BossIds[0])
|
||||
for _, v := range r {
|
||||
result.BossId = append(result.BossId, uint32(v.MonID))
|
||||
}
|
||||
@@ -113,33 +114,32 @@ func (h Controller) PetTawor(data *fight.StartTwarInboundInfo, c *player.Player)
|
||||
c.Fightinfo.Mode = fightinfo.BattleMode.MULTI_MODE
|
||||
c.Fightinfo.Status = fightinfo.BattleMode.FIGHT_WITH_NPC
|
||||
monsterInfo := &model.PlayerInfo{}
|
||||
var boss *configmodel.BaseTowerConfig
|
||||
var next *configmodel.BaseTowerConfig
|
||||
var boss []configmodel.BaseTowerConfig
|
||||
|
||||
result = &fight.S2C_ChoiceLevelRequestInfo{}
|
||||
switch data.Head.CMD {
|
||||
case 2429: //试炼之塔
|
||||
boss = service.NewTower600Service().Boss(c.Info.CurrentFreshStage)
|
||||
next = service.NewTower600Service().Boss(c.Info.CurrentFreshStage + 1)
|
||||
boss = service.NewTower600Service().Boss(c.Info.CurrentFreshStage, c.Info.CurrentFreshStage+1)
|
||||
|
||||
result.CurFightLevel = uint32(c.Info.CurrentFreshStage)
|
||||
case 2415: //勇者之塔
|
||||
boss = service.NewTower500Service().Boss(c.Info.CurrentStage)
|
||||
next = service.NewTower500Service().Boss(c.Info.CurrentStage + 1)
|
||||
boss = service.NewTower600Service().Boss(c.Info.CurrentStage, c.Info.CurrentStage+1)
|
||||
|
||||
result.CurFightLevel = uint32(c.Info.CurrentStage)
|
||||
case 2425:
|
||||
boss = service.NewTower110Service().Boss(c.CurDark)
|
||||
|
||||
}
|
||||
if next != nil {
|
||||
r := service.NewBossService().Get(boss.BossIds[0])
|
||||
if len(boss) > 1 {
|
||||
r := service.NewBossService().Get(boss[0].BossIds[0])
|
||||
for _, v := range r {
|
||||
result.BossID = append(result.BossID, uint32(v.MonID))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bosss := service.NewBossService().Get(boss.BossIds[0])
|
||||
monsterInfo.Nick = boss.Name
|
||||
bosss := service.NewBossService().Get(boss[0].BossIds[0])
|
||||
monsterInfo.Nick = boss[0].Name
|
||||
for i, r := range bosss {
|
||||
|
||||
monster := model.GenPetInfo(int(r.MonID), 24, int(r.Nature), 0, int(r.Lv), nil, 0)
|
||||
@@ -166,18 +166,14 @@ func (h Controller) PetTawor(data *fight.StartTwarInboundInfo, c *player.Player)
|
||||
|
||||
}
|
||||
|
||||
if len(r.Effect) != 0 {
|
||||
|
||||
for _, v := range r.Effect {
|
||||
|
||||
EID, args := service.NewEffectService().Args(v)
|
||||
monster.EffectInfo = append(monster.EffectInfo, model.PetEffectInfo{
|
||||
Idx: uint16(v),
|
||||
EID: gconv.Uint16(EID),
|
||||
Args: gconv.Ints(args),
|
||||
})
|
||||
}
|
||||
effects := service.NewEffectService().Args(r.Effect)
|
||||
|
||||
for _, v := range effects {
|
||||
monster.EffectInfo = append(monster.EffectInfo, model.PetEffectInfo{
|
||||
Idx: uint16(v.SeIdx),
|
||||
EID: gconv.Uint16(v.Eid),
|
||||
Args: gconv.Ints(v.Args),
|
||||
})
|
||||
}
|
||||
monster.CatchTime = uint32(i)
|
||||
monsterInfo.PetList = append(monsterInfo.PetList, *monster)
|
||||
|
||||
@@ -77,9 +77,9 @@ func (h Controller) GetMapPlayerList(data *space.ListMapPlayerInboundInfo, c *pl
|
||||
}
|
||||
func (h Controller) AttackBoss(data *space.AttackBossInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) { //这个时候player应该是空的
|
||||
|
||||
for _, v := range c.GetSpace().MapBossSInfo.INFO {
|
||||
if atomic.LoadInt32(&v.Hp) > 0 {
|
||||
atomic.AddInt32(&v.Hp, -1)
|
||||
for i := 0; i < len(c.GetSpace().MapBossSInfo.INFO); i++ {
|
||||
if atomic.LoadInt32(&c.GetSpace().MapBossSInfo.INFO[i].Hp) > 0 {
|
||||
atomic.AddInt32(&c.GetSpace().MapBossSInfo.INFO[i].Hp, -1)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@ type Event struct {
|
||||
EndTime string `gorm:"type:varchar(100);default:'';comment:'触发结束时间'" json:"end_time"`
|
||||
//触发天气Event
|
||||
Weather []int32 `gorm:"type:int[];comment:'触发天气'" json:"weather"`
|
||||
//触发的星期Event
|
||||
Week []int32 `gorm:"type:int[];comment:'触发的星期'" json:"week"`
|
||||
}
|
||||
|
||||
// MapPit 地图坑位核心配置模型(参照MonsterRefresh实现风格)
|
||||
|
||||
@@ -9,12 +9,12 @@ type EffectService struct {
|
||||
*cool.Service
|
||||
}
|
||||
|
||||
func (s *EffectService) Args(id uint32) (int, []int) {
|
||||
m := dbm_notenable(s.Model).Where("se_idx", id)
|
||||
var tt model.PlayerPetSpecialEffect
|
||||
func (s *EffectService) Args(id []uint32) []model.PlayerPetSpecialEffect {
|
||||
m := dbm_notenable(s.Model).WhereIn("se_idx", id)
|
||||
var tt []model.PlayerPetSpecialEffect
|
||||
m.Scan(&tt)
|
||||
|
||||
return int(tt.Eid), tt.Args
|
||||
return tt
|
||||
|
||||
}
|
||||
func NewEffectService() *EffectService {
|
||||
|
||||
@@ -66,17 +66,17 @@ func (m *UnifiedTowerModel) GroupName() string {
|
||||
}
|
||||
|
||||
// Boss 根据塔等级获取对应的Boss配置(统一入口)
|
||||
func (s *TowerService) Boss(towerLevel uint32) *model.BaseTowerConfig {
|
||||
func (s *TowerService) Boss(towerLevel ...uint32) []model.BaseTowerConfig {
|
||||
// 构建基础查询条件
|
||||
query := dbm_enable(s.Model).Where("tower_level = ?", towerLevel)
|
||||
query := dbm_enable(s.Model).WhereIn("tower_level", towerLevel)
|
||||
|
||||
// 600塔专属的缓存配置
|
||||
var config model.BaseTowerConfig
|
||||
var config []model.BaseTowerConfig
|
||||
query.Cache(gdb.CacheOption{
|
||||
// Duration: time.Hour, // 可根据需要开启缓存时长
|
||||
Force: false,
|
||||
}).Scan(&config)
|
||||
return &config
|
||||
return config
|
||||
}
|
||||
|
||||
// 兼容原有调用方式的快捷构造函数(可选,保证代码平滑迁移)
|
||||
|
||||
Reference in New Issue
Block a user