fix: 修复宠物升级经验显示与动态结算
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
This commit is contained in:
@@ -39,27 +39,16 @@ func (p *Player) AddPetExp(petInfo *model.PetInfo, addExp int64) {
|
||||
return
|
||||
}
|
||||
originalLevel := petInfo.Level
|
||||
allocatedExp := addExp
|
||||
p.Info.ExpPool -= addExp //减去已使用的经验
|
||||
|
||||
remainingExp := addExp
|
||||
for remainingExp > 0 {
|
||||
needExp := petInfo.NextLvExp - petInfo.Exp
|
||||
if needExp <= 0 {
|
||||
petInfo.Exp = petInfo.NextLvExp
|
||||
petInfo.Level++
|
||||
petInfo.Update(true)
|
||||
continue
|
||||
}
|
||||
if remainingExp < needExp {
|
||||
petInfo.Exp += remainingExp
|
||||
break
|
||||
}
|
||||
|
||||
petInfo.Exp += needExp
|
||||
remainingExp -= needExp
|
||||
currentExp := petInfo.Exp + addExp
|
||||
for currentExp >= petInfo.NextLvExp && petInfo.NextLvExp > 0 {
|
||||
petInfo.Level++
|
||||
petInfo.Update(true)
|
||||
currentExp -= petInfo.LvExp
|
||||
}
|
||||
petInfo.Exp = currentExp
|
||||
|
||||
// 重新计算面板
|
||||
if originalLevel != petInfo.Level {
|
||||
@@ -95,6 +84,7 @@ func (p *Player) AddPetExp(petInfo *model.PetInfo, addExp int64) {
|
||||
var petUpdateInfo info.UpdatePropInfo
|
||||
|
||||
copier.Copy(&petUpdateInfo, petInfo)
|
||||
petUpdateInfo.Exp = uint32(allocatedExp)
|
||||
updateOutbound.Data = append(updateOutbound.Data, petUpdateInfo)
|
||||
p.SendPack(header.Pack(updateOutbound)) //准备包由各自发,因为协议不一样
|
||||
|
||||
|
||||
Reference in New Issue
Block a user