``` refactor(pet): 优化宠物特性随机逻辑并修复宠物删除数组操作
This commit is contained in:
@@ -201,7 +201,7 @@ func init() {
|
||||
PetItemRegistry.RegisterExact(300053, func(itemid uint32, onpet *model.PetInfo) bool {
|
||||
_, _, ok := onpet.GetEffect(1)
|
||||
if !ok {
|
||||
onpet.RnadAN()
|
||||
onpet.RnadEffect()
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ func init() {
|
||||
PetItemRegistry.RegisterExact(300054, func(itemid uint32, onpet *model.PetInfo) bool {
|
||||
_, _, ok := onpet.GetEffect(1)
|
||||
if ok {
|
||||
onpet.RnadAN()
|
||||
onpet.RnadEffect()
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
||||
@@ -68,8 +68,8 @@ func (f *baseplayer) FindPet(catchTime uint32) (int, *model.PetInfo, bool) {
|
||||
func (f *Player) PetDel(catchTime uint32) {
|
||||
index, olpet, ok := f.FindPet(catchTime)
|
||||
if ok {
|
||||
copy(f.Info.PetList[index:], f.Info.PetList[index+1:])
|
||||
f.Info.PetList = f.Info.PetList[:len(f.Info.PetList)-1]
|
||||
f.Info.PetList = append(f.Info.PetList[:index], f.Info.PetList[index+1:]...)
|
||||
|
||||
//先将背包更新
|
||||
f.Service.Pet.PetInfo_One_exec(catchTime, func(petData *model.PetEX) {
|
||||
petData.Data = *olpet
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
"math/rand"
|
||||
"time"
|
||||
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
@@ -240,14 +239,10 @@ func (pet *PetInfo) IsShiny() bool {
|
||||
}
|
||||
|
||||
// 随机特性
|
||||
func (pet *PetInfo) RnadAN() {
|
||||
// 随机特性
|
||||
randomIndex := rand.Intn(len(xmlres.PlayerEffectMAP))
|
||||
func (pet *PetInfo) RnadEffect() {
|
||||
|
||||
var i int
|
||||
for _, v := range xmlres.PlayerEffectMAP {
|
||||
|
||||
if i == randomIndex {
|
||||
if gconv.Int(v.StarLevel) == 0 {
|
||||
ret := &PetEffectInfo{
|
||||
Idx: uint16(gconv.Int16(v.Idx)),
|
||||
Status: 1,
|
||||
@@ -264,7 +259,7 @@ func (pet *PetInfo) RnadAN() {
|
||||
|
||||
break
|
||||
}
|
||||
i++
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -475,14 +470,15 @@ func GenPetInfo(
|
||||
case abilityTypeEnum == -1:
|
||||
|
||||
for _, v := range xmlres.PlayerEffectMAP {
|
||||
|
||||
p.EffectInfo = append(p.EffectInfo, PetEffectInfo{
|
||||
Idx: uint16(gconv.Int16(v.Idx)),
|
||||
Status: 1,
|
||||
EID: uint16(gconv.Int16(v.Eid)),
|
||||
Args: v.ArgsS,
|
||||
})
|
||||
break
|
||||
if gconv.Int(v.StarLevel) == 0 {
|
||||
p.EffectInfo = append(p.EffectInfo, PetEffectInfo{
|
||||
Idx: uint16(gconv.Int16(v.Idx)),
|
||||
Status: 1,
|
||||
EID: uint16(gconv.Int16(v.Eid)),
|
||||
Args: v.ArgsS,
|
||||
})
|
||||
break
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ func (s *PetFusionService) Data(p1, p2, rand uint32) uint32 {
|
||||
return 0
|
||||
}
|
||||
pets := s.def()
|
||||
res := pets[grand.Intn(len(pets)-1)]
|
||||
res := pets[grand.Intn(len(pets))]
|
||||
rr := grand.Intn(100)
|
||||
if rr < int(res.Probability+int32(rand)) {
|
||||
return uint32(res.ResultPetID)
|
||||
|
||||
Reference in New Issue
Block a user