From ffe3ff18bfec2ef70030413044a52135bc74286d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=94=E5=BF=B5?= <12574910+72wo@users.noreply.github.com> Date: Sun, 8 Feb 2026 17:57:42 +0800 Subject: [PATCH] 1 --- common/data/xmlres/pet.go | 44 ++++++++--------- logic/controller/action_扭蛋.go | 2 +- logic/controller/fight_boss.go | 10 ++-- logic/controller/fight_塔.go | 2 +- logic/controller/pet_collect.go | 2 +- logic/controller/pet_fusion.go | 2 +- logic/controller/user_cdk.go | 2 +- logic/service/fight/boss/NewSeIdx_69.go | 2 +- logic/service/fight/effect/effect_130.go | 2 +- logic/service/fight/effect/effect_131.go | 2 +- logic/service/fight/effect/effect_83.go | 4 +- logic/service/fight/effect/effect_98.go | 2 +- .../effect_EffectConditionalAddDamage.go | 2 +- .../fight/effect/effect_power_doblue.go | 2 +- logic/service/fight/input.go | 2 +- logic/service/player/Monster.go | 6 +-- logic/service/player/player.go | 16 ++++--- logic/service/task/task.go | 2 +- modules/config/controller/admin/egg.go | 22 +++++++++ modules/config/model/egg.go | 48 ++++++++----------- modules/config/model/shiny.go | 12 +---- modules/config/service/egg.go | 32 +++++++++++++ modules/config/service/shiny.go | 47 ++++++++++-------- .../player/controller/admin/monster_get.go | 2 +- modules/player/model/pet.go | 28 ++++++++--- 25 files changed, 180 insertions(+), 117 deletions(-) create mode 100644 modules/config/controller/admin/egg.go create mode 100644 modules/config/service/egg.go diff --git a/common/data/xmlres/pet.go b/common/data/xmlres/pet.go index 0793b24dd..a04441171 100644 --- a/common/data/xmlres/pet.go +++ b/common/data/xmlres/pet.go @@ -15,28 +15,28 @@ type LearnableMoves struct { // PetInfo 表示一个怪物的信息 type PetInfo struct { - ID int `xml:"ID,attr"` - DefName string `xml:"DefName,attr"` // 名字 - Type int `xml:"Type,attr"` // 类型 - IsLarge int `xml:"IsLarge,attr"` // 是否为大型怪物 - GrowthType int `xml:"GrowthType,attr"` // 成长类型 - HP int `xml:"HP,attr"` // 血量种族值 - Atk uint32 `xml:"Atk,attr"` // 攻击种族值 - Def uint32 `xml:"Def,attr"` // 防御种族值 - SpAtk uint32 `xml:"SpAtk,attr"` // 特殊攻击种族值 - SpDef uint32 `xml:"SpDef,attr"` // 特殊防御种族值 - Spd uint32 `xml:"Spd,attr"` // 速度种族值 - YieldingExp int `xml:"YieldingExp,attr"` // 击败后获得的经验值 - CatchRate int `xml:"CatchRate,attr"` // 捕捉率 - YieldingEV string `xml:"YieldingEV,attr"` // 努力值奖励,格式为"HP Atk Def SpAtk SpDef Spd" - EvolvesFrom int `xml:"EvolvesFrom,attr"` // 进化前的怪物ID - EvolvesTo uint32 `xml:"EvolvesTo,attr"` // 进化后的怪物ID - EvolvFlag int `xml:"EvolvFlag,attr"` // - EvolvingLv int `xml:"EvolvingLv,attr"` // 进化等级 - FreeForbidden int `xml:"FreeForbidden,attr"` // 是否禁止放生 - FuseMaster int `xml:"FuseMaster,attr"` // 是否可作为融合主素材 - FuseSub int `xml:"FuseSub,attr"` // 是否可作为融合副素材 - Gender int `xml:"Gender,attr"` // 性别 0-无性别 1-雄性 2-雌性 + ID int `xml:"ID,attr"` + DefName string `xml:"DefName,attr"` // 名字 + Type int `xml:"Type,attr"` // 类型 + IsLarge int `xml:"IsLarge,attr"` // 是否为大型怪物 + GrowthType int `xml:"GrowthType,attr"` // 成长类型 + HP int `xml:"HP,attr"` // 血量种族值 + Atk uint32 `xml:"Atk,attr"` // 攻击种族值 + Def uint32 `xml:"Def,attr"` // 防御种族值 + SpAtk uint32 `xml:"SpAtk,attr"` // 特殊攻击种族值 + SpDef uint32 `xml:"SpDef,attr"` // 特殊防御种族值 + Spd uint32 `xml:"Spd,attr"` // 速度种族值 + YieldingExp int `xml:"YieldingExp,attr"` // 击败后获得的经验值 + CatchRate int `xml:"CatchRate,attr"` // 捕捉率 + YieldingEV string `xml:"YieldingEV,attr"` // 努力值奖励,格式为"HP Atk Def SpAtk SpDef Spd" + EvolvesFrom int `xml:"EvolvesFrom,attr"` // 进化前的怪物ID + EvolvesTo uint32 `xml:"EvolvesTo,attr"` // 进化后的怪物ID + EvolvFlag int `xml:"EvolvFlag,attr"` // + EvolvingLv int `xml:"EvolvingLv,attr"` // 进化等级 + FreeForbidden int `xml:"FreeForbidden,attr"` // 是否禁止放生 + FuseMaster int `xml:"FuseMaster,attr"` // 是否可作为融合主素材 + FuseSub int `xml:"FuseSub,attr"` // 是否可作为融合副素材 + // Gender int `xml:"Gender,attr"` // 性别 0-无性别 1-雄性 2-雌性 PetClass int `xml:"PetClass,attr"` // 宠物类别 FormParam float64 `xml:"FormParam,attr"` // 形态参数 CharacterAttrParam int `xml:"CharacterAttrParam,attr"` // 特性参数 diff --git a/logic/controller/action_扭蛋.go b/logic/controller/action_扭蛋.go index 06e4ecd8a..412558e7b 100644 --- a/logic/controller/action_扭蛋.go +++ b/logic/controller/action_扭蛋.go @@ -28,7 +28,7 @@ func (h Controller) EggGamePlay(data1 *egg.C2S_EGG_GAME_PLAY, c *player.Player) result = &egg.S2C_EGG_GAME_PLAY{ListInfo: []data.ItemInfo{}} 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) + newPet := model.GenPetInfo(int(r.MonID), int(r.DV), int(r.Nature), int(r.Effect), int(r.Lv), nil, 0) if grand.Meet(int(data1.EggNum), 100) { newPet.RandShiny() } diff --git a/logic/controller/fight_boss.go b/logic/controller/fight_boss.go index ac34d111e..a827a4248 100644 --- a/logic/controller/fight_boss.go +++ b/logic/controller/fight_boss.go @@ -87,7 +87,7 @@ func (Controller) PlayerFightBoss(data *fight.ChallengeBossInboundInfo, p *playe -1, 0, //野怪没特性 - bm.Lv, nil) + bm.Lv, nil, 0) monster.CatchTime = uint32(i) if bm.Hp != 0 { monster.Hp = uint32(bm.Hp) @@ -158,21 +158,21 @@ func (Controller) OnPlayerFightNpcMonster(data1 *fight.FightNpcMonsterInboundInf return nil, errorcode.ErrorCodes.ErrSystemError } refPet := p.OgreInfo.Data[data1.Number] - if refPet.Id == 0 { + if refPet.ID == 0 { return nil, errorcode.ErrorCodes.ErrPokemonNotExists } if refPet.Ext != 0 { - refPet.Id = refPet.Ext + refPet.ID = refPet.Ext } monster := model.GenPetInfo( - int(refPet.Id), -1, + int(refPet.ID), -1, -1, 0, //野怪没特性 int(refPet.Lv), - refPet.ShinyInfo) + refPet.ShinyInfo, -1) if refPet.Ext != 0 { if grand.Meet(3, 100) { monster.RandShiny() diff --git a/logic/controller/fight_塔.go b/logic/controller/fight_塔.go index 8a137a3b7..5cc6b1031 100644 --- a/logic/controller/fight_塔.go +++ b/logic/controller/fight_塔.go @@ -140,7 +140,7 @@ func (h Controller) PetTawor(data *fight.StartTwarInboundInfo, c *player.Player) r := service.NewBossService().Get(v) if r != nil { - monster := model.GenPetInfo(int(r.MonID), 24, int(r.Nature), 0, int(r.Lv), nil) + monster := model.GenPetInfo(int(r.MonID), 24, int(r.Nature), 0, int(r.Lv), nil, 0) if r.Hp != 0 { monster.Hp = uint32(r.Hp) monster.MaxHp = uint32(r.Hp) diff --git a/logic/controller/pet_collect.go b/logic/controller/pet_collect.go index b282e0e1c..340689dd0 100644 --- a/logic/controller/pet_collect.go +++ b/logic/controller/pet_collect.go @@ -53,7 +53,7 @@ func (h Controller) Collect( } c.Info.SetTask(1335+int(data.Type), model.Completed) - r := model.GenPetInfo(int(data.ID), -1, -1, 0, 1, nil) + r := model.GenPetInfo(int(data.ID), -1, -1, 0, 1, nil, 0) c.Service.Pet.PetAdd(r) result.CatchTime = r.CatchTime diff --git a/logic/controller/pet_fusion.go b/logic/controller/pet_fusion.go index 1e947b6e7..a7a2c92d9 100644 --- a/logic/controller/pet_fusion.go +++ b/logic/controller/pet_fusion.go @@ -97,7 +97,7 @@ func (h Controller) PetFusion(data *pet.C2S_PetFusion, c *player.Player) (result dv1 := alpacadecimal.NewFromInt(2).Div(alpacadecimal.NewFromInt(3)).Mul(alpacadecimal.NewFromInt(int64(Mcatchpetinfo.Dv))) dv2 := alpacadecimal.NewFromInt(1).Div(alpacadecimal.NewFromInt(3)).Mul(alpacadecimal.NewFromInt(int64(Auxpetinfo.Dv))) dv := dv1.Add(dv2).Add(alpacadecimal.NewFromInt(1)).IntPart() - r := model.GenPetInfo(resid, int(dv), int(natureId), effect, 1, nil) + r := model.GenPetInfo(resid, int(dv), int(natureId), effect, 1, nil, -1) r.OldCatchTime = Mcatchpetinfo.CatchTime shinycont := 1 diff --git a/logic/controller/user_cdk.go b/logic/controller/user_cdk.go index 856f00141..649a36169 100644 --- a/logic/controller/user_cdk.go +++ b/logic/controller/user_cdk.go @@ -31,7 +31,7 @@ func (h Controller) CDK(data *user.C2S_GET_GIFT_COMPLETE, player *player.Player) for _, v := range r.ElfRewardIds { pet := service.NewPetRewardService().Get(v) if pet != nil { - peti := model.GenPetInfo(int(pet.MonID), int(pet.DV), int(pet.Nature), int(pet.Effect), int(pet.Lv), nil) + peti := model.GenPetInfo(int(pet.MonID), int(pet.DV), int(pet.Nature), int(pet.Effect), int(pet.Lv), nil, 0) player.Service.Pet.PetAdd(peti) result.PetGift = append(result.PetGift, user.PetGiftInfo{PetID: peti.ID, CacthTime: peti.CatchTime}) } diff --git a/logic/service/fight/boss/NewSeIdx_69.go b/logic/service/fight/boss/NewSeIdx_69.go index cb8fb92fe..5bff53e1e 100644 --- a/logic/service/fight/boss/NewSeIdx_69.go +++ b/logic/service/fight/boss/NewSeIdx_69.go @@ -21,7 +21,7 @@ func (e *NewSel69) DamageAdd(t *info.DamageZone) bool { } // 检查对手性别 - if e.Ctx().Opp.CurrentPet.Gender != int(e.Args()[0].IntPart()) { + if e.Ctx().Opp.CurrentPet.Info.Gender != int(e.Args()[0].IntPart()) { return true } diff --git a/logic/service/fight/effect/effect_130.go b/logic/service/fight/effect/effect_130.go index a7fc26c4c..c79d8ab19 100644 --- a/logic/service/fight/effect/effect_130.go +++ b/logic/service/fight/effect/effect_130.go @@ -18,7 +18,7 @@ type Effect130 struct { func (e *Effect130) OnSkill() bool { // 1. 命中判定失败,不触发 - if e.Ctx().Opp.CurrentPet.PetInfo.Gender != int(e.Args()[0].IntPart()) { + if e.Ctx().Opp.CurrentPet.Info.Gender != int(e.Args()[0].IntPart()) { return true } // 4. 附加固定伤害(从SideEffectArgs[0]获取伤害值) diff --git a/logic/service/fight/effect/effect_131.go b/logic/service/fight/effect/effect_131.go index e279325d8..951ca3b4e 100644 --- a/logic/service/fight/effect/effect_131.go +++ b/logic/service/fight/effect/effect_131.go @@ -34,7 +34,7 @@ func (e *Effect131) DamageLockEx(t *info.DamageZone) bool { // 4. 对比对手性别与目标性别,匹配则免疫伤害 // 注:需确保BattlePetEntity的Gender字段类型为int/int8,与xGender类型匹配 - if int(e.Ctx().Opp.CurrentPet.Gender) == int(xGender) { + if int(e.Ctx().Opp.CurrentPet.Info.Gender) == int(xGender) { // 将伤害置为0,实现当前回合伤害免疫 t.Damage = alpacadecimal.Zero } diff --git a/logic/service/fight/effect/effect_83.go b/logic/service/fight/effect/effect_83.go index 4bb7d8ad2..efa963e32 100644 --- a/logic/service/fight/effect/effect_83.go +++ b/logic/service/fight/effect/effect_83.go @@ -35,7 +35,7 @@ func (e *Effect83) ComparePre(fattack *action.SelectSkillAction, sattack *action return true } - if e.Ctx().Our.CurrentPet.Gender != 1 { + if e.Ctx().Our.CurrentPet.Info.Gender != 1 { return true } @@ -70,7 +70,7 @@ func (e *Effect83) ActionStart(a, b *action.SelectSkillAction) bool { if e.Ctx().SkillEntity.Category() == info.Category.STATUS { return true } - if e.Ctx().Our.CurrentPet.Gender != 2 { + if e.Ctx().Our.CurrentPet.Info.Gender != 2 { return true } diff --git a/logic/service/fight/effect/effect_98.go b/logic/service/fight/effect/effect_98.go index 3138a5edf..7dc5939c7 100644 --- a/logic/service/fight/effect/effect_98.go +++ b/logic/service/fight/effect/effect_98.go @@ -25,7 +25,7 @@ type Effect98 struct { func (e *Effect98) Damage_Mul(t *info.DamageZone) bool { - if e.Ctx().Opp.CurrentPet.Gender != 1 { + if e.Ctx().Opp.CurrentPet.Info.Gender != 1 { return true } diff --git a/logic/service/fight/effect/effect_EffectConditionalAddDamage.go b/logic/service/fight/effect/effect_EffectConditionalAddDamage.go index 755a49dde..aea24cd90 100644 --- a/logic/service/fight/effect/effect_EffectConditionalAddDamage.go +++ b/logic/service/fight/effect/effect_EffectConditionalAddDamage.go @@ -95,7 +95,7 @@ func conditionIsFrozen(e *EffectConditionalAddDamage) bool { // conditionIsTypeX:判断对方是否为X属性对方为X性则附加n点伤害 func conditionIsTypeX(e *EffectConditionalAddDamage) bool { // 示例:假设Args[0]为目标属性值,判断对方属性是否匹配 - return e.Ctx().Opp.CurrentPet.PetInfo.Gender == int(e.Args()[0].IntPart()) + return e.Ctx().Opp.CurrentPet.Info.Gender == int(e.Args()[0].IntPart()) } // conditionIsAbnormal:判断对方是否处于任意异常状态 diff --git a/logic/service/fight/effect/effect_power_doblue.go b/logic/service/fight/effect/effect_power_doblue.go index bd031d72f..a364030d8 100644 --- a/logic/service/fight/effect/effect_power_doblue.go +++ b/logic/service/fight/effect/effect_power_doblue.go @@ -89,7 +89,7 @@ type Effect129 struct { } func (e *Effect129) SkillHit() bool { - if e.Ctx().Opp.CurrentPet.Gender != e.SideEffectArgs[0] { + if e.Ctx().Opp.CurrentPet.Info.Gender != e.SideEffectArgs[0] { return true } e.Ctx().SkillEntity.Power *= 2 diff --git a/logic/service/fight/input.go b/logic/service/fight/input.go index 44f034203..ac60e5012 100644 --- a/logic/service/fight/input.go +++ b/logic/service/fight/input.go @@ -170,7 +170,7 @@ func (f *FightC) initplayer(c common.PlayerI) (*input.Input, errorcode.ErrorCode // effect = int(v.Effect[0]) // } - pet := model.GenPetInfo(int(v.MonID), 24, int(v.Nature), int(v.Effect[0]), int(v.Lv), nil) + pet := model.GenPetInfo(int(v.MonID), 24, int(v.Nature), int(v.Effect[0]), int(v.Lv), nil, 0) var color data.GlowFilter err := json.Unmarshal([]byte(v.Color), &color) if err == nil { diff --git a/logic/service/player/Monster.go b/logic/service/player/Monster.go index 554baa1a4..1bf3c5068 100644 --- a/logic/service/player/Monster.go +++ b/logic/service/player/Monster.go @@ -66,9 +66,9 @@ func (p *Player) GenMonster() { lv := strings.Split(m.Lv, " ") p.OgreInfo.Data[i] = OgrePetInfo{} - p.OgreInfo.Data[i].Id = gconv.Uint32(RandomStringFromSlice(id)) + p.OgreInfo.Data[i].ID = gconv.Uint32(RandomStringFromSlice(id)) - if p.OgreInfo.Data[i].Id != 0 { + if p.OgreInfo.Data[i].ID != 0 { p.OgreInfo.Data[i].Lv = gconv.Uint32(RandomStringFromSlice(lv)) @@ -88,7 +88,7 @@ func (p *Player) GenMonster() { if cool.Config.ServerInfo.IsVip != 0 { //测试服,百分百异色 p.OgreInfo.Data[i].FixSHiny() } - if xmlres.PetMAP[int(p.OgreInfo.Data[i].Id)].CatchRate != 0 && grand.Meet(3, 1000) { + if xmlres.PetMAP[int(p.OgreInfo.Data[i].ID)].CatchRate != 0 && grand.Meet(3, 1000) { p.OgreInfo.Data[i].RandSHiny() } if ok { diff --git a/logic/service/player/player.go b/logic/service/player/player.go index 256eac053..6f9ee5771 100644 --- a/logic/service/player/player.go +++ b/logic/service/player/player.go @@ -18,6 +18,8 @@ import ( blservice "blazing/modules/player/service" "context" + "blazing/modules/config/model" + "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/util/gconv" csmap "github.com/mhmtszr/concurrent-swiss-map" @@ -28,7 +30,7 @@ import ( var Mainplayer = csmap.New[uint32, *Player]() type OgrePetInfo struct { - Id uint32 + ID uint32 ShinyLen uint32 `json:"-" struc:"sizeof=ShinyInfo"` ShinyInfo []data.GlowFilter `json:"ShinyInfo,omitempty"` Lv uint32 `struc:"skip"` //等级 @@ -37,26 +39,26 @@ type OgrePetInfo struct { } func (o *OgrePetInfo) RandSHiny() { - var co *data.GlowFilter + var co *model.ColorfulSkin if o.Ext == 0 { - co = config.NewShinyService().RandShiny(o.Id) + co = config.NewShinyService().RandShiny(o.ID) } if co != nil && len(o.ShinyInfo) == 0 { - o.ShinyInfo = append(o.ShinyInfo, *co) + o.ShinyInfo = append(o.ShinyInfo, co.Color) } } func (o *OgrePetInfo) FixSHiny() { - var co *data.GlowFilter + var co *model.ColorfulSkin if o.Ext == 0 { - co = config.NewShinyService().FixShiny(o.Id) + co = config.NewShinyService().FixShiny(o.ID) } if co != nil && len(o.ShinyInfo) == 0 { - o.ShinyInfo = append(o.ShinyInfo, *co) + o.ShinyInfo = append(o.ShinyInfo, co.Color) } } diff --git a/logic/service/task/task.go b/logic/service/task/task.go index ddaeaf51c..b8566fcd9 100644 --- a/logic/service/task/task.go +++ b/logic/service/task/task.go @@ -24,7 +24,7 @@ func GetTaskInfo(id, ot int) *TaskResult { pet := service.NewPetRewardService().Get(r.ElfRewardIds) if pet != nil { - ret.Pet = model.GenPetInfo(int(pet.MonID), int(pet.DV), int(pet.Nature), int(pet.Effect), int(pet.Lv), nil) + ret.Pet = model.GenPetInfo(int(pet.MonID), int(pet.DV), int(pet.Nature), int(pet.Effect), int(pet.Lv), nil, 0) } for _, itemID := range r.ItemRewardIds { diff --git a/modules/config/controller/admin/egg.go b/modules/config/controller/admin/egg.go new file mode 100644 index 000000000..0058b01e7 --- /dev/null +++ b/modules/config/controller/admin/egg.go @@ -0,0 +1,22 @@ +package admin + +import ( + "blazing/cool" + "blazing/modules/config/service" +) + +type EggController struct { + *cool.Controller +} + +func init() { + var task_info_controller = &EggController{ + &cool.Controller{ + Prefix: "/admin/config/egg", + Api: []string{"Add", "Delete", "Update", "Info", "List", "Page"}, + Service: service.NewEggService(), + }, + } + // 注册路由 + cool.RegisterController(task_info_controller) +} diff --git a/modules/config/model/egg.go b/modules/config/model/egg.go index 63d1382ce..1907be754 100644 --- a/modules/config/model/egg.go +++ b/modules/config/model/egg.go @@ -4,49 +4,43 @@ import ( "blazing/cool" ) -// 表名常量定义:egg配置表 const ( - TableNameeggConfig = "config_pet_egg" // egg配置表(记录egg编号、可兑换次数、奖励配置等核心信息) + TableNameEgg = "config_egg" // 性别配置表(替换原宠物融合表名) ) -// EggConfig egg核心配置模型(含可兑换次数,满足查询`where 可兑换次数 != 0`需求) -type EggConfig struct { - *cool.Model - +// Egg 性别配置模型(替换原宠物融合配方模型) +type Egg struct { + *cool.Model // 保留通用Model(ID/创建时间/更新时间等) //雄性 - - MalePet int32 `gorm:"not null;comment:'雄性宠物ID'" json:"male_pet"` + MalePetIDs []int32 `gorm:"type:int[];comment:'雄性宠物ID列表(如:[1001,1002])'" json:"male_pet_ids"` //雌性 - FemalePet int32 `gorm:"not null;comment:'雌性宠物ID'" json:"female_pet"` + FemalePetIDs []int32 `gorm:"type:int[];comment:'雌性宠物ID列表(如:[1001,1002])'" json:"female_pet_ids"` + //子代指定性别配置表名 + OutputMons []int32 `gorm:"type:int[];not null;comment:'宠物类型ID'" json:"pet_type_id"` + Probs []int32 `gorm:"type:int[];not null;comment:'对应子代宠物类型的概率(如:[50,50]表示均等概率)'" json:"probs"` - // 生成的精灵ID及对应概率 - GeneratedPetIDs []GeneratedPetID `gorm:"type:jsonb;comment:'生成的精灵ID及概率配置'" json:"generated_pet_ids"` - - Remark string `gorm:"size:512;default:'';comment:'egg备注'" json:"remark" description:"备注信息"` - //ItemGift []*ItemGift `gorm:"-" orm:"with:item_id=id"` -} -type GeneratedPetID struct { - PetID int32 `json:"pet_id" comment:"生成的精灵ID"` - Prob float64 `json:"prob" comment:"该精灵生成概率"` + IsEnable int32 `gorm:"not null;default:1;comment:'是否启用(1:启用,0:禁用)'" json:"is_enable"` // 保留原有逻辑 + Remark string `gorm:"type:varchar(255);default:'';comment:'性别配置备注(如:默认性别规则)'" json:"remark"` // 调整注释 } -// -------------------------- 核心配套方法(遵循项目规范)-------------------------- -func (*EggConfig) TableName() string { - return TableNameeggConfig +// TableName 指定性别配置表名(替换原宠物融合表名) +func (*Egg) TableName() string { + return TableNameEgg } -func (*EggConfig) GroupName() string { +// GroupName 表分组(保持原逻辑的default分组) +func (*Egg) GroupName() string { return "default" } -func NeweggConfig() *EggConfig { - return &EggConfig{ +// NewEgg 创建性别配置实例(替换原NewPetFusion) +func NewEgg() *Egg { + return &Egg{ Model: cool.NewModel(), } } -// -------------------------- 表结构自动同步 -------------------------- +// init 初始化性别配置表结构(替换原宠物融合表初始化) func init() { - - cool.CreateTable(&EggConfig{}) + cool.CreateTable(&Egg{}) } diff --git a/modules/config/model/shiny.go b/modules/config/model/shiny.go index 3d05a487a..edcd2d219 100644 --- a/modules/config/model/shiny.go +++ b/modules/config/model/shiny.go @@ -1,6 +1,7 @@ package model import ( + "blazing/common/data" "blazing/cool" ) @@ -14,7 +15,7 @@ type ColorfulSkin struct { *cool.Model // 核心必填字段 - Color string `gorm:"not null;default:'';comment:'炫彩皮肤颜色(唯一标识每条配置)'" json:"color" description:"炫彩皮肤颜色"` + Color data.GlowFilter `gorm:"type:jsonb;not null;;comment:'炫彩皮肤颜色(唯一标识每条配置)'" json:"color" description:"炫彩皮肤颜色"` IsEnabled uint32 `gorm:"not null;default:1;comment:'是否启用(0-禁用 1-启用)'" json:"is_enabled" description:"是否启用"` Author string `gorm:"not null;size:64;default:'';comment:'炫彩皮肤配置作者(创建人/配置者名称)'" json:"author" description:"作者"` @@ -42,15 +43,6 @@ func (*ColorfulSkin) GroupName() string { func NewColorfulSkin() *ColorfulSkin { return &ColorfulSkin{ Model: cool.NewModel(), - Color: "", - - IsEnabled: 1, - Author: "", - RefreshCount: 0, - UsageCount: 0, - BindElfIds: []uint32{}, - - Remark: "", } } diff --git a/modules/config/service/egg.go b/modules/config/service/egg.go new file mode 100644 index 000000000..519833420 --- /dev/null +++ b/modules/config/service/egg.go @@ -0,0 +1,32 @@ +package service + +import ( + "blazing/cool" + "blazing/modules/config/model" +) + +type EggService struct { + *cool.Service +} + +func NewEggService() *EggService { + return &EggService{ + &cool.Service{ + Model: model.NewEgg(), + PageQueryOp: &cool.QueryOp{ + KeyWordField: []string{"desc"}, + }, + }, + } +} + +func (s *EggService) Get(id uint32) *model.Egg { + if id == 0 { + return nil + } + var item *model.Egg + dbm(s.Model).Where("id", id).Scan(&item) + + return item + +} diff --git a/modules/config/service/shiny.go b/modules/config/service/shiny.go index 7f54269e4..759a5b88b 100644 --- a/modules/config/service/shiny.go +++ b/modules/config/service/shiny.go @@ -42,7 +42,7 @@ func (s *ShinyService) ModifyBefore(ctx context.Context, method string, param g. } return nil } -func (s *ShinyService) RandShiny(id uint32) *data.GlowFilter { +func (s *ShinyService) RandShiny(id uint32) *model.ColorfulSkin { var ret []model.ColorfulSkin // 执行 Raw SQL 并扫描返回值 @@ -57,24 +57,20 @@ func (s *ShinyService) RandShiny(id uint32) *data.GlowFilter { id := v.ID if grand.Meet(int(v.ElfProbability), 1000) { - var t data.GlowFilter - r := json.Unmarshal([]byte(v.Color), &t) - if r == nil { - if cool.Config.ServerInfo.IsVip == 0 { - m := cool.DBM(s.Model).Where("id", id) - m.Increment("refresh_count", 1) - } - - return &t + if cool.Config.ServerInfo.IsVip == 0 { + m := cool.DBM(s.Model).Where("id", id) + m.Increment("refresh_count", 1) } + return &v + } } return nil } -func (s *ShinyService) FixShiny(id uint32) *data.GlowFilter { +func (s *ShinyService) FixShiny(id uint32) *model.ColorfulSkin { var ret []model.ColorfulSkin // 执行 Raw SQL 并扫描返回值 @@ -87,17 +83,26 @@ func (s *ShinyService) FixShiny(id uint32) *data.GlowFilter { } v := ret[grand.Intn(len(ret))] - var t data.GlowFilter - - r := json.Unmarshal([]byte(v.Color), &t) - if r == nil { - if cool.Config.ServerInfo.IsVip == 0 { - m := cool.DBM(s.Model).Where("id", v.ID) - m.Increment("usage_count", 1) - } - - return &t + 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) GetShiny(id int) *data.GlowFilter { + var ret []model.ColorfulSkin + + // 执行 Raw SQL 并扫描返回值 + dbm(s.Model). + Where("id", id).Scan(&ret) + if len(ret) == 0 { + return nil + } + v := ret[grand.Intn(len(ret))] + + return &v.Color + return nil } diff --git a/modules/player/controller/admin/monster_get.go b/modules/player/controller/admin/monster_get.go index 9c1ca7ad2..75ea16cfd 100644 --- a/modules/player/controller/admin/monster_get.go +++ b/modules/player/controller/admin/monster_get.go @@ -41,7 +41,7 @@ func (c *PetBagController) GetSession(ctx context.Context, req *PetGetReq) (res //r = g.RequestFromCtx(ctx) ) t := model.GenPetInfo( - req.PetTypeId, req.IndividualValue, req.NatureId, req.AbilityTypeEnum, req.Level, nil) + req.PetTypeId, req.IndividualValue, req.NatureId, req.AbilityTypeEnum, req.Level, nil, -1) t.FixShiny() service.NewUserService(uint32(admin.UserId)).Pet.PetAdd(t) diff --git a/modules/player/model/pet.go b/modules/player/model/pet.go index a9ba48a1d..fdbbaa372 100644 --- a/modules/player/model/pet.go +++ b/modules/player/model/pet.go @@ -49,9 +49,11 @@ type PetInfo struct { ID uint32 `fieldDesc:"精灵编号" ` // 名字:默认为全0,补齐到16字节(固定长度 → [16]byte) - Name string `struc:"[16]byte" json:"Name,omitempty"` + Name string `struc:"[16]byte" json:"Name,omitempty"` + Gender int `struc:"uint16" fieldDesc:"性别" ` //generation - Generation uint32 `fieldDesc:"世代" ` + + Generation uint16 `fieldDesc:"世代" ` // 个体值(@UInt long → uint32) Dv uint32 `struc:"uint32" ` @@ -101,13 +103,13 @@ type PetInfo struct { CatchLevel uint32 `fieldDesc:"捕获等级 默认为0" ` EffectInfoLen uint16 `struc:"sizeof=EffectInfo" json:"-"` // 特性列表:长度用UShort存储(变长List → []PetEffectInfo + 长度前缀规则) 第一个一定是特性 - EffectInfo []PetEffectInfo `fieldDesc:"特性列表, 长度在头部以UShort存储" serialize:"lengthFirst,lengthType=uint16,type=structArray"` + EffectInfo []PetEffectInfo // 皮肤ID默认0(@UInt long → uint32) SkinID uint32 `fieldDesc:"皮肤id默认为0" ` // 是否闪光(@UInt long → uint32,0=否,1=是) - ShinyLen uint32 `json:"-" struc:"sizeof=ShinyInfo"` + ShinyLen uint32 `struc:"sizeof=ShinyInfo"` ShinyInfo []data.GlowFilter `json:"ShinyInfo,omitempty"` //时间轮转,然后effect根据type同时只共存一个,特性是1 特质是1,柱子是两种,魂印是一个,然后异色字段,然后特训技能字段 @@ -214,7 +216,7 @@ func (pet *PetInfo) RandShiny() { co := service.NewShinyService().RandShiny(pet.ID) if co != nil { - pet.ShinyInfo = append(pet.ShinyInfo, *co) + pet.ShinyInfo = append(pet.ShinyInfo, *&co.Color) } //o.ShinyInfo[0].ColorMatrixFilter = GenerateRandomOffspringMatrix().Get() //g.Dump(ttt.ShinyInfo) @@ -224,7 +226,7 @@ func (pet *PetInfo) FixShiny() { co := service.NewShinyService().FixShiny(pet.ID) if co != nil { - pet.ShinyInfo = append(pet.ShinyInfo, *co) + pet.ShinyInfo = append(pet.ShinyInfo, *&co.Color) } //o.ShinyInfo[0].ColorMatrixFilter = GenerateRandomOffspringMatrix().Get() //g.Dump(ttt.ShinyInfo) @@ -418,6 +420,7 @@ func init() { func GenPetInfo( id int, dv, natureId, abilityTypeEnum, level int, shinyid []data.GlowFilter, + gen int, ) *PetInfo { // 创建随机源 //rng := rand.New(rand.NewSource(time.Now().UnixNano())) @@ -434,8 +437,21 @@ func GenPetInfo( if shinyid != nil { //todo 待实现异色字段 p.ShinyInfo = shinyid + // r := service.NewShinyService().GetShiny(shinyid) + // if r != nil { + // p.ShinyInfo = append(p.ShinyInfo, *r) + // } + // p.Shiny = uint32(shinyid) } + if gen == -1 { + + p.Gender = grand.N(1, 4) + if p.Gender == 3 || p.Gender == 4 { + p.Gender = 0 + + } + } // ---- 性格 ---- if natureId == -1 {