feat: 添加地图节点匹配和战斗等级上限
This commit is contained in:
@@ -27,7 +27,10 @@ func (Controller) PlayerFightBoss(req *ChallengeBossInboundInfo, p *player.Playe
|
||||
return nil, err
|
||||
}
|
||||
|
||||
mapNode := service.NewMapNodeService().GetDataNode(p.Info.MapID, req.BossId)
|
||||
mapNode := p.GetSpace().GetMatchedMapNode(req.BossId)
|
||||
if mapNode == nil {
|
||||
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
|
||||
}
|
||||
bossConfigs, err := loadMapBossConfigs(mapNode)
|
||||
if err != 0 {
|
||||
return nil, err
|
||||
|
||||
@@ -55,7 +55,7 @@ func (h Controller) OnPlayerHandleFightInvite(data *HandleFightInviteInboundInfo
|
||||
return
|
||||
}
|
||||
|
||||
_, err = fight.NewFight(v, c, v.GetInfo().PetList, c.GetInfo().PetList, func(foi model.FightOverInfo) {
|
||||
_, err = fight.NewFight(v, c, v.GetPetInfo(100), c.GetPetInfo(100), func(foi model.FightOverInfo) {
|
||||
|
||||
//println("好友对战测试", foi.Reason)
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ const (
|
||||
queueTTL = 12 * time.Second
|
||||
banPickTimeout = 45 * time.Second
|
||||
banPickStartCmd = 2461
|
||||
battleLevelCap = 100
|
||||
)
|
||||
|
||||
type localQueueTicket struct {
|
||||
@@ -665,7 +666,11 @@ func resolveBattlePets(catchTimes []uint32, limit int) []model.PetInfo {
|
||||
if pet == nil || pet.Data.ID == 0 {
|
||||
continue
|
||||
}
|
||||
result = append(result, pet.Data)
|
||||
petInfo := pet.Data
|
||||
if petInfo.Level > battleLevelCap {
|
||||
petInfo.Level = battleLevelCap
|
||||
}
|
||||
result = append(result, petInfo)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ type Space struct {
|
||||
IsTime bool
|
||||
DropItemIds []uint32
|
||||
PitS *csmap.CsMap[int, []model.MapPit]
|
||||
MapNodeS *csmap.CsMap[uint32, *model.MapNode]
|
||||
}
|
||||
|
||||
func NewSpace() *Space {
|
||||
@@ -52,6 +53,7 @@ func NewSpace() *Space {
|
||||
ret := &Space{
|
||||
User: csmap.New[uint32, common.PlayerI](),
|
||||
UserInfo: csmap.New[uint32, info.SimpleInfo](),
|
||||
MapNodeS: csmap.New[uint32, *model.MapNode](),
|
||||
}
|
||||
|
||||
return ret
|
||||
@@ -185,12 +187,20 @@ func (ret *Space) init() {
|
||||
}
|
||||
ret.MapBossSInfo = info.MapModelBroadcastInfo{}
|
||||
ret.MapBossSInfo.INFO = make([]info.MapModelBroadcastEntry, 0)
|
||||
|
||||
mapNodes := service.NewMapNodeService().GetData(ret.ID)
|
||||
for i := range mapNodes {
|
||||
ret.MapNodeS.Store(mapNodes[i].NodeID, &mapNodes[i])
|
||||
}
|
||||
if len(r.WeatherType) > 1 {
|
||||
ret.WeatherType = r.WeatherType
|
||||
|
||||
cool.Cron.CustomFunc(ret, ret.GenWer)
|
||||
}
|
||||
for _, v := range service.NewMapNodeService().GetDataB(ret.ID) {
|
||||
for _, v := range mapNodes {
|
||||
if v.IsBroadcast == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
r := service.NewMapmodelService().GetDataByModelId(v.IsBroadcast)
|
||||
if r == nil {
|
||||
@@ -220,6 +230,19 @@ func (ret *Space) init() {
|
||||
}
|
||||
|
||||
}
|
||||
func (p *Space) GetMatchedMapNode(nodeID uint32) *model.MapNode {
|
||||
if p == nil || p.MapNodeS == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
mapNode, ok := p.MapNodeS.Load(nodeID)
|
||||
if !ok || mapNode == nil || mapNode.Event == nil || !p.IsMatch(*mapNode.Event) {
|
||||
return nil
|
||||
}
|
||||
|
||||
return mapNode
|
||||
}
|
||||
|
||||
func (p *Space) IsMatch(t model.Event) bool {
|
||||
if len(t.Weather) > 0 {
|
||||
_, ok := lo.Find(t.Weather, func(item int32) bool {
|
||||
|
||||
Reference in New Issue
Block a user