2025-12-21 17:18:33 +00:00
|
|
|
|
package model
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
|
"blazing/cool"
|
|
|
|
|
|
"errors"
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// 表名常量定义:精灵捕捉击杀数量记录表
|
|
|
|
|
|
const (
|
2026-01-19 18:51:56 +08:00
|
|
|
|
TableNamePetCatchKillCount = "player_catch_kill_count" // 精灵捕捉击杀数量表(记录每个精灵的捕捉总数量、击杀总数量)
|
2025-12-21 17:18:33 +00:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// PetBargeListInfo 精灵捕捉击杀数量核心模型(简化版,直接记录数量,摒弃状态判断)
|
|
|
|
|
|
type PetBargeListInfo struct {
|
2026-01-08 03:30:18 +08:00
|
|
|
|
Base
|
|
|
|
|
|
PlayerID uint64 `gorm:"not null;index:idx_milestone_by_player_id;comment:'所属玩家ID'" json:"player_id"`
|
|
|
|
|
|
PetId uint32 `gorm:"not null;default:0;comment:'精灵ID,关联config_pet_boss表主键'" json:"pet_id" description:"精灵ID"`
|
|
|
|
|
|
EnCntCnt uint32 `gorm:"not null;default:0;comment:'预留未知字段,暂未使用'" json:"en_cnt_cnt" description:"未知"`
|
|
|
|
|
|
CatchedCount uint32 `gorm:"not null;default:0;comment:'精灵捕捉总数量'" json:"catched_count" description:"捕捉数量"` // 替换原IsCatched,记录捕捉总数
|
|
|
|
|
|
KilledCount uint32 `gorm:"not null;default:0;comment:'精灵击杀总数量'" json:"killed_count" description:"击杀数量"` // 替换原IsKilled,记录击杀总数
|
2025-12-21 17:18:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// -------------------------- 核心配套方法 --------------------------
|
|
|
|
|
|
|
|
|
|
|
|
// TableName 指定模型对应的数据库表名(遵循项目规范)
|
|
|
|
|
|
func (*PetBargeListInfo) TableName() string {
|
|
|
|
|
|
return TableNamePetCatchKillCount
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// GroupName 指定表所属分组(与其他精灵表保持一致)
|
|
|
|
|
|
func (*PetBargeListInfo) GroupName() string {
|
|
|
|
|
|
return "default"
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// NewPetBargeListInfo 创建精灵捕捉击杀数量实例(初始化默认值)
|
|
|
|
|
|
func NewPetBargeListInfo() *PetBargeListInfo {
|
|
|
|
|
|
return &PetBargeListInfo{
|
2026-01-08 03:30:18 +08:00
|
|
|
|
Base: *NewBase(),
|
2025-12-21 17:18:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// AddCatchedCount 增加捕捉数量(支持批量累加,默认累加1)
|
|
|
|
|
|
// addNum:要增加的数量(需大于0)
|
|
|
|
|
|
func (p *PetBargeListInfo) AddCatchedCount(addNum uint32) error {
|
|
|
|
|
|
if addNum <= 0 {
|
|
|
|
|
|
return errors.New("增加的捕捉数量必须大于0")
|
|
|
|
|
|
}
|
|
|
|
|
|
if p.PetId == 0 {
|
|
|
|
|
|
return errors.New("精灵ID不能为空,无法累加捕捉数量")
|
|
|
|
|
|
}
|
|
|
|
|
|
p.CatchedCount += addNum
|
|
|
|
|
|
return nil
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// AddKilledCount 增加击杀数量(支持批量累加,默认累加1)
|
|
|
|
|
|
// addNum:要增加的数量(需大于0)
|
|
|
|
|
|
func (p *PetBargeListInfo) AddKilledCount(addNum uint32) error {
|
|
|
|
|
|
if addNum <= 0 {
|
|
|
|
|
|
return errors.New("增加的击杀数量必须大于0")
|
|
|
|
|
|
}
|
|
|
|
|
|
if p.PetId == 0 {
|
|
|
|
|
|
return errors.New("精灵ID不能为空,无法累加击杀数量")
|
|
|
|
|
|
}
|
|
|
|
|
|
p.KilledCount += addNum
|
|
|
|
|
|
return nil
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// SetCatchedCount 直接设置捕捉数量(适用于批量初始化/重置)
|
|
|
|
|
|
// count:目标捕捉数量(非负数)
|
|
|
|
|
|
func (p *PetBargeListInfo) SetCatchedCount(count uint32) error {
|
|
|
|
|
|
if p.PetId == 0 {
|
|
|
|
|
|
return errors.New("精灵ID不能为空,无法设置捕捉数量")
|
|
|
|
|
|
}
|
|
|
|
|
|
p.CatchedCount = count
|
|
|
|
|
|
return nil
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// SetKilledCount 直接设置击杀数量(适用于批量初始化/重置)
|
|
|
|
|
|
// count:目标击杀数量(非负数)
|
|
|
|
|
|
func (p *PetBargeListInfo) SetKilledCount(count uint32) error {
|
|
|
|
|
|
if p.PetId == 0 {
|
|
|
|
|
|
return errors.New("精灵ID不能为空,无法设置击杀数量")
|
|
|
|
|
|
}
|
|
|
|
|
|
p.KilledCount = count
|
|
|
|
|
|
return nil
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// -------------------------- 表结构自动同步 --------------------------
|
|
|
|
|
|
func init() {
|
|
|
|
|
|
// 程序启动时自动创建/同步精灵捕捉击杀数量表
|
|
|
|
|
|
cool.CreateTable(&PetBargeListInfo{})
|
|
|
|
|
|
}
|