diff --git a/logic/controller/action_egg.go b/logic/controller/action_egg.go index b4135e256..71b9d5505 100644 --- a/logic/controller/action_egg.go +++ b/logic/controller/action_egg.go @@ -24,7 +24,11 @@ func (h Controller) EggGamePlay(data1 *egg.C2S_EGG_GAME_PLAY, c *player.Player) if grand.Meet(int(data1.EggNum), 100) { r := service.NewPetRewardService().GetEgg() newPet := model.GenPetInfo(int(r.MonID), int(r.DV), int(r.Nature), int(r.Effect), int(r.Lv), nil) + if grand.Meet(int(data1.EggNum), 100) { + newPet.RandShiny() + } c.Service.Pet.PetAdd(newPet) + result.HadTime = newPet.CatchTime result.PetID = newPet.ID } diff --git a/logic/controller/fight_boss.go b/logic/controller/fight_boss.go index b80f60426..3d5756b68 100644 --- a/logic/controller/fight_boss.go +++ b/logic/controller/fight_boss.go @@ -96,8 +96,7 @@ func (h Controller) PlayerFightBoss(data *fight.ChallengeBossInboundInfo, p *pla for _, v := range strings.Split(bm.NewSeIdxs, " ") { idx := gconv.Uint16(v) - // eff := xmlres.EffectMAP[int(idx)] - // args := strings.Split(eff.Args, " ") + if idx == 0 { continue } @@ -113,6 +112,13 @@ func (h Controller) PlayerFightBoss(data *fight.ChallengeBossInboundInfo, p *pla } if bc.BossCatchable == 1 { canCapture = xmlres.PetMAP[int(monster.ID)].CatchRate + + if grand.Meet(1, 100) { + r := monsterInfo.PetList[0] + r.RandShiny() + monsterInfo.PetList[0] = r + } + } monsterInfo.Nick = bc.Name //xmlres.PetMAP[int(monster.ID)].DefName break diff --git a/logic/controller/item_use.go b/logic/controller/item_use.go index 0e70da1c2..aa50dd528 100644 --- a/logic/controller/item_use.go +++ b/logic/controller/item_use.go @@ -54,7 +54,9 @@ func (h Controller) UsePetItemOutOfFight(data *item.C2S_USE_PET_ITEM_OUT_OF_FIGH oldPet := c.Service.Pet.PetInfo_One_Unscoped(currentPet.OldCatchTime) copier.CopyWithOption(currentPet, oldPet.Data, copier.Option{DeepCopy: true}) + // println("currentPet.CatchTime", currentPet.CatchTime, currentPet.OldCatchTime) currentPet.CatchTime = oldPetCatchTime + currentPet.EffectInfo = oldPet.Data.EffectInfo } else { handler := item.PetItemRegistry.GetHandler(data.ItemID) diff --git a/logic/controller/pet_fusion.go b/logic/controller/pet_fusion.go index b3ca56f01..0d7ba1550 100644 --- a/logic/controller/pet_fusion.go +++ b/logic/controller/pet_fusion.go @@ -9,6 +9,7 @@ import ( "blazing/modules/config/service" "github.com/alpacahq/alpacadecimal" + "github.com/gogf/gf/v2/util/grand" ) func (h Controller) PetFusion(data *pet.C2S_PetFusion, c *player.Player) (result *pet.PetFusionInfo, err errorcode.ErrorCode) { @@ -62,10 +63,22 @@ func (h Controller) PetFusion(data *pet.C2S_PetFusion, c *player.Player) (result dv := dv1.Add(dv2).Add(alpacadecimal.NewFromInt(1)).IntPart() r := model.GenPetInfo(resid, int(dv), int(natureId), effect, 1, nil) r.OldCatchTime = Mcatchpetinfo.CatchTime + + shinycont := 0 + if Mcatchpetinfo.IsShiny() || Auxpetinfo.IsShiny() { + shinycont = 50 + } + if Mcatchpetinfo.IsShiny() && Auxpetinfo.IsShiny() { + shinycont = 100 + } + if grand.Meet(shinycont, 100) { + r.RandShiny() + + } c.Service.Pet.PetAdd(r) println(len(c.Info.PetList), data.Mcatchtime, data.Auxcatchtime, Mcatchpetinfo.CatchTime, Auxpetinfo.CatchTime) - c.Pet_del(data.Auxcatchtime) - c.Pet_del(data.Mcatchtime) + c.PetDel(data.Auxcatchtime) + c.PetDel(data.Mcatchtime) //fmt.Println(len(c.Info.PetList)) // g.Dump(c.Info.PetList) //todo材料扣除 diff --git a/logic/service/player/Monster.go b/logic/service/player/Monster.go index c6a656dd2..2c4b0f7a8 100644 --- a/logic/service/player/Monster.go +++ b/logic/service/player/Monster.go @@ -69,12 +69,7 @@ func (p *Player) genMonster() { if p.OgreInfo.Data[i].Id != 0 { p.OgreInfo.Data[i].Lv = gconv.Uint32(RandomStringFromSlice(lv)) - if cool.Config.PortBL == 2 { //测试服,百分百异色 - p.OgreInfo.Data[i].RandSHiny() - } - if xmlres.PetMAP[int(p.OgreInfo.Data[i].Id)].CatchRate != 0 && grand.Meet(1, 100) { - p.OgreInfo.Data[i].RandSHiny() - } + if len(id) == 1 { //说明这里只固定刷一个,概率变尼尔尼奥 nieo, _, _ := p.Roll(20, 1000) @@ -88,6 +83,12 @@ func (p *Player) genMonster() { } } + if cool.Config.PortBL == 2 { //测试服,百分百异色 + p.OgreInfo.Data[i].RandSHiny() + } + if xmlres.PetMAP[int(p.OgreInfo.Data[i].Id)].CatchRate != 0 && grand.Meet(1, 100) { + p.OgreInfo.Data[i].RandSHiny() + } if ok { p.OgreInfo.Data[i].Item = uint32(mapss.Monsters.ItemBonusID) diff --git a/logic/service/player/base.go b/logic/service/player/base.go index 9998f5850..ada662cce 100644 --- a/logic/service/player/base.go +++ b/logic/service/player/base.go @@ -63,23 +63,19 @@ func (f *baseplayer) FindPet(catchTime uint32) (int, *model.PetInfo, bool) { }) } -// Pet_del 删除指定宠物 +// PetDel 删除指定宠物 // catchTime: 宠物的捕捉时间戳 -func (f *Player) Pet_del(catchTime uint32) { - index, _, ok := f.FindPet(catchTime) +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.Service.Pet.PetInfo_One_exec(catchTime, func(petData *model.PetEX) { + petData.Data = *olpet + //t.InBag = 0 + + }) f.Service.Pet.Pet_del(catchTime) } } - -// // 计算整数的二进制1的个数(Integer.bitCount) -// func bitsCount(n int) int { -// count := 0 -// for n > 0 { -// count += n & 1 -// n >>= 1 -// } -// return count -// } diff --git a/modules/blazing/model/pet.go b/modules/blazing/model/pet.go index 6d4529c71..c3fe1480b 100644 --- a/modules/blazing/model/pet.go +++ b/modules/blazing/model/pet.go @@ -5,6 +5,7 @@ import ( "blazing/common/data/xmlres" "blazing/common/utils" "blazing/cool" + "blazing/modules/config/service" "errors" "fmt" "math" @@ -212,6 +213,21 @@ func (pet *PetInfo) Cure() { } } } +func (pet *PetInfo) RandShiny() { + + co := service.NewShinyService().Args(pet.ID) + if co != nil { + pet.ShinyInfo = append(pet.ShinyInfo, *co) + } + //o.ShinyInfo[0].ColorMatrixFilter = GenerateRandomOffspringMatrix().Get() + //g.Dump(ttt.ShinyInfo) + // ttt.Shiny = 0 //待确认是否刷新异色 +} +func (pet *PetInfo) IsShiny() bool { + + return len(pet.ShinyInfo) > 0 + +} // 随机特性 func (pet *PetInfo) RnadAN() {