refactor(common/data/xmlres): 注释掉未使用的MonsterMap配置变量 - 将MonsterMap配置变量注释掉,因为当前不再使用该配置 - 相应地注释掉了初始化代码中的MonsterMap赋值逻辑 feat(logic/controller): 统一CanFight方法返回值为ErrorCode - 修改PlayerFightBoss等战斗控制器中的Can
This commit is contained in:
@@ -10,7 +10,6 @@ import (
|
||||
"blazing/logic/service/fight/info"
|
||||
|
||||
"blazing/logic/service/player"
|
||||
"blazing/modules/config/service"
|
||||
"blazing/modules/player/model"
|
||||
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
@@ -51,112 +50,114 @@ func processMonID(bm string) string {
|
||||
// data: 包含挑战Boss信息的输入数据
|
||||
// player: 当前玩家对象
|
||||
// 返回: 战斗结果和错误码
|
||||
func (Controller) PlayerFightBoss(data *fight.ChallengeBossInboundInfo, p *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
||||
if !p.CanFight() {
|
||||
return nil, errorcode.ErrorCodes.ErrPokemonNoStamina
|
||||
}
|
||||
var monster *model.PetInfo
|
||||
monsterInfo := &model.PlayerInfo{}
|
||||
// func (Controller) PlayerFightBoss(data *fight.ChallengeBossInboundInfo, p *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
||||
// r := p.CanFight()
|
||||
// if p.CanFight() != 0 {
|
||||
// return nil, r
|
||||
// }
|
||||
// var monster *model.PetInfo
|
||||
// monsterInfo := &model.PlayerInfo{}
|
||||
|
||||
var taskID int
|
||||
var canCapture int
|
||||
mdata, ok := xmlres.MonsterMap[int(p.Info.MapID)]
|
||||
if !ok {
|
||||
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
|
||||
}
|
||||
if len(mdata.Bosses) == 0 {
|
||||
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
|
||||
}
|
||||
for _, bc := range mdata.Bosses {
|
||||
// var taskID int
|
||||
// var canCapture int
|
||||
// mdata, ok := xmlres.MonsterMap[int(p.Info.MapID)]
|
||||
// if !ok {
|
||||
// return nil, errorcode.ErrorCodes.ErrPokemonNotExists
|
||||
// }
|
||||
// if len(mdata.Bosses) == 0 {
|
||||
// return nil, errorcode.ErrorCodes.ErrPokemonNotExists
|
||||
// }
|
||||
// for _, bc := range mdata.Bosses {
|
||||
|
||||
if bc.Id == nil {
|
||||
// if bc.Id == nil {
|
||||
|
||||
bc.Id = gconv.PtrInt(0)
|
||||
}
|
||||
// bc.Id = gconv.PtrInt(0)
|
||||
// }
|
||||
|
||||
if (bc.Id == nil && data.BossId == 0) || uint32(*bc.Id) == data.BossId { //打默认第一个boss
|
||||
if bc.TaskID != nil {
|
||||
taskID = *bc.TaskID
|
||||
}
|
||||
// if (bc.Id == nil && data.BossId == 0) || uint32(*bc.Id) == data.BossId { //打默认第一个boss
|
||||
// if bc.TaskID != nil {
|
||||
// taskID = *bc.TaskID
|
||||
// }
|
||||
|
||||
for i, bm := range bc.BossMon {
|
||||
// for i, bm := range bc.BossMon {
|
||||
|
||||
dv := 24
|
||||
if bc.BossCatchable == 1 {
|
||||
dv = -1
|
||||
}
|
||||
// dv := 24
|
||||
// if bc.BossCatchable == 1 {
|
||||
// dv = -1
|
||||
// }
|
||||
|
||||
monster = model.GenPetInfo(
|
||||
gconv.Int(processMonID(bm.MonID)), dv, //24个体
|
||||
-1,
|
||||
0, //野怪没特性
|
||||
// monster = model.GenPetInfo(
|
||||
// gconv.Int(processMonID(bm.MonID)), dv, //24个体
|
||||
// -1,
|
||||
// 0, //野怪没特性
|
||||
|
||||
bm.Lv, nil, 0)
|
||||
monster.CatchTime = uint32(i)
|
||||
if bm.Hp != 0 {
|
||||
monster.Hp = uint32(bm.Hp)
|
||||
monster.MaxHp = uint32(bm.Hp)
|
||||
}
|
||||
// bm.Lv, nil, 0)
|
||||
// monster.CatchTime = uint32(i)
|
||||
// if bm.Hp != 0 {
|
||||
// monster.Hp = uint32(bm.Hp)
|
||||
// monster.MaxHp = uint32(bm.Hp)
|
||||
// }
|
||||
|
||||
for _, v := range strings.Split(bm.NewSeIdxs, " ") {
|
||||
idx := gconv.Uint16(v)
|
||||
// for _, v := range strings.Split(bm.NewSeIdxs, " ") {
|
||||
// idx := gconv.Uint16(v)
|
||||
|
||||
if idx == 0 {
|
||||
continue
|
||||
}
|
||||
// if idx == 0 {
|
||||
// continue
|
||||
// }
|
||||
|
||||
EID, args := service.NewEffectService().Args(uint32(idx))
|
||||
monster.EffectInfo = append(monster.EffectInfo, model.PetEffectInfo{
|
||||
Idx: idx,
|
||||
EID: gconv.Uint16(EID),
|
||||
Args: gconv.Ints(args),
|
||||
})
|
||||
}
|
||||
monsterInfo.PetList = append(monsterInfo.PetList, *monster)
|
||||
}
|
||||
if bc.BossCatchable == 1 {
|
||||
canCapture = xmlres.PetMAP[int(monster.ID)].CatchRate
|
||||
if grand.Meet(1, 500) {
|
||||
monsterInfo.PetList[0].RandomByWeightShiny()
|
||||
}
|
||||
// EID, args := service.NewEffectService().Args(uint32(idx))
|
||||
// monster.EffectInfo = append(monster.EffectInfo, model.PetEffectInfo{
|
||||
// Idx: idx,
|
||||
// EID: gconv.Uint16(EID),
|
||||
// Args: gconv.Ints(args),
|
||||
// })
|
||||
// }
|
||||
// monsterInfo.PetList = append(monsterInfo.PetList, *monster)
|
||||
// }
|
||||
// if bc.BossCatchable == 1 {
|
||||
// canCapture = xmlres.PetMAP[int(monster.ID)].CatchRate
|
||||
// if grand.Meet(1, 500) {
|
||||
// monsterInfo.PetList[0].RandomByWeightShiny()
|
||||
// }
|
||||
|
||||
}
|
||||
monsterInfo.Nick = bc.Name //xmlres.PetMAP[int(monster.ID)].DefName
|
||||
break
|
||||
}
|
||||
// }
|
||||
// monsterInfo.Nick = bc.Name //xmlres.PetMAP[int(monster.ID)].DefName
|
||||
// break
|
||||
// }
|
||||
|
||||
}
|
||||
if len(monsterInfo.PetList) == 0 {
|
||||
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
|
||||
}
|
||||
p.Fightinfo.Status = info.BattleMode.FIGHT_WITH_NPC
|
||||
p.Fightinfo.Mode = info.BattleMode.MULTI_MODE
|
||||
// }
|
||||
// if len(monsterInfo.PetList) == 0 {
|
||||
// return nil, errorcode.ErrorCodes.ErrPokemonNotExists
|
||||
// }
|
||||
// p.Fightinfo.Status = info.BattleMode.FIGHT_WITH_NPC
|
||||
// p.Fightinfo.Mode = info.BattleMode.MULTI_MODE
|
||||
|
||||
ai := player.NewAI_player(monsterInfo)
|
||||
ai.CanCapture = canCapture
|
||||
ai.Prop[0] = 2
|
||||
fight.NewFight(p, ai, func(foi info.FightOverInfo) {
|
||||
if taskID != 0 {
|
||||
if foi.Reason == 0 && foi.WinnerId == p.Info.UserID {
|
||||
p.SptCompletedTask(taskID, 1)
|
||||
// ai := player.NewAI_player(monsterInfo)
|
||||
// ai.CanCapture = canCapture
|
||||
// ai.Prop[0] = 2
|
||||
// fight.NewFight(p, ai, func(foi info.FightOverInfo) {
|
||||
// if taskID != 0 {
|
||||
// if foi.Reason == 0 && foi.WinnerId == p.Info.UserID {
|
||||
// p.SptCompletedTask(taskID, 1)
|
||||
|
||||
}
|
||||
}
|
||||
// }
|
||||
// }
|
||||
|
||||
//p.Done.Exec(model.MilestoneMode.BOSS, []uint32{p.Info.MapID, data.BossId, uint32(foi.Reason)}, nil)
|
||||
// //p.Done.Exec(model.MilestoneMode.BOSS, []uint32{p.Info.MapID, data.BossId, uint32(foi.Reason)}, nil)
|
||||
|
||||
})
|
||||
// })
|
||||
|
||||
return nil, -1
|
||||
}
|
||||
// return nil, -1
|
||||
// }
|
||||
|
||||
// OnPlayerFightNpcMonster 战斗野怪
|
||||
// data: 包含战斗野怪信息的输入数据
|
||||
// player: 当前玩家对象
|
||||
// 返回: 战斗结果和错误码
|
||||
func (Controller) OnPlayerFightNpcMonster(data1 *fight.FightNpcMonsterInboundInfo, p *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
||||
if !p.CanFight() {
|
||||
return nil, errorcode.ErrorCodes.ErrSystemError
|
||||
r := p.CanFight()
|
||||
if p.CanFight() != 0 {
|
||||
return nil, r
|
||||
}
|
||||
if data1.Number > 9 {
|
||||
return nil, errorcode.ErrorCodes.ErrSystemError
|
||||
@@ -188,7 +189,8 @@ func (Controller) OnPlayerFightNpcMonster(data1 *fight.FightNpcMonsterInboundInf
|
||||
monsterInfo.Nick = xmlres.PetMAP[int(monster.ID)].DefName
|
||||
monsterInfo.PetList = append(monsterInfo.PetList, *monster)
|
||||
ai := player.NewAI_player(monsterInfo)
|
||||
ai.CanCapture = handleNPCFightSpecial(monster.ID)
|
||||
|
||||
ai.CanCapture = refPet.IsCapture //handleNPCFightSpecial(monster.ID)
|
||||
|
||||
p.Fightinfo.Status = info.BattleMode.FIGHT_WITH_NPC //打野怪
|
||||
p.Fightinfo.Mode = info.BattleMode.MULTI_MODE //多人模式
|
||||
@@ -240,17 +242,3 @@ func (Controller) OnPlayerFightNpcMonster(data1 *fight.FightNpcMonsterInboundInf
|
||||
|
||||
return nil, -1
|
||||
}
|
||||
|
||||
// handleNPCFightSpecial 处理NPC战斗特殊情况
|
||||
func handleNPCFightSpecial(petID uint32) int {
|
||||
|
||||
npcPetID := int(petID)
|
||||
petCfg, ok := xmlres.PetMAP[npcPetID]
|
||||
if !ok {
|
||||
// log.Error(context.Background(), "NPC宠物配置不存在", "petID", npcPetID)
|
||||
return 0
|
||||
}
|
||||
|
||||
catchRate := gconv.Int(petCfg.CatchRate)
|
||||
return catchRate
|
||||
}
|
||||
|
||||
@@ -23,8 +23,9 @@ func (h Controller) OnPlayerHandleFightInvite(data *fight.HandleFightInviteInbou
|
||||
|
||||
}
|
||||
|
||||
if !c.CanFight() {
|
||||
return nil, errorcode.ErrorCodes.ErrSystemError
|
||||
r := c.CanFight()
|
||||
if c.CanFight() != 0 {
|
||||
return nil, r
|
||||
}
|
||||
|
||||
//c.Fightinfo.Status = info.BattleMode.FIGHT_WITH_NPC
|
||||
|
||||
@@ -25,11 +25,13 @@ 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{}
|
||||
for _, v := range boss.BossIds {
|
||||
r := service.NewBossService().Get(v)
|
||||
result.CurBossID = uint32(r.MonID)
|
||||
r := service.NewBossService().Get(boss.BossIds[0])
|
||||
result.CurBossID = uint32(r[0].MonID)
|
||||
// for _, v := range r {
|
||||
// r := service.NewBossService().Get(boss.BossIds[0])
|
||||
// result.CurBossID = uint32(r.MonID)
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
c.CurDark = uint32(data.Level)
|
||||
defer c.GetSpace().LeaveMap(c)
|
||||
@@ -80,13 +82,9 @@ func (h Controller) FreshChoiceFightLevel(data *fight.C2S_FRESH_CHOICE_FIGHT_LEV
|
||||
|
||||
}
|
||||
if boss != nil {
|
||||
|
||||
for _, v := range boss.BossIds {
|
||||
r := service.NewBossService().Get(v)
|
||||
if r != nil {
|
||||
result.BossId = append(result.BossId, uint32(r.MonID))
|
||||
}
|
||||
|
||||
r := service.NewBossService().Get(boss.BossIds[0])
|
||||
for _, v := range r {
|
||||
result.BossId = append(result.BossId, uint32(v.MonID))
|
||||
}
|
||||
|
||||
}
|
||||
@@ -108,8 +106,9 @@ func (h Controller) FreshLeaveFightLevel(data *fight.FRESH_LEAVE_FIGHT_LEVEL, c
|
||||
}
|
||||
|
||||
func (h Controller) PetTawor(data *fight.StartTwarInboundInfo, c *player.Player) (result *fight.S2C_ChoiceLevelRequestInfo, err errorcode.ErrorCode) {
|
||||
if !c.CanFight() {
|
||||
return nil, errorcode.ErrorCodes.ErrSystemError
|
||||
r := c.CanFight()
|
||||
if c.CanFight() != 0 {
|
||||
return nil, r
|
||||
}
|
||||
c.Fightinfo.Mode = fightinfo.BattleMode.MULTI_MODE
|
||||
c.Fightinfo.Status = fightinfo.BattleMode.FIGHT_WITH_NPC
|
||||
@@ -132,57 +131,57 @@ func (h Controller) PetTawor(data *fight.StartTwarInboundInfo, c *player.Player)
|
||||
boss = service.NewTower110Service().Boss(c.CurDark)
|
||||
}
|
||||
if next != nil {
|
||||
for _, v := range next.BossIds {
|
||||
r := service.NewBossService().Get(v)
|
||||
result.BossID = append(result.BossID, uint32(r.MonID))
|
||||
|
||||
r := service.NewBossService().Get(boss.BossIds[0])
|
||||
for _, v := range r {
|
||||
result.BossID = append(result.BossID, uint32(v.MonID))
|
||||
}
|
||||
|
||||
}
|
||||
for i, v := range boss.BossIds {
|
||||
r := service.NewBossService().Get(v)
|
||||
if r != nil {
|
||||
|
||||
monster := model.GenPetInfo(int(r.MonID), 24, int(r.Nature), 0, int(r.Lv), nil, 0)
|
||||
if r.Hp != 0 {
|
||||
monster.Hp = uint32(r.Hp)
|
||||
monster.MaxHp = uint32(r.Hp)
|
||||
bosss := service.NewBossService().Get(boss.BossIds[0])
|
||||
monsterInfo.Nick = boss.Name
|
||||
for i, r := range bosss {
|
||||
|
||||
}
|
||||
monster := model.GenPetInfo(int(r.MonID), 24, int(r.Nature), 0, int(r.Lv), nil, 0)
|
||||
if r.Hp != 0 {
|
||||
monster.Hp = uint32(r.Hp)
|
||||
monster.MaxHp = uint32(r.Hp)
|
||||
|
||||
for i, v := range r.Prop {
|
||||
if v != 0 {
|
||||
monster.Prop[i] = v
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if len(r.SKill) != 0 {
|
||||
for i := 0; i < len(monster.SkillList); i++ {
|
||||
if r.SKill[i] != 0 {
|
||||
monster.SkillList[i].ID = r.SKill[i]
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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),
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
monster.CatchTime = uint32(i)
|
||||
monsterInfo.PetList = append(monsterInfo.PetList, *monster)
|
||||
}
|
||||
|
||||
for i, v := range r.Prop {
|
||||
if v != 0 {
|
||||
monster.Prop[i] = v
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if len(r.SKill) != 0 {
|
||||
for i := 0; i < len(monster.SkillList); i++ {
|
||||
if r.SKill[i] != 0 {
|
||||
monster.SkillList[i].ID = r.SKill[i]
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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),
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
monster.CatchTime = uint32(i)
|
||||
monsterInfo.PetList = append(monsterInfo.PetList, *monster)
|
||||
|
||||
}
|
||||
|
||||
ai := player.NewAI_player(monsterInfo)
|
||||
|
||||
@@ -18,9 +18,9 @@ import (
|
||||
// 后端到前端无数据内容 空包
|
||||
// ArenaSetOwner 都需要通过2419包广播更新擂台状态
|
||||
func (h Controller) ArenaSetOwner(data *fight.ARENA_SET_OWENR, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
||||
|
||||
if !c.CanFight() {
|
||||
return nil, errorcode.ErrorCodes.ErrPokemonNotEligible
|
||||
r := c.CanFight()
|
||||
if r != 0 {
|
||||
return nil, r
|
||||
}
|
||||
c.Fightinfo.Mode = 0 //取消队列匹配
|
||||
if atomic.CompareAndSwapUint32(&c.GetSpace().Owner.Flag, 0, 1) {
|
||||
@@ -41,8 +41,9 @@ func (h Controller) ArenaSetOwner(data *fight.ARENA_SET_OWENR, c *player.Player)
|
||||
// ArenaFightOwner 并不会通知对方是否接受挑战。只要有人挑战就直接进入对战
|
||||
func (h Controller) ArenaFightOwner(data1 *fight.ARENA_FIGHT_OWENR, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
||||
|
||||
if !c.CanFight() {
|
||||
return nil, errorcode.ErrorCodes.ErrNoEligiblePokemon
|
||||
r := c.CanFight()
|
||||
if r != 0 {
|
||||
return nil, r
|
||||
}
|
||||
|
||||
if c.Info.UserID == c.GetSpace().Owner.UserID {
|
||||
@@ -53,7 +54,7 @@ func (h Controller) ArenaFightOwner(data1 *fight.ARENA_FIGHT_OWENR, c *player.Pl
|
||||
return nil, errorcode.ErrorCodes.ErrSystemError200007
|
||||
}
|
||||
|
||||
if !c.GetSpace().Owner.ARENA_Player.CanFight() {
|
||||
if c.GetSpace().Owner.ARENA_Player.CanFight() != 0 {
|
||||
c.GetSpace().Owner.Set(c)
|
||||
c.GetSpace().Broadcast(c, 2419, &c.GetSpace().Owner)
|
||||
c.SendPackCmd(2419, &c.GetSpace().Owner)
|
||||
|
||||
Reference in New Issue
Block a user