``feat(item): 新增物品出售价格属性(SellPrice)并实现物品出售功能,优化宠物面板计算和时区判断逻辑``
This commit is contained in:
48
logic/controller/pet_ev.go
Normal file
48
logic/controller/pet_ev.go
Normal file
@@ -0,0 +1,48 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"blazing/common/socket/errorcode"
|
||||
"blazing/logic/service/pet"
|
||||
"blazing/logic/service/player"
|
||||
|
||||
"github.com/samber/lo"
|
||||
)
|
||||
|
||||
func (h Controller) PetEVdiy(data *pet.PetEV, c *player.Player) (result *pet.S2C_50001, err errorcode.ErrorCode) {
|
||||
_, onpet, ok := c.FindPet(data.CacthTime)
|
||||
if !ok {
|
||||
return nil, errorcode.ErrorCodes.Err10401
|
||||
}
|
||||
//分配超过510的数据
|
||||
if lo.Sum(data.EVs[:]) > 510 {
|
||||
return nil, errorcode.ErrorCodes.Err10401
|
||||
}
|
||||
|
||||
for i, v := range data.EVs {
|
||||
|
||||
//分配超过255的数据
|
||||
if v > 255 {
|
||||
return nil, errorcode.ErrorCodes.Err10401
|
||||
}
|
||||
//分配比之前点数少的
|
||||
if v < onpet.Ev[i] {
|
||||
return nil, errorcode.ErrorCodes.Err10401
|
||||
}
|
||||
}
|
||||
if lo.Sum(data.EVs[:]) < lo.Sum(onpet.Ev[:]) {
|
||||
return nil, errorcode.ErrorCodes.Err10401
|
||||
}
|
||||
|
||||
USEEV1 := lo.Sum(data.EVs[:]) - lo.Sum(onpet.Ev[:])
|
||||
//加的比池子还多
|
||||
if USEEV1 > c.Info.EVPool {
|
||||
return nil, errorcode.ErrorCodes.Err10401
|
||||
}
|
||||
onpet.Ev = data.EVs
|
||||
onpet.CalculatePetPane(false)
|
||||
c.Info.EVPool -= USEEV1
|
||||
|
||||
result = &pet.S2C_50001{}
|
||||
result.UseEV = USEEV1
|
||||
return result, 0
|
||||
}
|
||||
Reference in New Issue
Block a user