2025-11-26 01:33:48 +08:00
|
|
|
|
package controller
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
|
"blazing/common/socket/errorcode"
|
|
|
|
|
|
"blazing/logic/service/pet"
|
|
|
|
|
|
"blazing/logic/service/player"
|
2026-01-19 18:51:56 +08:00
|
|
|
|
"blazing/modules/player/model"
|
2026-01-17 00:47:41 +08:00
|
|
|
|
|
|
|
|
|
|
"github.com/samber/lo"
|
2025-11-26 01:33:48 +08:00
|
|
|
|
)
|
|
|
|
|
|
|
2025-12-24 19:03:11 +08:00
|
|
|
|
func (h Controller) IsCollect(
|
2025-11-26 01:33:48 +08:00
|
|
|
|
data *pet.C2S_IS_COLLECT, c *player.Player) (result *pet.S2C_IS_COLLECT, err errorcode.ErrorCode) { //这个时候player应该是空的
|
|
|
|
|
|
result = &pet.S2C_IS_COLLECT{
|
2026-01-17 00:47:41 +08:00
|
|
|
|
ID: data.Type,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
res := c.Info.GetTask(1335 + int(data.Type)) //第一期
|
|
|
|
|
|
if res == model.Completed {
|
|
|
|
|
|
result.IsCom = 1
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return result, 0
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 定义 Type 与合法 ID 集合的映射表,集中管理所有规则
|
|
|
|
|
|
var validTypeIDMap = map[int][]uint32{
|
|
|
|
|
|
1: {1, 4, 7}, // Type1:合法ID为1、4、7
|
|
|
|
|
|
2: {71}, // Type2:合法ID为71
|
|
|
|
|
|
3: {275}, // Type3:合法ID为275
|
|
|
|
|
|
4: {669}, // Type4:合法ID为669(注:你之前提到的是670,确认是否笔误)
|
|
|
|
|
|
301: {1, 4, 7}, //精灵王计划
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (h Controller) Collect(
|
|
|
|
|
|
data *pet.C2S_PET_COLLECT, c *player.Player) (result *pet.S2C_PET_COLLECT, err errorcode.ErrorCode) { //这个时候player应该是空的
|
|
|
|
|
|
result = &pet.S2C_PET_COLLECT{ID: data.ID}
|
|
|
|
|
|
res := c.Info.GetTask(1335 + int(data.Type)) //第一期
|
|
|
|
|
|
if res != model.Unaccepted {
|
|
|
|
|
|
return nil, errorcode.ErrorCode(errorcode.ErrorCodes.ErrSystemError)
|
2025-11-26 01:33:48 +08:00
|
|
|
|
}
|
2026-01-03 02:18:31 +08:00
|
|
|
|
|
2026-01-17 00:47:41 +08:00
|
|
|
|
validIDs, ok := validTypeIDMap[int(data.Type)]
|
|
|
|
|
|
if !ok {
|
|
|
|
|
|
// Type不在映射表中,返回系统错误
|
|
|
|
|
|
return nil, errorcode.ErrorCode(errorcode.ErrorCodes.ErrSystemError)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 2. 判断ID是否在合法集合中
|
|
|
|
|
|
if !lo.Contains(validIDs, data.ID) {
|
|
|
|
|
|
return nil, errorcode.ErrorCode(errorcode.ErrorCodes.ErrSystemError)
|
|
|
|
|
|
}
|
2026-01-03 02:18:31 +08:00
|
|
|
|
|
2026-01-17 00:47:41 +08:00
|
|
|
|
c.Info.SetTask(1335+int(data.Type), model.Completed)
|
|
|
|
|
|
r := model.GenPetInfo(int(data.ID), -1, -1, 0, 1, nil)
|
|
|
|
|
|
c.Service.Pet.PetAdd(r)
|
|
|
|
|
|
result.CatchTime = r.CatchTime
|
2026-01-03 02:18:31 +08:00
|
|
|
|
|
2025-11-26 01:33:48 +08:00
|
|
|
|
return result, 0
|
|
|
|
|
|
|
|
|
|
|
|
}
|