feat(utils): 重构 OrderedMap 为 OrderMap,支持排序和非阻塞遍历
- 将原有的 `OrderedMap` 替换为 `OrderMap`,基于 `map` 和 `slice` 实现,提升性能并简化逻辑 - 支持自定义 key 排序规则,若未提供则按插入顺序维护 - 提供 `Set`、`Get`、`Delete`、`Keys`、`Values` 等基本操作,均并发安全 - 引入非阻塞遍历机制(`Iter`、`Iter
This commit is contained in:
@@ -8,12 +8,20 @@ import (
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/logic/service/player"
|
||||
"blazing/modules/blazing/model"
|
||||
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
)
|
||||
|
||||
// 挑战地图boss
|
||||
func (h Controller) PlayerFightBoss(data *fight.ChallengeBossInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
||||
if c.FightC != nil {
|
||||
return nil, errorcode.ErrorCodes.ErrOnlineOver6HoursCannotFight
|
||||
}
|
||||
|
||||
var petid int
|
||||
var mo *model.PetInfo
|
||||
moinfo := &model.PlayerInfo{}
|
||||
|
||||
if c.Info.MapID == 515 && data.BossId == 0 { //说明是新手,随机生成
|
||||
switch c.Info.PetList[0].ID {
|
||||
|
||||
@@ -33,14 +41,42 @@ func (h Controller) PlayerFightBoss(data *fight.ChallengeBossInboundInfo, c *pla
|
||||
0, //野怪没特性
|
||||
0,
|
||||
2)
|
||||
moinfo.Nick = xmlres.PetMAP[int(mo.ID)].DefName
|
||||
moinfo.PetList = append(moinfo.PetList, *mo)
|
||||
} else {
|
||||
|
||||
mdata, ok := xmlres.MonsterMap[int(c.Info.MapID)]
|
||||
if !ok {
|
||||
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
|
||||
}
|
||||
for _, bc := range mdata.Bosses {
|
||||
if bc.Id == nil {
|
||||
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
|
||||
|
||||
}
|
||||
if uint32(*bc.Id) == data.BossId {
|
||||
for _, bm := range bc.BossMon {
|
||||
mo = c.GenPetInfo(
|
||||
gconv.Int(bm.MonID), 24, //24个体
|
||||
-1,
|
||||
0, //野怪没特性
|
||||
0,
|
||||
2)
|
||||
|
||||
mo.Level = uint32(bm.Lv)
|
||||
mo.CalculatePetPane()
|
||||
mo.Hp = uint32(bm.Hp)
|
||||
mo.MaxHp = uint32(bm.Hp)
|
||||
moinfo.PetList = append(moinfo.PetList, *mo)
|
||||
|
||||
}
|
||||
moinfo.Nick = xmlres.PetMAP[int(mo.ID)].DefName
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if c.FightC != nil {
|
||||
return nil, errorcode.ErrorCodes.ErrOnlineOver6HoursCannotFight
|
||||
}
|
||||
moinfo := &model.PlayerInfo{}
|
||||
moinfo.Nick = xmlres.PetMAP[int(mo.ID)].DefName
|
||||
moinfo.PetList = append(moinfo.PetList, *mo)
|
||||
ai := player.NewAI_player(moinfo)
|
||||
fight.NewFight(info.BattleMode.MULTI_MODE, info.BattleStatus.FIGHT_WITH_BOSS, c, ai)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user