This commit is contained in:
@@ -121,7 +121,23 @@ func (s *Server) OnTraffic(c gnet.Conn) (action gnet.Action) {
|
||||
}
|
||||
}()
|
||||
|
||||
ws := c.Context().(*player.ClientData).Wsmsg
|
||||
client := c.Context().(*player.ClientData)
|
||||
if s.discorse && !client.IsCrossDomainChecked() {
|
||||
handled, ready, action := handle(c)
|
||||
if action != gnet.None {
|
||||
return action
|
||||
}
|
||||
if handled {
|
||||
client.MarkCrossDomainChecked()
|
||||
return gnet.None
|
||||
}
|
||||
if !ready {
|
||||
return gnet.None
|
||||
}
|
||||
client.MarkCrossDomainChecked()
|
||||
}
|
||||
|
||||
ws := client.Wsmsg
|
||||
if ws.Tcp {
|
||||
return s.handleTCP(c)
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@ func (h Controller) GET_XUANCAI(data *C2s_GET_XUANCAI, c *player.Player) (result
|
||||
|
||||
// 检查该位是否未被选中(避免重复)
|
||||
if (result.Status & mask) == 0 {
|
||||
result.Status |= mask
|
||||
itemID := uint32(400686 + randBitIdx + 1)
|
||||
selectedItems = append(selectedItems, itemID)
|
||||
itemMask[itemID] = mask
|
||||
|
||||
@@ -20,15 +20,15 @@ func petSetExpLimit(currentPet *playermodel.PetInfo) int64 {
|
||||
for simulatedPet.Level < 100 {
|
||||
needExp := simulatedPet.NextLvExp - simulatedPet.Exp
|
||||
if needExp <= 0 {
|
||||
simulatedPet.Exp = simulatedPet.NextLvExp
|
||||
simulatedPet.Level++
|
||||
simulatedPet.Exp = 0
|
||||
simulatedPet.Update(true)
|
||||
continue
|
||||
}
|
||||
|
||||
allowedExp += needExp
|
||||
simulatedPet.Exp += needExp
|
||||
simulatedPet.Level++
|
||||
simulatedPet.Exp = 0
|
||||
simulatedPet.Update(true)
|
||||
}
|
||||
|
||||
@@ -99,8 +99,9 @@ func (h Controller) PetFirst(
|
||||
func (h Controller) SetPetExp(
|
||||
data *PetSetExpInboundInfo,
|
||||
player *player.Player) (result *pet.PetSetExpOutboundInfo, err errorcode.ErrorCode) {
|
||||
_, currentPet, found := player.FindPet(data.CatchTime)
|
||||
if !found || currentPet.Level >= 100 {
|
||||
slot, found := player.FindPetBagSlot(data.CatchTime)
|
||||
currentPet := slot.PetInfoPtr()
|
||||
if !found || currentPet == nil || currentPet.Level >= 100 {
|
||||
return &pet.PetSetExpOutboundInfo{Exp: player.Info.ExpPool}, errorcode.ErrorCodes.ErrSystemError
|
||||
}
|
||||
|
||||
|
||||
@@ -67,8 +67,9 @@ func (h Controller) GetPetLearnableSkills(
|
||||
data *GetPetLearnableSkillsInboundInfo,
|
||||
c *player.Player,
|
||||
) (result *GetPetLearnableSkillsOutboundInfo, err errorcode.ErrorCode) {
|
||||
_, currentPet, ok := c.FindPet(data.CatchTime)
|
||||
if !ok {
|
||||
slot, ok := c.FindPetBagSlot(data.CatchTime)
|
||||
currentPet := slot.PetInfoPtr()
|
||||
if !ok || currentPet == nil {
|
||||
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
|
||||
}
|
||||
|
||||
@@ -81,8 +82,9 @@ func (h Controller) GetPetLearnableSkills(
|
||||
func (h Controller) SetPetSkill(data *ChangeSkillInfo, c *player.Player) (result *pet.ChangeSkillOutInfo, err errorcode.ErrorCode) {
|
||||
const setSkillCost = 50
|
||||
|
||||
_, currentPet, ok := c.FindPet(data.CatchTime)
|
||||
if !ok {
|
||||
slot, ok := c.FindPetBagSlot(data.CatchTime)
|
||||
currentPet := slot.PetInfoPtr()
|
||||
if !ok || currentPet == nil {
|
||||
return nil, errorcode.ErrorCodes.ErrSystemBusy
|
||||
}
|
||||
|
||||
@@ -147,8 +149,9 @@ func (h Controller) SetPetSkill(data *ChangeSkillInfo, c *player.Player) (result
|
||||
func (h Controller) SortPetSkills(data *C2S_Skill_Sort, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
||||
const skillSortCost = 50
|
||||
|
||||
_, currentPet, ok := c.FindPet(data.CapTm)
|
||||
if !ok {
|
||||
slot, ok := c.FindPetBagSlot(data.CapTm)
|
||||
currentPet := slot.PetInfoPtr()
|
||||
if !ok || currentPet == nil {
|
||||
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
|
||||
}
|
||||
|
||||
@@ -205,8 +208,9 @@ func (h Controller) CommitPetSkills(
|
||||
const setSkillCost = 50
|
||||
const skillSortCost = 50
|
||||
|
||||
_, currentPet, ok := c.FindPet(data.CatchTime)
|
||||
if !ok {
|
||||
slot, ok := c.FindPetBagSlot(data.CatchTime)
|
||||
currentPet := slot.PetInfoPtr()
|
||||
if !ok || currentPet == nil {
|
||||
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
|
||||
}
|
||||
|
||||
|
||||
@@ -34,9 +34,6 @@ func (p *baseplayer) GetInfo() *model.PlayerInfo {
|
||||
|
||||
func ApplyPetLevelLimit(pet model.PetInfo, limitlevel uint32) model.PetInfo {
|
||||
originalHP := pet.Hp
|
||||
if limitlevel > 0 {
|
||||
pet.Level = utils.Min(pet.Level, limitlevel)
|
||||
}
|
||||
pet.CalculatePetPane(limitlevel)
|
||||
pet.Hp = utils.Min(originalHP, pet.MaxHp)
|
||||
return pet
|
||||
|
||||
@@ -27,10 +27,11 @@ func (p *Player) AddPetExp(petInfo *model.PetInfo, addExp int64) {
|
||||
if petInfo == nil || addExp <= 0 {
|
||||
return
|
||||
}
|
||||
panelLimit := p.CurrentMapPetLevelLimit()
|
||||
if petInfo.Level > 100 {
|
||||
currentHP := petInfo.Hp
|
||||
petInfo.Update(false)
|
||||
petInfo.CalculatePetPane(100)
|
||||
petInfo.CalculatePetPane(panelLimit)
|
||||
petInfo.Hp = utils.Min(currentHP, petInfo.MaxHp)
|
||||
}
|
||||
addExp = utils.Min(addExp, p.Info.ExpPool)
|
||||
@@ -40,13 +41,12 @@ func (p *Player) AddPetExp(petInfo *model.PetInfo, addExp int64) {
|
||||
gainedExp := exp //已获得的经验
|
||||
for exp >= int64(petInfo.NextLvExp) {
|
||||
petInfo.Level++
|
||||
exp -= int64(petInfo.LvExp)
|
||||
petInfo.Update(true)
|
||||
}
|
||||
petInfo.Exp = (exp)
|
||||
// 重新计算面板
|
||||
if originalLevel != petInfo.Level {
|
||||
petInfo.CalculatePetPane(100)
|
||||
petInfo.CalculatePetPane(panelLimit)
|
||||
|
||||
petInfo.Cure()
|
||||
p.Info.PetMaxLevel = utils.Max(petInfo.Level, p.Info.PetMaxLevel)
|
||||
|
||||
@@ -239,6 +239,10 @@ func (p *Player) CurrentMapPetLevelLimit() uint32 {
|
||||
return 100
|
||||
}
|
||||
|
||||
func (p *Player) IsCurrentMapLevelBreak() bool {
|
||||
return p != nil && p.CurrentMapPetLevelLimit() == 0
|
||||
}
|
||||
|
||||
// CanFight 检查玩家是否可以进行战斗
|
||||
// 0无战斗,1PVP,2,BOOS,3PVE
|
||||
func (p *Player) CanFight() errorcode.ErrorCode {
|
||||
|
||||
Reference in New Issue
Block a user