diff --git a/logic/controller/action_扭蛋.go b/logic/controller/action_扭蛋.go index 0bab37721..63d8e129b 100644 --- a/logic/controller/action_扭蛋.go +++ b/logic/controller/action_扭蛋.go @@ -35,7 +35,10 @@ 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, 0) - newPet.RandShiny() + if grand.Meet(1, 500) { + newPet.RandomByWeightShiny() + } + c.Service.Pet.PetAdd(newPet) result.HadTime = newPet.CatchTime diff --git a/logic/controller/fight_boss野怪和地图怪.go b/logic/controller/fight_boss野怪和地图怪.go index 74f01f528..9ddd07e16 100644 --- a/logic/controller/fight_boss野怪和地图怪.go +++ b/logic/controller/fight_boss野怪和地图怪.go @@ -116,8 +116,9 @@ func (Controller) PlayerFightBoss(data *fight.ChallengeBossInboundInfo, p *playe } if bc.BossCatchable == 1 { canCapture = xmlres.PetMAP[int(monster.ID)].CatchRate - - monsterInfo.PetList[0].RandShiny() + if grand.Meet(1, 500) { + monsterInfo.PetList[0].RandomByWeightShiny() + } } monsterInfo.Nick = bc.Name //xmlres.PetMAP[int(monster.ID)].DefName @@ -178,7 +179,9 @@ func (Controller) OnPlayerFightNpcMonster(data1 *fight.FightNpcMonsterInboundInf refPet.ShinyInfo, -1) monster.CatchMap = p.Info.MapID //设置当前地图 if refPet.Ext != 0 { - monster.RandShiny() + if grand.Meet(1, 500) { + monster.RandomByWeightShiny() + } } monsterInfo := &model.PlayerInfo{} diff --git a/logic/service/player/Monster.go b/logic/service/player/Monster.go index b2ed0afcb..ae42d982d 100644 --- a/logic/service/player/Monster.go +++ b/logic/service/player/Monster.go @@ -81,10 +81,10 @@ func (p *Player) GenMonster() { } if cool.Config.ServerInfo.IsVip != 0 { //测试服,百分百异色 - p.OgreInfo.Data[i].RandomByWeightShiny() + p.OgreInfo.Data[i].FixSHiny() } if xmlres.PetMAP[int(p.OgreInfo.Data[i].ID)].CatchRate != 0 { - p.OgreInfo.Data[i].RandSHiny() + p.OgreInfo.Data[i].RandomByWeightShiny() } if ok && len(mapinfo.DropItemIds) > 0 { diff --git a/logic/service/player/player.go b/logic/service/player/player.go index 8a585fb69..543b2ba8a 100644 --- a/logic/service/player/player.go +++ b/logic/service/player/player.go @@ -38,23 +38,11 @@ type OgrePetInfo struct { Ext uint32 `struc:"skip"` //是否变尼尔尼奥 } -func (o *OgrePetInfo) RandSHiny() { - var co *model.ColorfulSkin - if o.Ext == 0 { - - co = config.NewShinyService().RandShiny(o.ID) - } - - if co != nil && len(o.ShinyInfo) == 0 { - o.ShinyInfo = append(o.ShinyInfo, co.Color) - } - -} func (o *OgrePetInfo) FixSHiny() { var co *model.ColorfulSkin if o.Ext == 0 { - co = config.NewShinyService().FixShiny(o.ID) + co = config.NewShinyService().RandShiny(o.ID) } if co != nil && len(o.ShinyInfo) == 0 { diff --git a/modules/player/model/glow.go b/modules/config/model/glow.go similarity index 100% rename from modules/player/model/glow.go rename to modules/config/model/glow.go diff --git a/modules/config/service/shiny.go b/modules/config/service/shiny.go index f70b3f816..60372aeb3 100644 --- a/modules/config/service/shiny.go +++ b/modules/config/service/shiny.go @@ -44,71 +44,40 @@ func (s *ShinyService) ModifyBefore(ctx context.Context, method string, param g. return nil } func (s *ShinyService) RandShiny(id uint32) *model.ColorfulSkin { - if !grand.Meet(1, 500) { - return nil - } + var ret []model.ColorfulSkin // 执行 Raw SQL 并扫描返回值 dbm_enable(s.Model). Wheref(`bind_elf_ids @> ?::jsonb`, id). Wheref(`jsonb_typeof(bind_elf_ids) = ?`, "array").Scan(&ret) - var rets []model.ColorfulSkin - var props []int for _, v := range ret { - rets = append(rets, v) - props = append(props, int(v.ElfProbability)) + //print(v.ID) + id := v.ID + + if grand.Meet(int(v.ElfProbability), 1000) { + + if cool.Config.ServerInfo.IsVip == 0 { + m := cool.DBM(s.Model).Where("id", id) + m.Increment("usage_count", 1) + } + + return &v + + } } - - r, _ := utils.RandomByWeight(rets, props) - if cool.Config.ServerInfo.IsVip == 0 { - m := cool.DBM(s.Model).Where("id", id) - m.Increment("refresh_count", 1) - } - // for _, v := range ret { - // //print(v.ID) - - // id := v.ID - - // if grand.Meet(int(v.ElfProbability), 1000) { - - // if cool.Config.ServerInfo.IsVip == 0 { - // m := cool.DBM(s.Model).Where("id", id) - // m.Increment("refresh_count", 1) - // } - - // return &v - - // } - // } - - return &r + r := model.GenerateRandomOffspringMatrix() + var t data.GlowFilter + var ret1 model.ColorfulSkin + t.ColorMatrixFilter = r.Get() + ret1.Color = t + return &ret1 } -// 强制随机 -func (s *ShinyService) FixShiny(id uint32) *model.ColorfulSkin { - var ret []model.ColorfulSkin - - // 执行 Raw SQL 并扫描返回值 - dbm_enable(s.Model). - Wheref(`bind_elf_ids @> ?::jsonb`, id). - Wheref(`jsonb_typeof(bind_elf_ids) = ?`, "array").Scan(&ret) - if len(ret) == 0 { - return nil - } - v := ret[grand.Intn(len(ret))] - - if cool.Config.ServerInfo.IsVip == 0 { - m := cool.DBM(s.Model).Where("id", v.ID) - m.Increment("usage_count", 1) - } - - return &v - -} func (s *ShinyService) RandomByWeightShiny(id uint32) *model.ColorfulSkin { + var ret []model.ColorfulSkin // 执行 Raw SQL 并扫描返回值 @@ -130,7 +99,7 @@ func (s *ShinyService) RandomByWeightShiny(id uint32) *model.ColorfulSkin { r, _ := utils.RandomByWeight(rets, props) if cool.Config.ServerInfo.IsVip == 0 { m := cool.DBM(s.Model).Where("id", r.ID) - m.Increment("usage_count", 1) + m.Increment("refresh_count", 1) } return &r diff --git a/modules/player/model/pet.go b/modules/player/model/pet.go index 851296eb7..16d0aefea 100644 --- a/modules/player/model/pet.go +++ b/modules/player/model/pet.go @@ -213,40 +213,19 @@ func (pet *PetInfo) Cure() { } } } -func (pet *PetInfo) RandShiny() { - - co := service.NewShinyService().RandShiny(pet.ID) - if co != nil { - pet.ShinyInfo = append(pet.ShinyInfo, co.Color) - } - //o.ShinyInfo[0].ColorMatrixFilter = GenerateRandomOffspringMatrix().Get() - //g.Dump(ttt.ShinyInfo) - // ttt.Shiny = 0 //待确认是否刷新异色 -} // 强制选色,这个是给熔炉用的 func (pet *PetInfo) FixShiny() { - co := service.NewShinyService().FixShiny(pet.ID) - if co != nil { - pet.ShinyInfo = append(pet.ShinyInfo, co.Color) - } else { - r := GenerateRandomOffspringMatrix() - var t data.GlowFilter - t.ColorMatrixFilter = r.Get() - pet.ShinyInfo = append(pet.ShinyInfo, t) - - } - + co := service.NewShinyService().RandShiny(pet.ID) + pet.ShinyInfo = append(pet.ShinyInfo, co.Color) } // 比重融合 func (pet *PetInfo) RandomByWeightShiny() { co := service.NewShinyService().RandomByWeightShiny(pet.ID) - if co != nil { - pet.ShinyInfo = append(pet.ShinyInfo, co.Color) - } + pet.ShinyInfo = append(pet.ShinyInfo, co.Color) } func (pet *PetInfo) IsShiny() bool {