1
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful

This commit is contained in:
昔念
2026-02-08 17:57:42 +08:00
parent 2edd1ba852
commit ffe3ff18bf
25 changed files with 180 additions and 117 deletions

View File

@@ -15,28 +15,28 @@ type LearnableMoves struct {
// PetInfo 表示一个怪物的信息 // PetInfo 表示一个怪物的信息
type PetInfo struct { type PetInfo struct {
ID int `xml:"ID,attr"` ID int `xml:"ID,attr"`
DefName string `xml:"DefName,attr"` // 名字 DefName string `xml:"DefName,attr"` // 名字
Type int `xml:"Type,attr"` // 类型 Type int `xml:"Type,attr"` // 类型
IsLarge int `xml:"IsLarge,attr"` // 是否为大型怪物 IsLarge int `xml:"IsLarge,attr"` // 是否为大型怪物
GrowthType int `xml:"GrowthType,attr"` // 成长类型 GrowthType int `xml:"GrowthType,attr"` // 成长类型
HP int `xml:"HP,attr"` // 血量种族值 HP int `xml:"HP,attr"` // 血量种族值
Atk uint32 `xml:"Atk,attr"` // 攻击种族值 Atk uint32 `xml:"Atk,attr"` // 攻击种族值
Def uint32 `xml:"Def,attr"` // 防御种族值 Def uint32 `xml:"Def,attr"` // 防御种族值
SpAtk uint32 `xml:"SpAtk,attr"` // 特殊攻击种族值 SpAtk uint32 `xml:"SpAtk,attr"` // 特殊攻击种族值
SpDef uint32 `xml:"SpDef,attr"` // 特殊防御种族值 SpDef uint32 `xml:"SpDef,attr"` // 特殊防御种族值
Spd uint32 `xml:"Spd,attr"` // 速度种族值 Spd uint32 `xml:"Spd,attr"` // 速度种族值
YieldingExp int `xml:"YieldingExp,attr"` // 击败后获得的经验值 YieldingExp int `xml:"YieldingExp,attr"` // 击败后获得的经验值
CatchRate int `xml:"CatchRate,attr"` // 捕捉率 CatchRate int `xml:"CatchRate,attr"` // 捕捉率
YieldingEV string `xml:"YieldingEV,attr"` // 努力值奖励,格式为"HP Atk Def SpAtk SpDef Spd" YieldingEV string `xml:"YieldingEV,attr"` // 努力值奖励,格式为"HP Atk Def SpAtk SpDef Spd"
EvolvesFrom int `xml:"EvolvesFrom,attr"` // 进化前的怪物ID EvolvesFrom int `xml:"EvolvesFrom,attr"` // 进化前的怪物ID
EvolvesTo uint32 `xml:"EvolvesTo,attr"` // 进化后的怪物ID EvolvesTo uint32 `xml:"EvolvesTo,attr"` // 进化后的怪物ID
EvolvFlag int `xml:"EvolvFlag,attr"` //<!-- EvolvFlag: 0 - 直接进化(等级到了就进化); 1~49 - 触发进化,默认值: 0 (默认直接进化) --> EvolvFlag int `xml:"EvolvFlag,attr"` //<!-- EvolvFlag: 0 - 直接进化(等级到了就进化); 1~49 - 触发进化,默认值: 0 (默认直接进化) -->
EvolvingLv int `xml:"EvolvingLv,attr"` // 进化等级 EvolvingLv int `xml:"EvolvingLv,attr"` // 进化等级
FreeForbidden int `xml:"FreeForbidden,attr"` // 是否禁止放生 FreeForbidden int `xml:"FreeForbidden,attr"` // 是否禁止放生
FuseMaster int `xml:"FuseMaster,attr"` // 是否可作为融合主素材 FuseMaster int `xml:"FuseMaster,attr"` // 是否可作为融合主素材
FuseSub int `xml:"FuseSub,attr"` // 是否可作为融合副素材 FuseSub int `xml:"FuseSub,attr"` // 是否可作为融合副素材
Gender int `xml:"Gender,attr"` // 性别 0-无性别 1-雄性 2-雌性 // Gender int `xml:"Gender,attr"` // 性别 0-无性别 1-雄性 2-雌性
PetClass int `xml:"PetClass,attr"` // 宠物类别 PetClass int `xml:"PetClass,attr"` // 宠物类别
FormParam float64 `xml:"FormParam,attr"` // 形态参数 FormParam float64 `xml:"FormParam,attr"` // 形态参数
CharacterAttrParam int `xml:"CharacterAttrParam,attr"` // 特性参数 CharacterAttrParam int `xml:"CharacterAttrParam,attr"` // 特性参数

View File

@@ -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{}} result = &egg.S2C_EGG_GAME_PLAY{ListInfo: []data.ItemInfo{}}
if grand.Meet(int(data1.EggNum), 100) { if grand.Meet(int(data1.EggNum), 100) {
r := service.NewPetRewardService().GetEgg() 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) { if grand.Meet(int(data1.EggNum), 100) {
newPet.RandShiny() newPet.RandShiny()
} }

View File

@@ -87,7 +87,7 @@ func (Controller) PlayerFightBoss(data *fight.ChallengeBossInboundInfo, p *playe
-1, -1,
0, //野怪没特性 0, //野怪没特性
bm.Lv, nil) bm.Lv, nil, 0)
monster.CatchTime = uint32(i) monster.CatchTime = uint32(i)
if bm.Hp != 0 { if bm.Hp != 0 {
monster.Hp = uint32(bm.Hp) monster.Hp = uint32(bm.Hp)
@@ -158,21 +158,21 @@ func (Controller) OnPlayerFightNpcMonster(data1 *fight.FightNpcMonsterInboundInf
return nil, errorcode.ErrorCodes.ErrSystemError return nil, errorcode.ErrorCodes.ErrSystemError
} }
refPet := p.OgreInfo.Data[data1.Number] refPet := p.OgreInfo.Data[data1.Number]
if refPet.Id == 0 { if refPet.ID == 0 {
return nil, errorcode.ErrorCodes.ErrPokemonNotExists return nil, errorcode.ErrorCodes.ErrPokemonNotExists
} }
if refPet.Ext != 0 { if refPet.Ext != 0 {
refPet.Id = refPet.Ext refPet.ID = refPet.Ext
} }
monster := model.GenPetInfo( monster := model.GenPetInfo(
int(refPet.Id), -1, int(refPet.ID), -1,
-1, -1,
0, //野怪没特性 0, //野怪没特性
int(refPet.Lv), int(refPet.Lv),
refPet.ShinyInfo) refPet.ShinyInfo, -1)
if refPet.Ext != 0 { if refPet.Ext != 0 {
if grand.Meet(3, 100) { if grand.Meet(3, 100) {
monster.RandShiny() monster.RandShiny()

View File

@@ -140,7 +140,7 @@ func (h Controller) PetTawor(data *fight.StartTwarInboundInfo, c *player.Player)
r := service.NewBossService().Get(v) r := service.NewBossService().Get(v)
if r != nil { 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 { if r.Hp != 0 {
monster.Hp = uint32(r.Hp) monster.Hp = uint32(r.Hp)
monster.MaxHp = uint32(r.Hp) monster.MaxHp = uint32(r.Hp)

View File

@@ -53,7 +53,7 @@ func (h Controller) Collect(
} }
c.Info.SetTask(1335+int(data.Type), model.Completed) 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) c.Service.Pet.PetAdd(r)
result.CatchTime = r.CatchTime result.CatchTime = r.CatchTime

View File

@@ -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))) 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))) dv2 := alpacadecimal.NewFromInt(1).Div(alpacadecimal.NewFromInt(3)).Mul(alpacadecimal.NewFromInt(int64(Auxpetinfo.Dv)))
dv := dv1.Add(dv2).Add(alpacadecimal.NewFromInt(1)).IntPart() 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 r.OldCatchTime = Mcatchpetinfo.CatchTime
shinycont := 1 shinycont := 1

View File

@@ -31,7 +31,7 @@ func (h Controller) CDK(data *user.C2S_GET_GIFT_COMPLETE, player *player.Player)
for _, v := range r.ElfRewardIds { for _, v := range r.ElfRewardIds {
pet := service.NewPetRewardService().Get(v) pet := service.NewPetRewardService().Get(v)
if pet != nil { 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) player.Service.Pet.PetAdd(peti)
result.PetGift = append(result.PetGift, user.PetGiftInfo{PetID: peti.ID, CacthTime: peti.CatchTime}) result.PetGift = append(result.PetGift, user.PetGiftInfo{PetID: peti.ID, CacthTime: peti.CatchTime})
} }

View File

@@ -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 return true
} }

View File

@@ -18,7 +18,7 @@ type Effect130 struct {
func (e *Effect130) OnSkill() bool { func (e *Effect130) OnSkill() bool {
// 1. 命中判定失败,不触发 // 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 return true
} }
// 4. 附加固定伤害从SideEffectArgs[0]获取伤害值) // 4. 附加固定伤害从SideEffectArgs[0]获取伤害值)

View File

@@ -34,7 +34,7 @@ func (e *Effect131) DamageLockEx(t *info.DamageZone) bool {
// 4. 对比对手性别与目标性别,匹配则免疫伤害 // 4. 对比对手性别与目标性别,匹配则免疫伤害
// 注需确保BattlePetEntity的Gender字段类型为int/int8与xGender类型匹配 // 注需确保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实现当前回合伤害免疫 // 将伤害置为0实现当前回合伤害免疫
t.Damage = alpacadecimal.Zero t.Damage = alpacadecimal.Zero
} }

View File

@@ -35,7 +35,7 @@ func (e *Effect83) ComparePre(fattack *action.SelectSkillAction, sattack *action
return true return true
} }
if e.Ctx().Our.CurrentPet.Gender != 1 { if e.Ctx().Our.CurrentPet.Info.Gender != 1 {
return true return true
} }
@@ -70,7 +70,7 @@ func (e *Effect83) ActionStart(a, b *action.SelectSkillAction) bool {
if e.Ctx().SkillEntity.Category() == info.Category.STATUS { if e.Ctx().SkillEntity.Category() == info.Category.STATUS {
return true return true
} }
if e.Ctx().Our.CurrentPet.Gender != 2 { if e.Ctx().Our.CurrentPet.Info.Gender != 2 {
return true return true
} }

View File

@@ -25,7 +25,7 @@ type Effect98 struct {
func (e *Effect98) Damage_Mul(t *info.DamageZone) bool { 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 return true
} }

View File

@@ -95,7 +95,7 @@ func conditionIsFrozen(e *EffectConditionalAddDamage) bool {
// conditionIsTypeX判断对方是否为X属性对方为X性则附加n点伤害 // conditionIsTypeX判断对方是否为X属性对方为X性则附加n点伤害
func conditionIsTypeX(e *EffectConditionalAddDamage) bool { func conditionIsTypeX(e *EffectConditionalAddDamage) bool {
// 示例假设Args[0]为目标属性值,判断对方属性是否匹配 // 示例假设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判断对方是否处于任意异常状态 // conditionIsAbnormal判断对方是否处于任意异常状态

View File

@@ -89,7 +89,7 @@ type Effect129 struct {
} }
func (e *Effect129) SkillHit() bool { 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 return true
} }
e.Ctx().SkillEntity.Power *= 2 e.Ctx().SkillEntity.Power *= 2

View File

@@ -170,7 +170,7 @@ func (f *FightC) initplayer(c common.PlayerI) (*input.Input, errorcode.ErrorCode
// effect = int(v.Effect[0]) // 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 var color data.GlowFilter
err := json.Unmarshal([]byte(v.Color), &color) err := json.Unmarshal([]byte(v.Color), &color)
if err == nil { if err == nil {

View File

@@ -66,9 +66,9 @@ func (p *Player) GenMonster() {
lv := strings.Split(m.Lv, " ") lv := strings.Split(m.Lv, " ")
p.OgreInfo.Data[i] = OgrePetInfo{} 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)) p.OgreInfo.Data[i].Lv = gconv.Uint32(RandomStringFromSlice(lv))
@@ -88,7 +88,7 @@ func (p *Player) GenMonster() {
if cool.Config.ServerInfo.IsVip != 0 { //测试服,百分百异色 if cool.Config.ServerInfo.IsVip != 0 { //测试服,百分百异色
p.OgreInfo.Data[i].FixSHiny() 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() p.OgreInfo.Data[i].RandSHiny()
} }
if ok { if ok {

View File

@@ -18,6 +18,8 @@ import (
blservice "blazing/modules/player/service" blservice "blazing/modules/player/service"
"context" "context"
"blazing/modules/config/model"
"github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/util/gconv" "github.com/gogf/gf/v2/util/gconv"
csmap "github.com/mhmtszr/concurrent-swiss-map" csmap "github.com/mhmtszr/concurrent-swiss-map"
@@ -28,7 +30,7 @@ import (
var Mainplayer = csmap.New[uint32, *Player]() var Mainplayer = csmap.New[uint32, *Player]()
type OgrePetInfo struct { type OgrePetInfo struct {
Id uint32 ID uint32
ShinyLen uint32 `json:"-" struc:"sizeof=ShinyInfo"` ShinyLen uint32 `json:"-" struc:"sizeof=ShinyInfo"`
ShinyInfo []data.GlowFilter `json:"ShinyInfo,omitempty"` ShinyInfo []data.GlowFilter `json:"ShinyInfo,omitempty"`
Lv uint32 `struc:"skip"` //等级 Lv uint32 `struc:"skip"` //等级
@@ -37,26 +39,26 @@ type OgrePetInfo struct {
} }
func (o *OgrePetInfo) RandSHiny() { func (o *OgrePetInfo) RandSHiny() {
var co *data.GlowFilter var co *model.ColorfulSkin
if o.Ext == 0 { if o.Ext == 0 {
co = config.NewShinyService().RandShiny(o.Id) co = config.NewShinyService().RandShiny(o.ID)
} }
if co != nil && len(o.ShinyInfo) == 0 { if co != nil && len(o.ShinyInfo) == 0 {
o.ShinyInfo = append(o.ShinyInfo, *co) o.ShinyInfo = append(o.ShinyInfo, co.Color)
} }
} }
func (o *OgrePetInfo) FixSHiny() { func (o *OgrePetInfo) FixSHiny() {
var co *data.GlowFilter var co *model.ColorfulSkin
if o.Ext == 0 { if o.Ext == 0 {
co = config.NewShinyService().FixShiny(o.Id) co = config.NewShinyService().FixShiny(o.ID)
} }
if co != nil && len(o.ShinyInfo) == 0 { if co != nil && len(o.ShinyInfo) == 0 {
o.ShinyInfo = append(o.ShinyInfo, *co) o.ShinyInfo = append(o.ShinyInfo, co.Color)
} }
} }

View File

@@ -24,7 +24,7 @@ func GetTaskInfo(id, ot int) *TaskResult {
pet := service.NewPetRewardService().Get(r.ElfRewardIds) pet := service.NewPetRewardService().Get(r.ElfRewardIds)
if pet != nil { 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 { for _, itemID := range r.ItemRewardIds {

View File

@@ -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)
}

View File

@@ -4,49 +4,43 @@ import (
"blazing/cool" "blazing/cool"
) )
// 表名常量定义egg配置表
const ( const (
TableNameeggConfig = "config_pet_egg" // egg配置表(记录egg编号、可兑换次数、奖励配置等核心信息 TableNameEgg = "config_egg" // 性别配置表(替换原宠物融合表名
) )
// EggConfig egg核心配置模型含可兑换次数满足查询`where 可兑换次数 != 0`需求 // Egg 性别配置模型(替换原宠物融合配方模型
type EggConfig struct { type Egg struct {
*cool.Model *cool.Model // 保留通用ModelID/创建时间/更新时间等)
//雄性 //雄性
MalePetIDs []int32 `gorm:"type:int[];comment:'雄性宠物ID列表[1001,1002]'" json:"male_pet_ids"`
MalePet int32 `gorm:"not null;comment:'雄性宠物ID'" json:"male_pet"`
//雌性 //雌性
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及对应概率 IsEnable int32 `gorm:"not null;default:1;comment:'是否启用1:启用0:禁用)'" json:"is_enable"` // 保留原有逻辑
GeneratedPetIDs []GeneratedPetID `gorm:"type:jsonb;comment:'生成的精灵ID及概率配置'" json:"generated_pet_ids"` Remark string `gorm:"type:varchar(255);default:'';comment:'性别配置备注(如:默认性别规则)'" json:"remark"` // 调整注释
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:"该精灵生成概率"`
} }
// -------------------------- 核心配套方法(遵循项目规范)-------------------------- // TableName 指定性别配置表名(替换原宠物融合表名)
func (*EggConfig) TableName() string { func (*Egg) TableName() string {
return TableNameeggConfig return TableNameEgg
} }
func (*EggConfig) GroupName() string { // GroupName 表分组保持原逻辑的default分组
func (*Egg) GroupName() string {
return "default" return "default"
} }
func NeweggConfig() *EggConfig { // NewEgg 创建性别配置实例替换原NewPetFusion
return &EggConfig{ func NewEgg() *Egg {
return &Egg{
Model: cool.NewModel(), Model: cool.NewModel(),
} }
} }
// -------------------------- 表结构自动同步 -------------------------- // init 初始化性别配置表结构(替换原宠物融合表初始化)
func init() { func init() {
cool.CreateTable(&Egg{})
cool.CreateTable(&EggConfig{})
} }

View File

@@ -1,6 +1,7 @@
package model package model
import ( import (
"blazing/common/data"
"blazing/cool" "blazing/cool"
) )
@@ -14,7 +15,7 @@ type ColorfulSkin struct {
*cool.Model *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:"是否启用"` 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:"作者"` Author string `gorm:"not null;size:64;default:'';comment:'炫彩皮肤配置作者(创建人/配置者名称)'" json:"author" description:"作者"`
@@ -42,15 +43,6 @@ func (*ColorfulSkin) GroupName() string {
func NewColorfulSkin() *ColorfulSkin { func NewColorfulSkin() *ColorfulSkin {
return &ColorfulSkin{ return &ColorfulSkin{
Model: cool.NewModel(), Model: cool.NewModel(),
Color: "",
IsEnabled: 1,
Author: "",
RefreshCount: 0,
UsageCount: 0,
BindElfIds: []uint32{},
Remark: "",
} }
} }

View File

@@ -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
}

View File

@@ -42,7 +42,7 @@ func (s *ShinyService) ModifyBefore(ctx context.Context, method string, param g.
} }
return nil return nil
} }
func (s *ShinyService) RandShiny(id uint32) *data.GlowFilter { func (s *ShinyService) RandShiny(id uint32) *model.ColorfulSkin {
var ret []model.ColorfulSkin var ret []model.ColorfulSkin
// 执行 Raw SQL 并扫描返回值 // 执行 Raw SQL 并扫描返回值
@@ -57,24 +57,20 @@ func (s *ShinyService) RandShiny(id uint32) *data.GlowFilter {
id := v.ID id := v.ID
if grand.Meet(int(v.ElfProbability), 1000) { if grand.Meet(int(v.ElfProbability), 1000) {
var t data.GlowFilter
r := json.Unmarshal([]byte(v.Color), &t) if cool.Config.ServerInfo.IsVip == 0 {
if r == nil { m := cool.DBM(s.Model).Where("id", id)
if cool.Config.ServerInfo.IsVip == 0 { m.Increment("refresh_count", 1)
m := cool.DBM(s.Model).Where("id", id)
m.Increment("refresh_count", 1)
}
return &t
} }
return &v
} }
} }
return nil return nil
} }
func (s *ShinyService) FixShiny(id uint32) *data.GlowFilter { func (s *ShinyService) FixShiny(id uint32) *model.ColorfulSkin {
var ret []model.ColorfulSkin var ret []model.ColorfulSkin
// 执行 Raw SQL 并扫描返回值 // 执行 Raw SQL 并扫描返回值
@@ -87,17 +83,26 @@ func (s *ShinyService) FixShiny(id uint32) *data.GlowFilter {
} }
v := ret[grand.Intn(len(ret))] v := ret[grand.Intn(len(ret))]
var t data.GlowFilter if cool.Config.ServerInfo.IsVip == 0 {
m := cool.DBM(s.Model).Where("id", v.ID)
r := json.Unmarshal([]byte(v.Color), &t) m.Increment("usage_count", 1)
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
} }
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 return nil
} }

View File

@@ -41,7 +41,7 @@ func (c *PetBagController) GetSession(ctx context.Context, req *PetGetReq) (res
//r = g.RequestFromCtx(ctx) //r = g.RequestFromCtx(ctx)
) )
t := model.GenPetInfo( 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() t.FixShiny()
service.NewUserService(uint32(admin.UserId)).Pet.PetAdd(t) service.NewUserService(uint32(admin.UserId)).Pet.PetAdd(t)

View File

@@ -49,9 +49,11 @@ type PetInfo struct {
ID uint32 `fieldDesc:"精灵编号" ` ID uint32 `fieldDesc:"精灵编号" `
// 名字默认为全0补齐到16字节固定长度 → [16]byte // 名字默认为全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
Generation uint32 `fieldDesc:"世代" `
Generation uint16 `fieldDesc:"世代" `
// 个体值(@UInt long → uint32 // 个体值(@UInt long → uint32
Dv uint32 `struc:"uint32" ` Dv uint32 `struc:"uint32" `
@@ -101,13 +103,13 @@ type PetInfo struct {
CatchLevel uint32 `fieldDesc:"捕获等级 默认为0" ` CatchLevel uint32 `fieldDesc:"捕获等级 默认为0" `
EffectInfoLen uint16 `struc:"sizeof=EffectInfo" json:"-"` EffectInfoLen uint16 `struc:"sizeof=EffectInfo" json:"-"`
// 特性列表长度用UShort存储变长List → []PetEffectInfo + 长度前缀规则) 第一个一定是特性 // 特性列表长度用UShort存储变长List → []PetEffectInfo + 长度前缀规则) 第一个一定是特性
EffectInfo []PetEffectInfo `fieldDesc:"特性列表, 长度在头部以UShort存储" serialize:"lengthFirst,lengthType=uint16,type=structArray"` EffectInfo []PetEffectInfo
// 皮肤ID默认0@UInt long → uint32 // 皮肤ID默认0@UInt long → uint32
SkinID uint32 `fieldDesc:"皮肤id默认为0" ` SkinID uint32 `fieldDesc:"皮肤id默认为0" `
// 是否闪光(@UInt long → uint320=否1=是) // 是否闪光(@UInt long → uint320=否1=是)
ShinyLen uint32 `json:"-" struc:"sizeof=ShinyInfo"` ShinyLen uint32 `struc:"sizeof=ShinyInfo"`
ShinyInfo []data.GlowFilter `json:"ShinyInfo,omitempty"` ShinyInfo []data.GlowFilter `json:"ShinyInfo,omitempty"`
//时间轮转然后effect根据type同时只共存一个特性是1 特质是1柱子是两种魂印是一个然后异色字段然后特训技能字段 //时间轮转然后effect根据type同时只共存一个特性是1 特质是1柱子是两种魂印是一个然后异色字段然后特训技能字段
@@ -214,7 +216,7 @@ func (pet *PetInfo) RandShiny() {
co := service.NewShinyService().RandShiny(pet.ID) co := service.NewShinyService().RandShiny(pet.ID)
if co != nil { if co != nil {
pet.ShinyInfo = append(pet.ShinyInfo, *co) pet.ShinyInfo = append(pet.ShinyInfo, *&co.Color)
} }
//o.ShinyInfo[0].ColorMatrixFilter = GenerateRandomOffspringMatrix().Get() //o.ShinyInfo[0].ColorMatrixFilter = GenerateRandomOffspringMatrix().Get()
//g.Dump(ttt.ShinyInfo) //g.Dump(ttt.ShinyInfo)
@@ -224,7 +226,7 @@ func (pet *PetInfo) FixShiny() {
co := service.NewShinyService().FixShiny(pet.ID) co := service.NewShinyService().FixShiny(pet.ID)
if co != nil { if co != nil {
pet.ShinyInfo = append(pet.ShinyInfo, *co) pet.ShinyInfo = append(pet.ShinyInfo, *&co.Color)
} }
//o.ShinyInfo[0].ColorMatrixFilter = GenerateRandomOffspringMatrix().Get() //o.ShinyInfo[0].ColorMatrixFilter = GenerateRandomOffspringMatrix().Get()
//g.Dump(ttt.ShinyInfo) //g.Dump(ttt.ShinyInfo)
@@ -418,6 +420,7 @@ func init() {
func GenPetInfo( func GenPetInfo(
id int, id int,
dv, natureId, abilityTypeEnum, level int, shinyid []data.GlowFilter, dv, natureId, abilityTypeEnum, level int, shinyid []data.GlowFilter,
gen int,
) *PetInfo { ) *PetInfo {
// 创建随机源 // 创建随机源
//rng := rand.New(rand.NewSource(time.Now().UnixNano())) //rng := rand.New(rand.NewSource(time.Now().UnixNano()))
@@ -434,8 +437,21 @@ func GenPetInfo(
if shinyid != nil { if shinyid != nil {
//todo 待实现异色字段 //todo 待实现异色字段
p.ShinyInfo = shinyid p.ShinyInfo = shinyid
// r := service.NewShinyService().GetShiny(shinyid)
// if r != nil {
// p.ShinyInfo = append(p.ShinyInfo, *r)
// }
// p.Shiny = uint32(shinyid) // 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 { if natureId == -1 {