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