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

feat(pet): 宠物系统重构和功能增强

- 修复战斗boss中effect ID索引错误问题
- 实现宠物仓库和背包管理功能
- 添加宠物列表排序保存功能
- 重构宠物备份列表同步逻辑
- 优化宠物释放和获取逻辑
- 添加宠物背包仓库切换功能
- 修复地图模型广播信息结构问题
- 调整宠物特效数据库查询逻辑
```
This commit is contained in:
昔念
2026-04-02 07:49:49 +08:00
parent 3a13bcc99c
commit f810a2ae86
13 changed files with 280 additions and 43 deletions

View File

@@ -12,8 +12,6 @@ const TableNamePlayerPetSpecialEffect = "config_boss_effect"
type PlayerPetSpecialEffect struct {
*cool.Model // 嵌入基础Model包含主键、创建/更新时间等通用字段)
// 严格对应XML的4个核心字段
SeIdx uint32 `gorm:"not null;uniqueIndex:idx_se_idx;comment:'精灵特效索引XML中的Idx'" json:"se_idx"`
//Stat uint32 `gorm:"not null;default:0;comment:'精灵特效状态XML中的Stat'" json:"stat"`
Eid uint32 `gorm:"not null;index:idx_eid;comment:'精灵特效EidXML中的Eid'" json:"eid"`
Args []int `gorm:"type:jsonb;comment:'精灵特效参数XML中的Args'" json:"args"`

View File

@@ -1,4 +1,4 @@
package model
package model
import (
"blazing/cool"
@@ -6,7 +6,7 @@ import (
// 表名统一改为 map_model
const (
TableNameMapModel = "map_model"
TableNameMapModel = "config_map_model"
)
// 模型类型常量 (0:精灵, 1:NPC)
@@ -26,7 +26,7 @@ const (
MapModelDirectionRightUp
)
// MapModel 地图模型配置表(NPC/宠物)
// MapModel 地图模型配置表 (NPC/宠物)
type MapModel struct {
*cool.Model // 保留通用ModelID/创建时间/更新时间等)
@@ -41,6 +41,7 @@ type MapModel struct {
HeadTalk string `gorm:"type:varchar(255);default:'';comment:'头顶对话框内容'" json:"head_talk" description:"头顶对话框内容"`
Pos string `gorm:"type:varchar(255);default:'';comment:'位置'" json:"pos" description:"位置"`
HP int32 `gorm:"type:int;default:0;comment:'血量'" json:"hp" description:"血量"`
Scale float64 `gorm:"type:decimal(6,2);default:1.00;comment:'缩放倍数'" json:"scale" description:"缩放倍数"`
Direction int32 `gorm:"type:int;default:2;comment:'方向(0-7)'" json:"direction" description:"BOSS方向"`
TriggerPlotID uint32 `gorm:"default:0;comment:'触发剧情ID0表示无剧情'" json:"trigger_plot_id" description:"触发剧情ID"`
Cloths []uint32 `gorm:"type:varchar(255);default:'';comment:'服装'" json:"cloths" description:"服装"`

View File

@@ -10,7 +10,7 @@ type EffectService struct {
}
func (s *EffectService) Args(id []uint32) []model.PlayerPetSpecialEffect {
m := dbm_notenable(s.Model).WhereIn("se_idx", id)
m := dbm_notenable(s.Model).WhereIn("id", id)
var tt []model.PlayerPetSpecialEffect
m.Scan(&tt)
@@ -21,8 +21,8 @@ func NewEffectService() *EffectService {
return &EffectService{
&cool.Service{
Model: model.NewPlayerPetSpecialEffect(),
UniqueKey: map[string]string{"idx_se_idx": "索引不能重复"},
Model: model.NewPlayerPetSpecialEffect(),
PageQueryOp: &cool.QueryOp{
KeyWordField: []string{"desc"},
},

View File

@@ -21,6 +21,10 @@ func NewMapmodelService() *MapmodelService {
KeyWordField: []string{"remake"},
FieldEQ: []string{"map_id"},
},
ListQueryOp: &cool.QueryOp{
KeyWordField: []string{"remake"},
FieldEQ: []string{"map_id"},
},
},
}
}

View File

@@ -205,8 +205,8 @@ type PlayerInfo struct {
Badge uint32 `struc:"uint32" default:"0" json:"badge"` // 默认0
Reserved1 [27]byte `struc:"[27]byte" default:"3" json:"reserved1"` // 27字节默认3
TaskList [1000]byte `struc:"[1000]byte" default:"0" json:"task_list"` // 任务状态数组500字节默认3
PetListCount uint32 `struc:"sizeof=PetList" json:"pet_list_count"` // 精灵列表长度
PetList []PetInfo ` json:"pet_list"` // 精灵背包内信息
PetListCount uint32 `struc:"skip" json:"pet_list_count"` // 旧登录协议精灵列表长度(已跳过)
PetList []PetInfo `struc:"skip" json:"pet_list"` // 精灵背包内信息(不再走旧登录包体)
BackupPetList []PetInfo `struc:"skip" json:"backup_pet_list"` // 精灵并列备用列表
ClothesCount uint32 `struc:"sizeof=Clothes" json:"clothes_count"` // 穿戴装备数量
Clothes []PeopleItemInfo ` json:"clothes"` // 穿戴装备

View File

@@ -65,12 +65,8 @@ func (s *InfoService) GetLogin() *model.PlayerInfo {
return nil
}
tt.Data.AllPetNumber = uint32(NewPetService(s.userid).PetCount(0))
if len(tt.Data.BackupPetList) == 0 {
storagePets := NewPetService(s.userid).PetInfo(1)
tt.Data.BackupPetList = make([]model.PetInfo, len(storagePets))
for i := range storagePets {
tt.Data.BackupPetList[i] = storagePets[i].Data
}
if tt.Data.BackupPetList == nil {
tt.Data.BackupPetList = make([]model.PetInfo, 0)
}
if tt.Data.MapID > 300 || tt.Data.MapID == 0 { //如果位于基地,就重置到传送仓