修改部分代码

This commit is contained in:
1
2025-08-31 06:53:42 +00:00
parent 9ef6b7b8bc
commit ab7df82bae
10 changed files with 115 additions and 33 deletions

View File

@@ -15,7 +15,11 @@ type Pet struct {
PlayerID uint32 `gorm:"not null;index:idx_pet_by_player_id;comment:'所属玩家ID'" json:"player_id"`
InBag int `gorm:"not null;comment:'是否在背包中'" json:"in_bag"` //"0为放入仓库1为放入背包
CatchTime uint32 `gorm:"not null;comment:'捕捉时间'" json:"catch_time"`
Data string `gorm:"type:text;not null;comment:'精灵全部数据'" json:"data"`
// Owner uint32 `struc:"skip"` //仅作为存储
// FreedTime uint32 `struc:"skip"` //放生时间
//是否可交易这里应该定义在精灵ID里
//是否上架
Data string `gorm:"type:text;not null;comment:'精灵全部数据'" json:"data"`
}
// * @param petTypeId 精灵类型ID
@@ -125,8 +129,7 @@ func (c *PetInfo) CalculatePetPanelSize(base, iv, level, ev uint32, natureCorrec
// PetInfo 精灵信息结构(合并后的优化版本)
type PetInfo struct {
Owner uint32 `struc:"skip"` //仅作为存储
freedTime uint32 `struc:"skip"` //放生时间
// 精灵编号(@UInt long → uint32
ID uint32 `fieldDesc:"精灵编号" `

View File

@@ -47,15 +47,26 @@ func (s *UserService) PetExec(ctime uint32, t func(uint32, model.PetInfo) model.
m1.Save(player)
}
func (s *UserService) PetAdd(ctime uint32, inbag int, y model.PetInfo) {
func (s *UserService) PetAdd(y model.PetInfo) {
m1 := cool.DBM(s.pet.Model).Where("player_id", s.userid)
var player model.Pet
player.PlayerID = s.userid
player.CatchTime = ctime
player.InBag = inbag
player.CatchTime = y.CatchTime
player.InBag = 1
tmp, _ := json.Marshal(y)
player.Data = string(tmp)
m1.Insert(player)
}
func (s *UserService) PetM(ctime, type1 int) model.PetInfo {
m1 := cool.DBM(s.pet.Model).Where("player_id", s.userid).Where("catch_time", ctime)
var player model.Pet
player.InBag = type1
m1.Update(player)
var tt model.PetInfo
json.Unmarshal([]byte(player.Data), &tt)
return tt
}

View File

@@ -58,7 +58,7 @@ func (s *UserService) InitTask() {
//panic(err)
}
func (s *UserService) TaskExec(t func([]model.TaskInfo) []model.TaskInfo, isdaliy bool) (ret bool) {
func (s *UserService) TaskExec(t func([]model.TaskInfo) []model.TaskInfo) (ret bool) {
//待实现检测是否为每日任务
// if isdaliy {