fix(fight): 修正空变更导致的潜在逻辑问题
This commit is contained in:
@@ -7,6 +7,8 @@ import (
|
||||
"blazing/logic/service/player"
|
||||
"blazing/modules/blazing/model"
|
||||
"blazing/modules/blazing/service"
|
||||
|
||||
"github.com/shopspring/decimal"
|
||||
)
|
||||
|
||||
func (h Controller) PetFusion(data *pet.C2S_PetFusion, c *player.Player) (result *pet.PetFusionInfo, err errorcode.ErrorCode) {
|
||||
@@ -50,7 +52,10 @@ func (h Controller) PetFusion(data *pet.C2S_PetFusion, c *player.Player) (result
|
||||
}
|
||||
|
||||
effect := int(service.NewPetFusionMaterialService().Data(data.Item1))
|
||||
r := model.GenPetInfo(resid, -1, int(natureId), effect, -1, 1)
|
||||
dv1 := decimal.NewFromInt(2).Div(decimal.NewFromInt(3)).Mul(decimal.NewFromInt(int64(Mcatchpetinfo.Dv)))
|
||||
dv2 := decimal.NewFromInt(1).Div(decimal.NewFromInt(3)).Mul(decimal.NewFromInt(int64(Auxpetinfo.Dv)))
|
||||
dv := dv1.Add(dv2).Add(decimal.NewFromInt(1)).IntPart()
|
||||
r := model.GenPetInfo(resid, int(dv), int(natureId), effect, -1, 1)
|
||||
c.Service.Pet.PetAdd(*r)
|
||||
c.Pet_del(Auxpetinfo.CatchTime)
|
||||
c.Pet_del(Mcatchpetinfo.CatchTime)
|
||||
|
||||
@@ -46,14 +46,23 @@ func (s *PetFusionService) Data(p1, p2 uint32) uint32 {
|
||||
return uint32(v.ResultPetID)
|
||||
}
|
||||
}
|
||||
//说明是失败,直接返回失败
|
||||
if len(pet) > 0 {
|
||||
return 0
|
||||
}
|
||||
|
||||
var pets []model.PetFusion
|
||||
|
||||
m = cool.DBM(s.Model)
|
||||
m.Where("is_enable", 1).Where("is_default", 1).Scan(&pets)
|
||||
if len(pets) == 0 {
|
||||
return 0
|
||||
}
|
||||
res := pets[grand.Intn(len(pets)-1)]
|
||||
rr := grand.Intn(100)
|
||||
if rr < int(res.Probability) {
|
||||
return uint32(res.ResultPetID)
|
||||
}
|
||||
|
||||
return uint32(pets[grand.Intn(len(pets)-1)].ID)
|
||||
return 0
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user