```
feat(config): 新增固定异色功能并重构异色服务 - 新增 FixShiny 方法用于固定获取异色效果 - 重命名 Args 方法为 RandShiny 以明确功能 - 添加 utils 包依赖用于数据转换 feat(model): 扩展宠物异色相关方法 - 为 PetInfo 结构体添加 FixShiny 方法 - 修改 RandShiny 方法逻辑,确保异色信息正确添加 ref
This commit is contained in:
@@ -118,7 +118,7 @@ func Initfile() {
|
||||
}
|
||||
PlayerEffectMAP = make(map[int]NewSeIdx)
|
||||
for _, v := range EffectMAP1.SeIdxList {
|
||||
if gconv.Int(v.Stat) == 1 && gconv.Int(v.StarLevel) == 0 && gconv.Int(v.Idx) > 1000 {
|
||||
if gconv.Int(v.Stat) == 1 && gconv.Int(v.Idx) > 1000 {
|
||||
v.ArgsS = ParseSideEffectArgs(v.Args)
|
||||
|
||||
PlayerEffectMAP[gconv.Int(v.Idx)] = v
|
||||
|
||||
@@ -72,7 +72,7 @@ func (h Controller) PetFusion(data *pet.C2S_PetFusion, c *player.Player) (result
|
||||
shinycont = 100
|
||||
}
|
||||
if grand.Meet(shinycont, 100) {
|
||||
r.RandShiny()
|
||||
r.FixShiny()
|
||||
|
||||
}
|
||||
c.Service.Pet.PetAdd(r)
|
||||
|
||||
@@ -69,7 +69,7 @@ func (o *OgrePetInfo) RandSHiny() {
|
||||
// // 矩阵含义:R=100%、G=100%、B=100%、A=100%,无颜色偏移
|
||||
|
||||
// }
|
||||
co := config.NewShinyService().Args(o.Id)
|
||||
co := config.NewShinyService().RandShiny(o.Id)
|
||||
if co != nil {
|
||||
o.ShinyInfo = append(o.ShinyInfo, *co)
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ func (c *PetBagController) GetSession(ctx context.Context, req *PetGetReq) (res
|
||||
)
|
||||
t := model.GenPetInfo(
|
||||
req.PetTypeId, req.IndividualValue, req.NatureId, req.AbilityTypeEnum, req.Level, nil)
|
||||
t.FixShiny()
|
||||
|
||||
service.NewUserService(uint32(admin.UserId)).Pet.PetAdd(t)
|
||||
return
|
||||
|
||||
@@ -215,7 +215,17 @@ func (pet *PetInfo) Cure() {
|
||||
}
|
||||
func (pet *PetInfo) RandShiny() {
|
||||
|
||||
co := service.NewShinyService().Args(pet.ID)
|
||||
co := service.NewShinyService().RandShiny(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) FixShiny() {
|
||||
|
||||
co := service.NewShinyService().FixShiny(pet.ID)
|
||||
if co != nil {
|
||||
pet.ShinyInfo = append(pet.ShinyInfo, *co)
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package service
|
||||
|
||||
import (
|
||||
"blazing/common/data"
|
||||
"blazing/common/utils"
|
||||
"blazing/cool"
|
||||
"blazing/modules/config/model"
|
||||
"context"
|
||||
@@ -40,7 +41,7 @@ func (s *ShinyService) ModifyBefore(ctx context.Context, method string, param g.
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (s *ShinyService) Args(id uint32) *data.GlowFilter {
|
||||
func (s *ShinyService) RandShiny(id uint32) *data.GlowFilter {
|
||||
var ret []model.ColorfulSkin
|
||||
|
||||
// 执行 Raw SQL 并扫描返回值
|
||||
@@ -70,3 +71,35 @@ func (s *ShinyService) Args(id uint32) *data.GlowFilter {
|
||||
|
||||
return nil
|
||||
}
|
||||
func (s *ShinyService) FixShiny(id uint32) *data.GlowFilter {
|
||||
var ret []model.ColorfulSkin
|
||||
|
||||
// 执行 Raw SQL 并扫描返回值
|
||||
cool.DBM(s.Model).Wheref(`bind_elf_ids @> ?::jsonb`, id).Wheref(`jsonb_typeof(bind_elf_ids) = ?`, "array").Cache(gdb.CacheOption{
|
||||
// Duration: time.Hour,
|
||||
|
||||
Force: false,
|
||||
}).Scan(&ret)
|
||||
|
||||
rets := utils.ToMap(ret, func(t model.ColorfulSkin) uint32 {
|
||||
return uint32(t.ID)
|
||||
})
|
||||
|
||||
for _, v := range rets {
|
||||
//print(v.ID)
|
||||
|
||||
id := v.ID
|
||||
|
||||
var t data.GlowFilter
|
||||
|
||||
r := json.Unmarshal([]byte(v.Color), &t)
|
||||
if r == nil {
|
||||
m := cool.DBM(s.Model).Where("id", id)
|
||||
m.Increment("refresh_count", 1)
|
||||
return &t
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user