```
feat(cache): 添加复合键缓存操作支持 添加了基于 uint32+string 组合键的缓存操作方法,包括 GetByCompoundKey、SetByCompoundKey、DelByCompoundKey 和 ContainsByCompoundKey 方法,用于处理用户ID和会话ID的组合缓存场景 fix(vscode): 添加 cSpell 配置支持 struc 词汇 refactor(session): 移除过时的会话管理方法 移除了基于单一字符串键的会话管理方法,因为已迁移到使用 复合键的缓存操作方式 ```
This commit is contained in:
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@@ -20,5 +20,6 @@
|
||||
"currentPreset": "dev"
|
||||
},
|
||||
"go.toolsEnvVars": {},
|
||||
"goBuild.zcli.enabled": false
|
||||
"goBuild.zcli.enabled": false,
|
||||
"cSpell.words": ["struc"]
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -26,12 +27,17 @@ type cacheStore[T any] struct {
|
||||
prefix string // 缓存键前缀
|
||||
}
|
||||
|
||||
// 生成带前缀的缓存键
|
||||
// 生成带前缀的缓存键 - 为普通字符串键使用
|
||||
func (s *cacheStore[T]) formatKey(key string) string {
|
||||
return s.prefix + strings.TrimSpace(key)
|
||||
}
|
||||
|
||||
// Get 通过键获取缓存值
|
||||
// 生成带前缀的复合缓存键 - 为 uint32+string 组合使用
|
||||
func (s *cacheStore[T]) formatCompoundKey(userID uint32, sessionID string) string {
|
||||
return s.prefix + strconv.FormatUint(uint64(userID), 10) + ":" + strings.TrimSpace(sessionID)
|
||||
}
|
||||
|
||||
// Get 通过键获取缓存值 - 原始方法保持兼容性
|
||||
func (s *cacheStore[T]) Get(ctx context.Context, key string) (T, error) {
|
||||
var zero T
|
||||
result, err := s.manager.Get(ctx, s.formatKey(key))
|
||||
@@ -58,7 +64,35 @@ func (s *cacheStore[T]) Get(ctx context.Context, key string) (T, error) {
|
||||
return converted, nil
|
||||
}
|
||||
|
||||
// Set 设置缓存值并带有效期
|
||||
// GetByCompoundKey 通过 uint32+string 组合键获取缓存值
|
||||
func (s *cacheStore[T]) GetByCompoundKey(ctx context.Context, userID uint32, sessionID string) (T, error) {
|
||||
var zero T
|
||||
key := s.formatCompoundKey(userID, sessionID)
|
||||
result, err := s.manager.Get(ctx, key)
|
||||
if err != nil {
|
||||
return zero, gerror.Wrapf(err, "获取缓存失败,键: %s", key)
|
||||
}
|
||||
if result.IsEmpty() {
|
||||
return zero, ErrCacheMiss
|
||||
}
|
||||
|
||||
// 使用 ConvertWithRefer 进行类型转换
|
||||
value := gconv.ConvertWithRefer(result.Val(), zero)
|
||||
|
||||
// 类型断言检查转换结果
|
||||
converted, ok := value.(T)
|
||||
if !ok {
|
||||
return zero, gerror.Wrapf(
|
||||
ErrTypeConvert,
|
||||
"键: %s,缓存值实际类型: %T,期望类型: %T",
|
||||
key, result.Val(), zero,
|
||||
)
|
||||
}
|
||||
|
||||
return converted, nil
|
||||
}
|
||||
|
||||
// Set 设置缓存值并带有效期 - 原始方法保持兼容性
|
||||
func (s *cacheStore[T]) Set(ctx context.Context, key string, value T, duration time.Duration) error {
|
||||
err := s.manager.Set(ctx, s.formatKey(key), value, duration)
|
||||
if err != nil {
|
||||
@@ -69,7 +103,19 @@ func (s *cacheStore[T]) Set(ctx context.Context, key string, value T, duration t
|
||||
return nil
|
||||
}
|
||||
|
||||
// Del 删除缓存
|
||||
// SetByCompoundKey 通过 uint32+string 组合键设置缓存值
|
||||
func (s *cacheStore[T]) SetByCompoundKey(ctx context.Context, userID uint32, sessionID string, value T, duration time.Duration) error {
|
||||
key := s.formatCompoundKey(userID, sessionID)
|
||||
err := s.manager.Set(ctx, key, value, duration)
|
||||
if err != nil {
|
||||
return gerror.Wrapf(err, "设置缓存失败,键: %s,值: %v", key, value)
|
||||
}
|
||||
fmt.Printf("[INFO] 缓存操作 [%s] 键: %d:%s 值: %v 有效期: %v\n",
|
||||
s.prefix, userID, sessionID, value, duration)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Del 删除缓存 - 原始方法保持兼容性
|
||||
func (s *cacheStore[T]) Del(ctx context.Context, key string) error {
|
||||
_, err := s.manager.Remove(ctx, s.formatKey(key))
|
||||
if err != nil {
|
||||
@@ -79,7 +125,18 @@ func (s *cacheStore[T]) Del(ctx context.Context, key string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Contains 检查缓存是否存在
|
||||
// DelByCompoundKey 通过 uint32+string 组合键删除缓存
|
||||
func (s *cacheStore[T]) DelByCompoundKey(ctx context.Context, userID uint32, sessionID string) error {
|
||||
key := s.formatCompoundKey(userID, sessionID)
|
||||
_, err := s.manager.Remove(ctx, key)
|
||||
if err != nil {
|
||||
return gerror.Wrapf(err, "删除缓存失败,键: %s", key)
|
||||
}
|
||||
fmt.Printf("[INFO] 删除缓存 [%s] 键: %d:%s 成功\n", s.prefix, userID, sessionID)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Contains 检查缓存是否存在 - 原始方法保持兼容性
|
||||
func (s *cacheStore[T]) Contains(ctx context.Context, key string) (bool, error) {
|
||||
exists, err := s.manager.Contains(ctx, s.formatKey(key))
|
||||
if err != nil {
|
||||
@@ -88,6 +145,16 @@ func (s *cacheStore[T]) Contains(ctx context.Context, key string) (bool, error)
|
||||
return exists, nil
|
||||
}
|
||||
|
||||
// ContainsByCompoundKey 检查 uint32+string 组合键的缓存是否存在
|
||||
func (s *cacheStore[T]) ContainsByCompoundKey(ctx context.Context, userID uint32, sessionID string) (bool, error) {
|
||||
key := s.formatCompoundKey(userID, sessionID)
|
||||
exists, err := s.manager.Contains(ctx, key)
|
||||
if err != nil {
|
||||
return false, gerror.Wrapf(err, "检查缓存是否存在失败,键: %s", key)
|
||||
}
|
||||
return exists, nil
|
||||
}
|
||||
|
||||
// GetOrSet 获取缓存值,如果不存在则设置默认值
|
||||
func (s *cacheStore[T]) GetOrSet(ctx context.Context, key string, defaultValue T, duration time.Duration) (T, error) {
|
||||
var zero T
|
||||
|
||||
@@ -51,26 +51,6 @@ func newSessionManager() *sessionManager {
|
||||
}
|
||||
}
|
||||
|
||||
// GetSession 通过会话ID获取用户ID
|
||||
func (m *sessionManager) GetSession(sessionID string) (uint32, error) {
|
||||
return m.sessionStore.Get(context.Background(), sessionID)
|
||||
}
|
||||
|
||||
// SaveSession 保存会话信息
|
||||
func (m *sessionManager) SaveSession(sessionID string, userID uint32) error {
|
||||
return m.sessionStore.Set(gctx.New(), sessionID, userID, time.Hour*1)
|
||||
}
|
||||
|
||||
// DeleteSession 删除会话
|
||||
func (m *sessionManager) DeleteSession(sessionID string) error {
|
||||
return m.sessionStore.Del(gctx.New(), sessionID)
|
||||
}
|
||||
|
||||
// SessionExists 检查会话是否存在
|
||||
func (m *sessionManager) SessionExists(sessionID string) (bool, error) {
|
||||
return m.sessionStore.Contains(context.Background(), sessionID)
|
||||
}
|
||||
|
||||
// SetUserOnline 设置用户在线状态
|
||||
func (m *sessionManager) SetUserOnline(userID uint32, serverID uint16) error {
|
||||
return m.userOnlineStore.Set(gctx.New(), gconv.String(userID), serverID, 0)
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -112,6 +112,7 @@ func (s *handler) register(namespace string, r interface{}) {
|
||||
if method.Name != "KickPerson" &&
|
||||
method.Name != "QuitSelf" &&
|
||||
method.Name != "Kick" &&
|
||||
method.Name != "Broadcast" &&
|
||||
method.Name != "RegisterLogic" {
|
||||
continue
|
||||
|
||||
|
||||
2
go.work
2
go.work
@@ -23,7 +23,7 @@ use (
|
||||
./login
|
||||
./modules
|
||||
./modules/base
|
||||
./modules/blazing
|
||||
./modules/player
|
||||
./modules/config
|
||||
./modules/dict
|
||||
./modules/space
|
||||
|
||||
42
help/内测奖励查询.sql
Normal file
42
help/内测奖励查询.sql
Normal file
@@ -0,0 +1,42 @@
|
||||
-- 整合所有用户核心指标:任务数、击杀数、在线时长、胜利数、最高关卡、最高刷新关卡
|
||||
SELECT
|
||||
COALESCE(t1.player_id, t2.player_id, t3.player_id, t4.player_id, t5.player_id, t6.player_id) AS player_id,
|
||||
-- 处理NULL值:无数据时显示0
|
||||
COALESCE(t1.task_count, 0) AS task_count, -- player_task表的任务数量
|
||||
COALESCE(t2.catch_kill_count, 0) AS catch_kill_count, -- player_catch_kill_count表的击杀数量
|
||||
COALESCE(t3.online_time, 0) AS online_time, -- 在线时长
|
||||
COALESCE(t4.mess_win, 0) AS mess_win, -- 胜利次数
|
||||
COALESCE(t5.max_stage, 0) AS max_stage, -- 最高关卡
|
||||
COALESCE(t6.max_fresh_stage, 0) AS max_fresh_stage -- 最高刷新关卡
|
||||
FROM
|
||||
-- 子查询1:统计player_task表的用户任务数
|
||||
(SELECT player_id, COUNT(*) AS task_count
|
||||
FROM player_task
|
||||
GROUP BY player_id) t1
|
||||
FULL OUTER JOIN
|
||||
-- 子查询2:统计player_catch_kill_count表的用户击杀数
|
||||
(SELECT player_id, COUNT(*) AS catch_kill_count
|
||||
FROM player_catch_kill_count
|
||||
GROUP BY player_id) t2 ON t1.player_id = t2.player_id
|
||||
FULL OUTER JOIN
|
||||
-- 子查询3:提取player_info表的在线时长(>0)
|
||||
(SELECT player_id, (data->>'online_time')::int AS online_time
|
||||
FROM player_info
|
||||
WHERE jsonb_exists(data, 'online_time') AND (data->>'online_time')::int > 0) t3 ON COALESCE(t1.player_id, t2.player_id) = t3.player_id
|
||||
FULL OUTER JOIN
|
||||
-- 子查询4:提取player_info表的胜利次数(mess_win >0)
|
||||
(SELECT player_id, (data->>'mess_win')::int AS mess_win
|
||||
FROM player_info
|
||||
WHERE jsonb_exists(data, 'mess_win') AND (data->>'mess_win')::int > 0) t4 ON COALESCE(t1.player_id, t2.player_id, t3.player_id) = t4.player_id
|
||||
FULL OUTER JOIN
|
||||
-- 子查询5:提取player_info表的最高关卡(max_stage >0)
|
||||
(SELECT player_id, (data->>'max_stage')::int AS max_stage
|
||||
FROM player_info
|
||||
WHERE jsonb_exists(data, 'max_stage') AND (data->>'max_stage')::int > 0) t5 ON COALESCE(t1.player_id, t2.player_id, t3.player_id, t4.player_id) = t5.player_id
|
||||
FULL OUTER JOIN
|
||||
-- 子查询6:提取player_info表的最高刷新关卡(max_fresh_stage >0)
|
||||
(SELECT player_id, (data->>'max_fresh_stage')::int AS max_fresh_stage
|
||||
FROM player_info
|
||||
WHERE jsonb_exists(data, 'max_fresh_stage') AND (data->>'max_fresh_stage')::int > 0) t6 ON COALESCE(t1.player_id, t2.player_id, t3.player_id, t4.player_id, t5.player_id) = t6.player_id
|
||||
-- 可选:按某一指标排序(比如在线时长降序)
|
||||
ORDER BY online_time DESC;
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"blazing/common/socket/errorcode"
|
||||
"blazing/logic/service/egg"
|
||||
"blazing/logic/service/player"
|
||||
"blazing/modules/blazing/model"
|
||||
"blazing/modules/config/service"
|
||||
"blazing/modules/player/model"
|
||||
|
||||
"github.com/gogf/gf/v2/util/grand"
|
||||
)
|
||||
|
||||
@@ -10,8 +10,8 @@ import (
|
||||
"blazing/logic/service/fight/info"
|
||||
|
||||
"blazing/logic/service/player"
|
||||
"blazing/modules/blazing/model"
|
||||
"blazing/modules/config/service"
|
||||
"blazing/modules/player/model"
|
||||
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
"github.com/gogf/gf/v2/util/grand"
|
||||
@@ -137,12 +137,12 @@ func (h Controller) PlayerFightBoss(data *fight.ChallengeBossInboundInfo, p *pla
|
||||
fight.NewFight(p, ai, func(foi info.FightOverInfo) {
|
||||
if taskID != 0 {
|
||||
if foi.Reason == 0 && foi.WinnerId == p.Info.UserID {
|
||||
p.CompletedTask(taskID, 100)
|
||||
p.BossCompletedTask(taskID, 100)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
p.Done.Exec(model.MilestoneMode.BOSS, []uint32{p.Info.MapID, data.BossId, uint32(foi.Reason)}, nil)
|
||||
//p.Done.Exec(model.MilestoneMode.BOSS, []uint32{p.Info.MapID, data.BossId, uint32(foi.Reason)}, nil)
|
||||
|
||||
})
|
||||
|
||||
@@ -189,7 +189,7 @@ func (h Controller) OnPlayerFightNpcMonster(data1 *fight.FightNpcMonsterInboundI
|
||||
p.Fightinfo.Mode = info.BattleMode.MULTI_MODE //多人模式
|
||||
|
||||
fight.NewFight(p, ai, func(foi info.FightOverInfo) {
|
||||
p.Done.Exec(model.MilestoneMode.Moster, []uint32{p.Info.MapID, monsterInfo.PetList[0].ID, uint32(foi.Reason)}, nil)
|
||||
//p.Done.Exec(model.MilestoneMode.Moster, []uint32{p.Info.MapID, monsterInfo.PetList[0].ID, uint32(foi.Reason)}, nil)
|
||||
if foi.Reason == 0 && foi.WinnerId == p.Info.UserID {
|
||||
|
||||
if !p.CanGetExp() {
|
||||
@@ -217,6 +217,7 @@ func (h Controller) OnPlayerFightNpcMonster(data1 *fight.FightNpcMonsterInboundI
|
||||
p.Info.ExpPool += exp * 4
|
||||
p.AddPetExp(foi.Winpet, uint32(exp)*2)
|
||||
p.SendPackCmd(8004, items)
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
@@ -7,9 +7,9 @@ import (
|
||||
fightinfo "blazing/logic/service/fight/info"
|
||||
"blazing/logic/service/player"
|
||||
"blazing/logic/service/space/info"
|
||||
"blazing/modules/blazing/model"
|
||||
configmodel "blazing/modules/config/model"
|
||||
"blazing/modules/config/service"
|
||||
"blazing/modules/player/model"
|
||||
|
||||
"sync/atomic"
|
||||
|
||||
@@ -188,26 +188,20 @@ func (h Controller) PetTawor(data *fight.StartTwarInboundInfo, c *player.Player)
|
||||
if foi.Reason == 0 && foi.WinnerId == c.Info.UserID { //我放获胜
|
||||
switch data.Head.CMD {
|
||||
case 2429: //试炼之塔
|
||||
for _, v := range boss.TaskIds {
|
||||
c.CompletedTask(int(v), 600)
|
||||
}
|
||||
c.BossCompletedTask(600, int(c.Info.CurrentStage))
|
||||
c.Info.CurrentFreshStage++
|
||||
if c.Info.CurrentFreshStage >= c.Info.MaxFreshStage {
|
||||
c.Info.MaxFreshStage = c.Info.CurrentFreshStage
|
||||
}
|
||||
|
||||
case 2415: //勇者之塔
|
||||
for _, v := range boss.TaskIds {
|
||||
c.CompletedTask(int(v), 500)
|
||||
}
|
||||
c.BossCompletedTask(500, int(c.Info.CurrentStage))
|
||||
c.Info.CurrentStage++
|
||||
if c.Info.CurrentStage >= c.Info.MaxStage {
|
||||
c.Info.MaxStage = c.Info.CurrentStage
|
||||
}
|
||||
case 2425:
|
||||
for _, v := range boss.TaskIds {
|
||||
c.CompletedTask(int(v), 110)
|
||||
}
|
||||
c.BossCompletedTask(110, int(c.Info.CurrentStage))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"blazing/logic/service/fight"
|
||||
"blazing/logic/service/item"
|
||||
"blazing/logic/service/player"
|
||||
"blazing/modules/blazing/model"
|
||||
"blazing/modules/player/model"
|
||||
|
||||
"github.com/jinzhu/copier"
|
||||
)
|
||||
|
||||
@@ -3,8 +3,13 @@ package controller
|
||||
import (
|
||||
"blazing/common/rpc"
|
||||
"blazing/common/socket/errorcode"
|
||||
"blazing/cool"
|
||||
"blazing/logic/service/user"
|
||||
"blazing/modules/base/service"
|
||||
playerservice "blazing/modules/player/service"
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
|
||||
"github.com/panjf2000/gnet/v2"
|
||||
)
|
||||
@@ -21,12 +26,37 @@ import (
|
||||
// GetServerOnline 处理命令: 105
|
||||
func (h Controller) GetServerOnline(data *user.SidInfo, c gnet.Conn) (result *rpc.CommendSvrInfo, err errorcode.ErrorCode) { //这个时候player应该是空的
|
||||
result = rpc.NewInInfo()
|
||||
// tt, _ := cool.CacheManager.Keys(context.Background())
|
||||
//g.Dump(tt)
|
||||
t1 := hex.EncodeToString(data.Sid)
|
||||
userid, ok := playerservice.User.Load(t1)
|
||||
if !ok || userid != data.Head.UserID {
|
||||
|
||||
defer c.Close()
|
||||
return
|
||||
}
|
||||
|
||||
// if service.NewBaseSysUserService().GetPerson(data.Head.UserID).Debug == 1 {
|
||||
// result.IsVip = 1
|
||||
// }
|
||||
result.IsVip = 1
|
||||
result.ServerList = rpc.GetServerInfoList(service.NewBaseSysUserService().GetPerson(data.Head.UserID).Debug)
|
||||
defer func() {
|
||||
|
||||
// share.ShareManager.DeleteSession(t1)
|
||||
|
||||
ser := playerservice.NewUserService(data.Head.UserID)
|
||||
kickErr := ser.Info.Kick(data.Head.UserID)
|
||||
if kickErr != nil {
|
||||
fmt.Println("踢人失败", kickErr)
|
||||
|
||||
}
|
||||
logininfo := ser.Info.SetLogin()
|
||||
if logininfo != nil {
|
||||
cool.CacheManager.Set(context.TODO(), fmt.Sprintf("player: %d", data.Head.UserID), logininfo, 0)
|
||||
cool.CacheManager.Set(context.Background(), fmt.Sprintf("session: %d", data.Head.UserID), t1, 0)
|
||||
|
||||
}
|
||||
|
||||
}()
|
||||
|
||||
return
|
||||
|
||||
//return //TODO 这里待实现改成接口调用Ret方法
|
||||
|
||||
@@ -3,7 +3,6 @@ package controller
|
||||
import (
|
||||
"blazing/common/data/share"
|
||||
"blazing/cool"
|
||||
"fmt"
|
||||
|
||||
"blazing/common/socket/errorcode"
|
||||
|
||||
@@ -11,7 +10,7 @@ import (
|
||||
|
||||
"blazing/logic/service/player"
|
||||
"blazing/logic/service/space"
|
||||
blservice "blazing/modules/blazing/service"
|
||||
"blazing/modules/player/service"
|
||||
"context"
|
||||
"time"
|
||||
|
||||
@@ -27,13 +26,6 @@ func (h Controller) Login(data *user.MAIN_LOGIN_IN, c gnet.Conn) (result *user.L
|
||||
return
|
||||
}
|
||||
|
||||
kickErr := h.RPCClient.Kick(data.Head.UserID) //先踢人
|
||||
if kickErr != nil {
|
||||
fmt.Println("踢人失败", err)
|
||||
}
|
||||
|
||||
cool.Logger.Info(context.TODO(), "踢人请求完成,继续登录流程")
|
||||
|
||||
share.ShareManager.SetUserOnline(data.Head.UserID, h.Port) //设置用户登录服务器
|
||||
currentPlayer := player.GetPlayer(c, data.Head.UserID)
|
||||
if currentPlayer == nil {
|
||||
@@ -42,9 +34,9 @@ func (h Controller) Login(data *user.MAIN_LOGIN_IN, c gnet.Conn) (result *user.L
|
||||
defer c.Close()
|
||||
return
|
||||
}
|
||||
currentPlayer.Service = blservice.NewUserService(data.Head.UserID)
|
||||
currentPlayer.Service = service.NewUserService(data.Head.UserID)
|
||||
|
||||
currentPlayer.Info = currentPlayer.Service.Info.Personself()
|
||||
currentPlayer.Info = currentPlayer.Service.Info.GetCache()
|
||||
|
||||
if currentPlayer.Info == nil {
|
||||
defer c.Close()
|
||||
|
||||
95
logic/controller/pet_breed.go
Normal file
95
logic/controller/pet_breed.go
Normal file
@@ -0,0 +1,95 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"blazing/common/socket/errorcode"
|
||||
"blazing/logic/service/fight"
|
||||
"blazing/logic/service/pet"
|
||||
"blazing/logic/service/player"
|
||||
)
|
||||
|
||||
// GetBreedInfo 获取繁殖信息协议
|
||||
// 前端到后端无数据 请求协议
|
||||
func (ctl Controller) GetBreedInfo(
|
||||
data *pet.C2S_GET_BREED_INFO, playerObj *player.Player) (result *pet.S2C_GET_BREED_INFO, err errorcode.ErrorCode) { //这个时候player应该是空的
|
||||
|
||||
result = &pet.S2C_GET_BREED_INFO{}
|
||||
// TODO: 实现获取繁殖信息的具体逻辑
|
||||
return result, 0
|
||||
|
||||
}
|
||||
|
||||
// GetBreedPet 获取繁殖精灵
|
||||
// 前端到后端
|
||||
func (ctl Controller) GetBreedPet(
|
||||
data *pet.C2S_GET_BREED_PET, playerObj *player.Player) (result *pet.S2C_GET_BREED_PET, err errorcode.ErrorCode) { //这个时候player应该是空的
|
||||
|
||||
result = &pet.S2C_GET_BREED_PET{}
|
||||
// TODO: 实现获取可繁殖雌性精灵列表的逻辑
|
||||
// 这里只是示例,实际应该根据雄性精灵的catchTime查找可繁殖的雌性精灵
|
||||
for _, v := range playerObj.Info.PetList {
|
||||
// 如果是雌性精灵,且可以繁殖,则添加到列表
|
||||
result.FemaleList = append(result.FemaleList, v.CatchTime)
|
||||
}
|
||||
return result, 0
|
||||
|
||||
}
|
||||
|
||||
// StartBreed 开始繁殖协议
|
||||
// 前端到后端
|
||||
func (ctl Controller) StartBreed(
|
||||
data *pet.C2S_START_BREED, playerObj *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) { //这个时候player应该是空的
|
||||
|
||||
// TODO: 实现开始繁殖的具体逻辑
|
||||
result = &fight.NullOutboundInfo{}
|
||||
return result, 0
|
||||
|
||||
}
|
||||
|
||||
// GetEggList 获取精灵蛋数组
|
||||
// 前端到后端无数据 请求协议
|
||||
func (ctl Controller) GetEggList(
|
||||
data *pet.C2S_GET_EGG_LIST, playerObj *player.Player) (result *pet.S2C_GET_EGG_LIST, err errorcode.ErrorCode) { //这个时候player应该是空的
|
||||
|
||||
result = &pet.S2C_GET_EGG_LIST{}
|
||||
// TODO: 实现获取精灵蛋列表的逻辑
|
||||
// 示例数据,实际应从玩家数据中获取
|
||||
result.EggList = append(result.EggList, pet.EggInfo{EggID: 1, OwnerID: 10001, EggCatchTime: 122123})
|
||||
return result, 0
|
||||
|
||||
}
|
||||
|
||||
// EffectHatch 精灵蛋互动协议
|
||||
// 前端到后端
|
||||
func (ctl Controller) EffectHatch(
|
||||
data *pet.C2S_EFFECT_HATCH, playerObj *player.Player) (result *pet.S2C_EFFECT_HATCH, err errorcode.ErrorCode) {
|
||||
|
||||
result = &pet.S2C_EFFECT_HATCH{}
|
||||
// TODO: 实现精灵蛋互动逻辑,根据互动ID更新亲密度
|
||||
result.Intimacy = 1 // 悲伤
|
||||
return result, 0
|
||||
|
||||
}
|
||||
|
||||
// StartHatch 开始孵化精灵蛋
|
||||
// 前端到后端
|
||||
func (ctl Controller) StartHatch(
|
||||
data *pet.C2S_START_HATCH, playerObj *player.Player) (result *pet.S2C_START_HATCH, err errorcode.ErrorCode) {
|
||||
|
||||
// TODO: 实现开始孵化精灵蛋的具体逻辑
|
||||
result = &pet.S2C_START_HATCH{}
|
||||
return result, 0
|
||||
|
||||
}
|
||||
|
||||
// GetHatchPet 获得孵化精灵协议
|
||||
// 前端到后端无数据内容 请求协议
|
||||
func (ctl Controller) GetHatchPet(
|
||||
data *pet.C2S_GET_HATCH_PET, playerObj *player.Player) (result *pet.S2C_GET_HATCH_PET, err errorcode.ErrorCode) {
|
||||
|
||||
result = &pet.S2C_GET_HATCH_PET{}
|
||||
// TODO: 实现获得孵化精灵的具体逻辑,这里暂时返回默认值
|
||||
result.PetID = 0
|
||||
result.CatchTime = 0
|
||||
return result, 0
|
||||
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"blazing/common/socket/errorcode"
|
||||
"blazing/logic/service/pet"
|
||||
"blazing/logic/service/player"
|
||||
"blazing/modules/blazing/model"
|
||||
"blazing/modules/player/model"
|
||||
|
||||
"github.com/samber/lo"
|
||||
)
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"blazing/common/socket/errorcode"
|
||||
"blazing/logic/service/pet"
|
||||
"blazing/logic/service/player"
|
||||
"blazing/modules/blazing/model"
|
||||
"blazing/modules/config/service"
|
||||
"blazing/modules/player/model"
|
||||
|
||||
"github.com/alpacahq/alpacadecimal"
|
||||
"github.com/gogf/gf/v2/util/grand"
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"blazing/logic/service/fight"
|
||||
"blazing/logic/service/pet"
|
||||
"blazing/logic/service/player"
|
||||
"blazing/modules/blazing/model"
|
||||
"blazing/modules/player/model"
|
||||
|
||||
"github.com/samber/lo"
|
||||
)
|
||||
|
||||
@@ -20,7 +20,7 @@ func (h Controller) BuyFitment(data *room.C2S_BUY_FITMENT, c *player.Player) (re
|
||||
if !c.GetCoins(uint32(totalCost)) {
|
||||
return nil, errorcode.ErrorCodes.ErrSunDouInsufficient10016
|
||||
}
|
||||
c.Service.Room.Add(data.ID, data.Count)
|
||||
c.Service.Item.UPDATE(data.ID, int(data.Count))
|
||||
c.Info.Coins -= uint32(totalCost)
|
||||
result.ID = data.ID
|
||||
result.Coins = c.Info.Coins
|
||||
|
||||
@@ -2,7 +2,7 @@ package controller
|
||||
|
||||
import (
|
||||
"blazing/common/socket/errorcode"
|
||||
"blazing/modules/blazing/model"
|
||||
"blazing/modules/player/model"
|
||||
|
||||
"blazing/logic/service/pet"
|
||||
"blazing/logic/service/player"
|
||||
@@ -55,10 +55,19 @@ func (h Controller) GetAllFurniture(data *room.FitmentAllInboundEmpty, c *player
|
||||
result = &room.FitmentAllOutboundInfo{}
|
||||
result.Fitments = make([]room.FitmentItemInfo, 0)
|
||||
|
||||
items := c.Service.Item.Get(500000, 600000)
|
||||
roomData := c.Service.Room.Get(c.Info.UserID)
|
||||
for itemID, count := range roomData.OwnedItems {
|
||||
result.Fitments = append(result.Fitments, room.FitmentItemInfo{Id: itemID, AllCount: count, UsedCount: roomData.UserItems[itemID]})
|
||||
for _, item := range items {
|
||||
var itemInfo room.FitmentItemInfo
|
||||
itemInfo.Id = item.ItemId
|
||||
itemInfo.AllCount = item.ItemCnt
|
||||
i, ok := roomData.UsedItems[item.ItemId]
|
||||
if ok {
|
||||
itemInfo.UsedCount = i
|
||||
}
|
||||
result.Fitments = append(result.Fitments, itemInfo)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
// c: 当前玩家对象
|
||||
// 返回: 空结果和错误码
|
||||
func (h Controller) SetFitment(data *room.SET_FITMENT, c *player.Player) (result *room.NullInfo, err errorcode.ErrorCode) {
|
||||
|
||||
c.Service.Room.Set(data.Fitments)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -7,7 +7,8 @@ import (
|
||||
"blazing/logic/service/item"
|
||||
"blazing/logic/service/player"
|
||||
"blazing/logic/service/user"
|
||||
"blazing/modules/blazing/model"
|
||||
"blazing/modules/player/model"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// PlayerAim 玩家射击操作
|
||||
@@ -160,3 +161,34 @@ func (h Controller) ChangePlayerCloth(data *item.ChangePlayerClothInboundInfo, p
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (h Controller) ChangePlayerName(data *user.ChangePlayerNameInboundInfo, c *player.Player) (result *user.ChangePlayerNameOutboundInfo, err errorcode.ErrorCode) {
|
||||
newNickname := cool.Filter.Replace(strings.Trim(data.Nickname, "\x00"), '*')
|
||||
|
||||
c.Info.Nick = newNickname
|
||||
result = &user.ChangePlayerNameOutboundInfo{
|
||||
Nickname: newNickname,
|
||||
UserID: c.Info.UserID,
|
||||
}
|
||||
c.GetSpace().Broadcast(c, data.Head.CMD, result)
|
||||
|
||||
return result, 0
|
||||
}
|
||||
func (h Controller) ChangeTile(data *user.ChangeTitleInboundInfo, c *player.Player) (result *user.ChangeTitleOutboundInfo, err errorcode.ErrorCode) {
|
||||
result = &user.ChangeTitleOutboundInfo{
|
||||
|
||||
UserID: c.Info.UserID,
|
||||
}
|
||||
if data.TileID == 0 {
|
||||
return result, 0
|
||||
}
|
||||
if !c.Service.Title.Can(data.TileID) {
|
||||
return nil, errorcode.ErrorCodes.ErrSystemError
|
||||
}
|
||||
c.Info.Title = data.TileID
|
||||
result.TileID = data.TileID
|
||||
|
||||
c.GetSpace().Broadcast(c, data.Head.CMD, result)
|
||||
|
||||
return result, 0
|
||||
}
|
||||
|
||||
56
logic/controller/user_cdk.go
Normal file
56
logic/controller/user_cdk.go
Normal file
@@ -0,0 +1,56 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"blazing/common/socket/errorcode"
|
||||
"blazing/logic/service/player"
|
||||
"blazing/logic/service/user"
|
||||
"blazing/modules/config/service"
|
||||
"blazing/modules/player/model"
|
||||
"time"
|
||||
)
|
||||
|
||||
func (h Controller) CDK(data *user.C2S_GET_GIFT_COMPLETE, player *player.Player) (result *user.S2C_GET_GIFT_COMPLETE, err errorcode.ErrorCode) {
|
||||
result = &user.S2C_GET_GIFT_COMPLETE{}
|
||||
|
||||
r := service.NewCdkService().Get(data.PassText)
|
||||
if r == nil {
|
||||
return nil, errorcode.ErrorCodes.ErrMolecularCodeNotExists
|
||||
}
|
||||
|
||||
if r.ValidEndTime.Compare(time.Now()) == -1 {
|
||||
return nil, errorcode.ErrorCodes.ErrMolecularCodeExpired
|
||||
}
|
||||
if !player.Service.Cdk.CanGet(uint32(r.ID)) {
|
||||
return
|
||||
}
|
||||
if !service.NewCdkService().Set(data.PassText) {
|
||||
return nil, errorcode.ErrorCodes.ErrMolecularCodeGiftsGone
|
||||
}
|
||||
|
||||
result.Flag = 1
|
||||
for _, v := range r.ElfRewardIds {
|
||||
pet := service.NewPetRewardService().Get(v)
|
||||
if pet != nil {
|
||||
peti := model.GenPetInfo(int(pet.MonID), int(pet.DV), int(pet.Nature), int(pet.Effect), int(pet.Lv), nil)
|
||||
player.Service.Pet.PetAdd(peti)
|
||||
result.PetGift = append(result.PetGift, user.PetGiftInfo{PetID: peti.ID, CacthTime: peti.CatchTime})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for _, itemID := range r.ItemRewardIds {
|
||||
iteminfo := service.NewItemService().GetItemCount(itemID)
|
||||
player.ItemAdd(iteminfo.ItemId, iteminfo.ItemCnt)
|
||||
|
||||
result.GiftList = append(result.GiftList, user.GiftInfo{GiftID: iteminfo.ItemId, Count: iteminfo.ItemCnt})
|
||||
|
||||
}
|
||||
if r.TitleRewardIds != 0 {
|
||||
player.Service.Title.Give(r.TitleRewardIds)
|
||||
result.Tile = r.TitleRewardIds
|
||||
|
||||
}
|
||||
player.Service.Cdk.Log(uint32(r.ID))
|
||||
|
||||
return
|
||||
}
|
||||
@@ -3,10 +3,9 @@ package controller
|
||||
import (
|
||||
"blazing/common/socket/errorcode"
|
||||
"blazing/cool"
|
||||
"blazing/modules/player/service"
|
||||
|
||||
"blazing/logic/service/player"
|
||||
"blazing/logic/service/user"
|
||||
blservice "blazing/modules/blazing/service"
|
||||
"strings"
|
||||
|
||||
"github.com/panjf2000/gnet/v2"
|
||||
@@ -15,19 +14,7 @@ import (
|
||||
// CreatePlayer 处理命令: 1001
|
||||
func (h Controller) CreatePlayer(data *user.CreatePlayerInboundInfo, c gnet.Conn) (result *user.CreatePlayerOutInfo, err errorcode.ErrorCode) {
|
||||
data.Nickname = strings.Trim(data.Nickname, "\x00")
|
||||
blservice.NewUserService(data.Head.UserID).Info.Reg(cool.Filter.Replace(data.Nickname, '*'), data.Color)
|
||||
return result, 0
|
||||
}
|
||||
|
||||
func (h Controller) ChangePlayerName(data *user.ChangePlayerNameInboundInfo, c *player.Player) (result *user.ChangePlayerNameOutboundInfo, err errorcode.ErrorCode) {
|
||||
newNickname := cool.Filter.Replace(strings.Trim(data.Nickname, "\x00"), '*')
|
||||
|
||||
c.Info.Nick = newNickname
|
||||
result = &user.ChangePlayerNameOutboundInfo{
|
||||
Nickname: newNickname,
|
||||
UserID: c.Info.UserID,
|
||||
}
|
||||
c.GetSpace().Broadcast(c, data.Head.CMD, result)
|
||||
service.NewUserService(data.Head.UserID).Info.Reg(cool.Filter.Replace(data.Nickname, '*'), data.Color)
|
||||
|
||||
return result, 0
|
||||
}
|
||||
|
||||
@@ -3,11 +3,11 @@ package controller
|
||||
import (
|
||||
"blazing/common/data"
|
||||
"blazing/common/socket/errorcode"
|
||||
"fmt"
|
||||
|
||||
"blazing/logic/service/player"
|
||||
"blazing/logic/service/task"
|
||||
"blazing/modules/blazing/model"
|
||||
"blazing/modules/config/service"
|
||||
"blazing/modules/player/model"
|
||||
)
|
||||
|
||||
// AcceptTask 接受任务
|
||||
@@ -16,13 +16,14 @@ func (h Controller) AcceptTask(data *task.AcceptTaskInboundInfo, c *player.Playe
|
||||
// if data.Head.CMD != 2201 { //判断是每日任务
|
||||
// //isdaliy = true
|
||||
// }
|
||||
if c.Info.GetTask(int(data.TaskId)) == model.Completed {
|
||||
return result, 0
|
||||
if c.Info.GetTask(int(data.TaskId)) != model.Unaccepted {
|
||||
return nil, errorcode.ErrorCodes.ErrSystemError
|
||||
}
|
||||
if !service.NewTaskService().IsAcceptable(data.TaskId) {
|
||||
return nil, errorcode.ErrorCodes.ErrSystemError
|
||||
}
|
||||
if c.Info.GetTask(int(data.TaskId)) == model.Unaccepted {
|
||||
c.Info.SetTask(int(data.TaskId), model.Accepted)
|
||||
|
||||
}
|
||||
c.Info.SetTask(int(data.TaskId), model.Accepted)
|
||||
c.Service.Task.Exec(uint32(data.TaskId), func(t *model.TaskEX) bool {
|
||||
t.Data = []uint32{}
|
||||
|
||||
@@ -39,6 +40,10 @@ func (h Controller) AcceptTask(data *task.AcceptTaskInboundInfo, c *player.Playe
|
||||
// c: 当前玩家对象
|
||||
// 返回: 空输出结果和错误码
|
||||
func (h Controller) AddTaskBuf(data *task.AddTaskBufInboundInfo, c *player.Player) (result *task.AddTaskBufOutboundInfo, err errorcode.ErrorCode) {
|
||||
|
||||
if !service.NewTaskService().IsAcceptable(data.TaskId) {
|
||||
return nil, errorcode.ErrorCodes.ErrSystemError
|
||||
}
|
||||
c.Service.Task.Exec(data.TaskId, func(taskEx *model.TaskEX) bool {
|
||||
taskEx.Data = data.TaskList
|
||||
return true
|
||||
@@ -54,9 +59,12 @@ func (h Controller) CompleteTask(data1 *task.CompleteTaskInboundInfo, c *player.
|
||||
if c.Info.GetTask(int(data1.TaskId)) != model.Accepted {
|
||||
return result, errorcode.ErrorCodes.ErrAwardAlreadyClaimed
|
||||
}
|
||||
if data1.OutState > 10 {
|
||||
fmt.Println("error", data1.OutState, c.Info.UserID, "分支溢出")
|
||||
return result, 0
|
||||
// if data1.OutState > 10 {
|
||||
// fmt.Println("error", data1.OutState, c.Info.UserID, "分支溢出")
|
||||
// return result, 0
|
||||
// }
|
||||
if !service.NewTaskService().IsAcceptable(data1.TaskId) {
|
||||
return nil, errorcode.ErrorCodes.ErrSystemError
|
||||
}
|
||||
c.Info.SetTask(int(data1.TaskId), model.Completed)
|
||||
|
||||
@@ -65,7 +73,7 @@ func (h Controller) CompleteTask(data1 *task.CompleteTaskInboundInfo, c *player.
|
||||
ItemList: make([]data.ItemInfo, 0),
|
||||
}
|
||||
|
||||
taskInfo := task.GetTaskInfo(data1.TaskId, data1.OutState)
|
||||
taskInfo := task.GetTaskInfo(int(data1.TaskId), int(data1.OutState))
|
||||
if taskInfo == nil {
|
||||
return result, 0
|
||||
}
|
||||
@@ -104,7 +112,9 @@ func (h Controller) GetTaskBuf(data *task.GetTaskBufInboundInfo, c *player.Playe
|
||||
|
||||
// DeleteTask 删除任务
|
||||
func (h Controller) DeleteTask(data *task.DeleteTaskInboundInfo, c *player.Player) (result *task.DeleteTaskOutboundInfo, err errorcode.ErrorCode) {
|
||||
|
||||
if !service.NewTaskService().IsAcceptable(data.TaskId) {
|
||||
return nil, errorcode.ErrorCodes.ErrSystemError
|
||||
}
|
||||
if c.Info.GetTask(int(data.TaskId)) == model.Accepted {
|
||||
c.Info.SetTask(int(data.TaskId), model.Unaccepted)
|
||||
return &task.DeleteTaskOutboundInfo{TaskId: data.TaskId}, 0
|
||||
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
|
||||
//"blazing/o/service"
|
||||
"blazing/modules/base/service"
|
||||
blservice "blazing/modules/blazing/service"
|
||||
blservice "blazing/modules/player/service"
|
||||
"net/http"
|
||||
_ "net/http/pprof"
|
||||
)
|
||||
|
||||
@@ -2,7 +2,7 @@ package common
|
||||
|
||||
import (
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/modules/blazing/model"
|
||||
"blazing/modules/player/model"
|
||||
)
|
||||
|
||||
type PlayerI interface {
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"blazing/logic/service/fight/action"
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/logic/service/fight/input"
|
||||
"blazing/modules/blazing/model"
|
||||
"blazing/modules/player/model"
|
||||
"fmt"
|
||||
"reflect"
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package info
|
||||
import (
|
||||
element "blazing/common/data/Element"
|
||||
"blazing/common/data/xmlres"
|
||||
"blazing/modules/blazing/model"
|
||||
"blazing/modules/player/model"
|
||||
|
||||
"math/rand"
|
||||
|
||||
@@ -18,8 +18,8 @@ type BattlePetEntity struct {
|
||||
Info model.PetInfo //通过偏移赋值
|
||||
//*input.Input
|
||||
//PType int
|
||||
|
||||
Skills map[uint32]*SkillEntity // 技能槽(最多4个技能)
|
||||
|
||||
Skills map[uint32]*SkillEntity // 技能槽(最多4个技能)
|
||||
//Status StatusDict //精灵的状态
|
||||
//能力提升属性
|
||||
//Prop PropDict
|
||||
|
||||
@@ -3,7 +3,7 @@ package info
|
||||
import (
|
||||
element "blazing/common/data/Element"
|
||||
"blazing/common/data/xmlres"
|
||||
"blazing/modules/blazing/model"
|
||||
"blazing/modules/player/model"
|
||||
"math/rand"
|
||||
|
||||
"fmt"
|
||||
|
||||
@@ -2,7 +2,7 @@ package info
|
||||
|
||||
import (
|
||||
"blazing/common/data"
|
||||
"blazing/modules/blazing/model"
|
||||
"blazing/modules/player/model"
|
||||
"fmt"
|
||||
|
||||
"github.com/tnnmigga/enum"
|
||||
@@ -230,6 +230,10 @@ type S2C_2404 struct {
|
||||
// 用户ID(野怪为0),@UInt long
|
||||
UserID uint32 `fieldDesc:"userID 如果为野怪则为0" `
|
||||
}
|
||||
type S2C_50005 struct {
|
||||
//奖励称号
|
||||
Title uint32
|
||||
}
|
||||
|
||||
// NoteReadyToFightInfo 战斗准备就绪消息结构体,NoteReadyToFightInfo
|
||||
type NoteReadyToFightInfo struct {
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"blazing/common/socket/errorcode"
|
||||
"blazing/common/utils"
|
||||
"blazing/cool"
|
||||
"blazing/modules/blazing/model"
|
||||
"blazing/modules/config/service"
|
||||
"blazing/modules/player/model"
|
||||
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
@@ -3,7 +3,7 @@ package input
|
||||
import (
|
||||
"blazing/common/utils"
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/modules/blazing/model"
|
||||
"blazing/modules/player/model"
|
||||
|
||||
"fmt"
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package item
|
||||
|
||||
import (
|
||||
"blazing/logic/service/common"
|
||||
"blazing/modules/blazing/model"
|
||||
"blazing/modules/player/model"
|
||||
)
|
||||
|
||||
type ChangePlayerClothOutboundInfo struct {
|
||||
|
||||
@@ -2,12 +2,12 @@ package item
|
||||
|
||||
import (
|
||||
"blazing/logic/service/common"
|
||||
"blazing/modules/blazing/model"
|
||||
"blazing/modules/player/model"
|
||||
)
|
||||
|
||||
// 实现了入站消息接口(Go中通过方法集隐式实现)
|
||||
type ItemListInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2605" struc:"skip"`
|
||||
Head common.TomeeHeader `cmd:"2605|4475" struc:"skip"`
|
||||
// 查询物品id的开始,
|
||||
Param1 uint32
|
||||
// 查询物品id的结尾
|
||||
|
||||
@@ -2,7 +2,7 @@ package item
|
||||
|
||||
import (
|
||||
"blazing/logic/service/common"
|
||||
"blazing/modules/blazing/model"
|
||||
"blazing/modules/player/model"
|
||||
)
|
||||
|
||||
// C2S_USE_PET_ITEM_OUT_OF_FIGHT 客户端→服务端:非战斗场景使用宠物道具
|
||||
|
||||
@@ -2,7 +2,7 @@ package item
|
||||
|
||||
import (
|
||||
"blazing/common/data/xmlres"
|
||||
"blazing/modules/blazing/model"
|
||||
"blazing/modules/player/model"
|
||||
"errors"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
119
logic/service/pet/egg.go
Normal file
119
logic/service/pet/egg.go
Normal file
@@ -0,0 +1,119 @@
|
||||
package pet
|
||||
|
||||
import "blazing/logic/service/common"
|
||||
|
||||
// C2S_GET_BREED_PET 获取繁殖精灵协议
|
||||
// 前端到后端
|
||||
type C2S_GET_BREED_PET struct {
|
||||
Head common.TomeeHeader `cmd:"2364" struc:"skip"`
|
||||
MaleCatchTime uint32 `json:"maleCatchTime"` // 雄性的精灵捕获时间
|
||||
}
|
||||
|
||||
// S2C_GET_BREED_PET 获取繁殖精灵协议
|
||||
// 后端到前端
|
||||
type S2C_GET_BREED_PET struct {
|
||||
FemaleListLen uint32 `struc:"sizeof=FemaleList"`
|
||||
FemaleList []uint32 `json:"femaleList"` // 可繁殖雌性的精灵数组 参数为精灵捕获时间
|
||||
}
|
||||
|
||||
// S2C_GET_BREED_INFO 获取繁殖信息协议
|
||||
// 后端到前端
|
||||
type S2C_GET_BREED_INFO struct {
|
||||
// BreedState 繁殖状态
|
||||
BreedState uint32 `json:"breedState"`
|
||||
// BreedLeftTime 繁殖剩余时间
|
||||
BreedLeftTime uint32 `json:"breedLeftTime"`
|
||||
// BreedCoolTime 繁殖冷却时间
|
||||
BreedCoolTime uint32 `json:"breedCoolTime"`
|
||||
// MalePetCatchTime 雄性精灵捕捉时间
|
||||
MalePetCatchTime uint32 `json:"malePetCatchTime"`
|
||||
// MalePetID 雄性精灵ID
|
||||
MalePetID uint32 `json:"malePetID"`
|
||||
// FeMalePetCatchTime 雌性精灵捕捉时间
|
||||
FeMalePetCatchTime uint32 `json:"feMalePetCatchTime"`
|
||||
// FeMalePetID 雌性精灵ID
|
||||
FeMalePetID uint32 `json:"feMalePetID"`
|
||||
// HatchState 孵化状态
|
||||
HatchState uint32 `json:"hatchState"`
|
||||
// HatchLeftTime 孵化剩余时间
|
||||
HatchLeftTime uint32 `json:"hatchLeftTime"`
|
||||
// EggID 当前孵化的精灵蛋ID
|
||||
EggID uint32 `json:"eggID"`
|
||||
// Intimacy 亲密度 1 = 悲伤 以此类推 ["悲伤","冷淡","平淡","友好","亲密无间"]
|
||||
Intimacy uint32 `json:"intimacy"`
|
||||
}
|
||||
|
||||
// C2S_GET_BREED_INFO 获取繁殖信息协议
|
||||
// 前端到后端无数据 请求协议
|
||||
type C2S_GET_BREED_INFO struct {
|
||||
Head common.TomeeHeader `cmd:"2365" struc:"skip"`
|
||||
}
|
||||
|
||||
// C2S_GET_EGG_LIST 获取精灵蛋数组协议
|
||||
// 前端到后端无数据 请求协议
|
||||
type C2S_GET_EGG_LIST struct {
|
||||
Head common.TomeeHeader `cmd:"2367" struc:"skip"`
|
||||
}
|
||||
|
||||
// S2C_GET_EGG_LIST 获取精灵蛋数组协议
|
||||
// 后端到前端
|
||||
type S2C_GET_EGG_LIST struct {
|
||||
EggListLen uint32 `struc:"sizeof=EggList"`
|
||||
EggList []EggInfo `json:"eggList"` // 精灵蛋数组 跟其他数组一样 需要给有数量
|
||||
}
|
||||
|
||||
// EggInfo 精灵蛋信息
|
||||
type EggInfo struct {
|
||||
OwnerID uint32 `json:"ownerID"` // 所属人ID
|
||||
EggCatchTime uint32 `json:"eggCatchTime"` // 精灵蛋获得时间
|
||||
EggID uint32 `json:"eggID"` // 精灵蛋ID
|
||||
Male uint32 `json:"male"` // 雄性精灵ID
|
||||
Female uint32 `json:"female"` // 雌性精灵ID
|
||||
}
|
||||
|
||||
// C2S_START_HATCH 开始孵化精灵蛋协议
|
||||
// 前端到后端
|
||||
type C2S_START_HATCH struct {
|
||||
Head common.TomeeHeader `cmd:"2368" struc:"skip"`
|
||||
OwnerID uint32 `json:"ownerID"` // 所属人ID
|
||||
EggCatchTime uint32 `json:"eggCatchTime"` // 精灵蛋获得时间
|
||||
}
|
||||
|
||||
// S2C_START_HATCH 开始孵化精灵蛋协议
|
||||
// 后端到前端无数据内容 只有头部信息
|
||||
type S2C_START_HATCH struct {
|
||||
}
|
||||
|
||||
// C2S_EFFECT_HATCH 精灵蛋互动协议
|
||||
// 前端到后端
|
||||
type C2S_EFFECT_HATCH struct {
|
||||
Head common.TomeeHeader `cmd:"2369" struc:"skip"`
|
||||
Index uint32 `json:"index"` // 互动ID 1 2 3 4 4种
|
||||
}
|
||||
|
||||
// S2C_EFFECT_HATCH 精灵蛋互动协议
|
||||
// 后端到前端
|
||||
type S2C_EFFECT_HATCH struct {
|
||||
Intimacy uint32 `json:"intimacy"` // 亲密度 1 = 悲伤 以此类推 ["悲伤","冷淡","平淡","友好","亲密无间"]
|
||||
}
|
||||
|
||||
// C2S_GET_HATCH_PET 获得孵化精灵协议
|
||||
// 前端到后端无数据内容 请求协议
|
||||
type C2S_GET_HATCH_PET struct {
|
||||
Head common.TomeeHeader `cmd:"2370" struc:"skip"`
|
||||
}
|
||||
|
||||
// S2C_GET_HATCH_PET 获得孵化精灵协议
|
||||
// 后端到前端
|
||||
type S2C_GET_HATCH_PET struct {
|
||||
PetID uint32 `json:"petID"` // 精灵ID
|
||||
CatchTime uint32 `json:"catchTime"` // 精灵捕获时间
|
||||
}
|
||||
|
||||
// C2S_START_BREED 开始繁殖协议
|
||||
// 前端到后端
|
||||
type C2S_START_BREED struct {
|
||||
Head common.TomeeHeader `cmd:"2374" struc:"skip"`
|
||||
Male uint32 `json:"male"` // 雄性精灵捕捉时间
|
||||
Female uint32 `json:"female"` // 雌性精灵捕捉时间
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package pet
|
||||
import (
|
||||
"blazing/common/data"
|
||||
"blazing/logic/service/common"
|
||||
"blazing/modules/blazing/model"
|
||||
"blazing/modules/player/model"
|
||||
)
|
||||
|
||||
type GetPetListInboundEmpty struct {
|
||||
|
||||
@@ -3,7 +3,7 @@ package pet
|
||||
import (
|
||||
"blazing/common/data"
|
||||
"blazing/logic/service/common"
|
||||
"blazing/modules/blazing/model"
|
||||
"blazing/modules/player/model"
|
||||
)
|
||||
|
||||
type InInfo struct {
|
||||
|
||||
@@ -2,7 +2,7 @@ package player
|
||||
|
||||
import (
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/modules/blazing/model"
|
||||
"blazing/modules/player/model"
|
||||
)
|
||||
|
||||
type AI_player struct {
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"blazing/common/utils"
|
||||
"blazing/logic/service/common"
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/modules/blazing/model"
|
||||
"blazing/modules/player/model"
|
||||
"math/rand"
|
||||
"time"
|
||||
|
||||
|
||||
@@ -3,36 +3,62 @@ package player
|
||||
import (
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/logic/service/task"
|
||||
"blazing/modules/blazing/model"
|
||||
"blazing/modules/player/model"
|
||||
|
||||
"github.com/pointernil/bitset32"
|
||||
)
|
||||
|
||||
func (p *Player) CompletedTask(taskID int, ot uint32) {
|
||||
|
||||
// 这个是通过总任务去完成,还可以去实现完成分支
|
||||
// boss的完成时限,所以先完成默认的分支,然后完成指定分支
|
||||
func (p *Player) BossCompletedTask(taskID int, ot int) {
|
||||
//完成每日
|
||||
if p.Info.GetTask(taskID) == model.Unaccepted {
|
||||
p.Info.SetTask(taskID, model.Completed) //设置完成任务
|
||||
p.bossgive(taskID, -1)
|
||||
}
|
||||
|
||||
gift := task.GetTaskInfo(uint32(taskID), ot)
|
||||
if gift != nil {
|
||||
p.Service.Task.Exec(uint32(taskID), func(te *model.TaskEX) bool {
|
||||
if te != nil {
|
||||
|
||||
res := &info.S2C_GET_BOSS_MONSTER{
|
||||
BonusID: uint32(taskID),
|
||||
}
|
||||
if gift.Pet != nil {
|
||||
p.Service.Pet.PetAdd(gift.Pet)
|
||||
res.PetID = gift.Pet.ID
|
||||
res.CaptureTm = gift.Pet.CatchTime
|
||||
r := bitset32.From(te.Data)
|
||||
|
||||
}
|
||||
for _, item := range gift.ItemList {
|
||||
success := p.ItemAdd(item.ItemId, item.ItemCnt)
|
||||
if success {
|
||||
res.ItemList = append(res.ItemList, item)
|
||||
}
|
||||
if !r.Test(uint(ot)) {
|
||||
r.Set(uint(ot))
|
||||
p.bossgive(taskID, ot)
|
||||
|
||||
}
|
||||
|
||||
p.SendPackCmd(8004, res)
|
||||
}
|
||||
return true
|
||||
})
|
||||
|
||||
}
|
||||
func (p *Player) bossgive(taskID int, ot int) {
|
||||
gift := task.GetTaskInfo((taskID), ot)
|
||||
if gift != nil {
|
||||
|
||||
res := &info.S2C_GET_BOSS_MONSTER{
|
||||
BonusID: uint32(taskID),
|
||||
}
|
||||
if gift.Pet != nil {
|
||||
p.Service.Pet.PetAdd(gift.Pet)
|
||||
res.PetID = gift.Pet.ID
|
||||
res.CaptureTm = gift.Pet.CatchTime
|
||||
|
||||
}
|
||||
for _, item := range gift.ItemList {
|
||||
success := p.ItemAdd(item.ItemId, item.ItemCnt)
|
||||
if success {
|
||||
res.ItemList = append(res.ItemList, item)
|
||||
}
|
||||
|
||||
}
|
||||
if gift.Title != 0 {
|
||||
p.GiveTitle(gift.Title)
|
||||
|
||||
}
|
||||
|
||||
p.SendPackCmd(8004, res)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package player
|
||||
|
||||
import (
|
||||
"blazing/modules/blazing/model"
|
||||
"blazing/modules/player/model"
|
||||
)
|
||||
|
||||
type Done struct {
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"blazing/cool"
|
||||
"blazing/logic/service/common"
|
||||
"blazing/modules/base/service"
|
||||
"blazing/modules/blazing/model"
|
||||
"blazing/modules/player/model"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"blazing/logic/service/common"
|
||||
"blazing/logic/service/fight/info"
|
||||
|
||||
"blazing/modules/blazing/model"
|
||||
"blazing/modules/player/model"
|
||||
|
||||
"github.com/jinzhu/copier"
|
||||
)
|
||||
|
||||
@@ -13,8 +13,8 @@ import (
|
||||
|
||||
"blazing/modules/base/service"
|
||||
|
||||
blservice "blazing/modules/blazing/service"
|
||||
config "blazing/modules/config/service"
|
||||
blservice "blazing/modules/player/service"
|
||||
"context"
|
||||
|
||||
"github.com/antlabs/timer"
|
||||
@@ -250,3 +250,10 @@ func (p *Player) Cheak(b error) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (p *Player) GiveTitle(id uint32) {
|
||||
p.Service.Title.Give(id)
|
||||
p.SendPackCmd(50005, &info.S2C_50005{
|
||||
Title: id,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package player
|
||||
import (
|
||||
"blazing/common/data/share"
|
||||
"blazing/cool"
|
||||
"blazing/modules/blazing/model"
|
||||
"blazing/modules/player/model"
|
||||
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/logic/service/space"
|
||||
@@ -93,6 +93,17 @@ func (lw *Player) CompleteLogin() {
|
||||
|
||||
}
|
||||
}
|
||||
if lw.Info.MaxPuniLv < 7 {
|
||||
|
||||
for i := 291; i < 297; i++ {
|
||||
|
||||
if lw.Info.GetTask(i) == model.Completed {
|
||||
lw.Info.MaxPuniLv = uint32(i) - 290
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
lw.IsLogin = true
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package room
|
||||
import (
|
||||
"blazing/logic/service/common"
|
||||
"blazing/logic/service/pet"
|
||||
"blazing/modules/blazing/model"
|
||||
"blazing/modules/player/model"
|
||||
)
|
||||
|
||||
// FitmentUseringInboundInfo FitmentUseringInboundInfo类,实现InboundMessage接口
|
||||
|
||||
@@ -2,7 +2,7 @@ package space
|
||||
|
||||
import (
|
||||
"blazing/logic/service/common"
|
||||
"blazing/modules/blazing/model"
|
||||
"blazing/modules/player/model"
|
||||
)
|
||||
|
||||
type ListMapPlayerInboundInfo struct {
|
||||
|
||||
@@ -2,7 +2,7 @@ package info
|
||||
|
||||
import (
|
||||
"blazing/common/data"
|
||||
"blazing/modules/blazing/model"
|
||||
"blazing/modules/player/model"
|
||||
|
||||
"github.com/creasty/defaults"
|
||||
)
|
||||
|
||||
@@ -3,17 +3,18 @@ package task
|
||||
import (
|
||||
"blazing/common/data"
|
||||
|
||||
"blazing/modules/blazing/model"
|
||||
"blazing/modules/config/service"
|
||||
"blazing/modules/player/model"
|
||||
)
|
||||
|
||||
type TaskResult struct {
|
||||
Pet *model.PetInfo `json:"petTypeId" description:"发放的精灵ID"` // 发放的精灵ID,
|
||||
|
||||
ItemList []data.ItemInfo `json:"itemList" description:"发放物品的数组"` // 发放物品的数组,
|
||||
Title uint32 `json:"title" description:"称号奖励"`
|
||||
}
|
||||
|
||||
func GetTaskInfo(id, ot uint32) *TaskResult {
|
||||
func GetTaskInfo(id, ot int) *TaskResult {
|
||||
ret := &TaskResult{}
|
||||
|
||||
r := service.NewTaskService().Get(id, ot)
|
||||
@@ -30,6 +31,10 @@ func GetTaskInfo(id, ot uint32) *TaskResult {
|
||||
iteminfo := service.NewItemService().GetItemCount(itemID)
|
||||
ret.ItemList = append(ret.ItemList, data.ItemInfo{ItemId: iteminfo.ItemId, ItemCnt: iteminfo.ItemCnt})
|
||||
|
||||
}
|
||||
if r.TitleRewardIds != 0 {
|
||||
ret.Title = r.TitleRewardIds
|
||||
|
||||
}
|
||||
|
||||
return ret
|
||||
|
||||
@@ -27,3 +27,12 @@ type ChangePlayerNameOutboundInfo struct {
|
||||
UserID uint32
|
||||
Nickname string `struc:"[16]byte"` // 固定长度16字节
|
||||
}
|
||||
type ChangeTitleInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"3404" struc:"skip"` //玩家登录
|
||||
TileID uint32
|
||||
}
|
||||
|
||||
type ChangeTitleOutboundInfo struct {
|
||||
UserID uint32
|
||||
TileID uint32
|
||||
}
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
package user
|
||||
|
||||
import "blazing/logic/service/common"
|
||||
import (
|
||||
"blazing/logic/service/common"
|
||||
)
|
||||
|
||||
//var _ entity.Blazingservice = (*SidInfo)(nil)
|
||||
|
||||
type SidInfo struct { //这里直接使用组合来实现将传入的原始头部数据和结构体参数序列化
|
||||
Head common.TomeeHeader `cmd:"105" struc:"skip"` //玩家登录
|
||||
|
||||
Sid []byte `struc:"[20]byte"` // 登录会话ID,固定长度16字节
|
||||
Sid []byte `struc:"[16]byte"` // 登录会话ID,固定长度16字节
|
||||
// ret []byte `struc:"skip"`
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package user
|
||||
|
||||
import (
|
||||
"blazing/logic/service/common"
|
||||
"blazing/modules/blazing/model"
|
||||
"blazing/modules/player/model"
|
||||
)
|
||||
|
||||
type SimUserInfoInboundInfo struct {
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"blazing/common/data/share"
|
||||
"blazing/cool"
|
||||
"blazing/logic/service/common"
|
||||
"fmt"
|
||||
|
||||
"blazing/modules/blazing/model"
|
||||
"blazing/modules/player/model"
|
||||
"context"
|
||||
"encoding/hex"
|
||||
|
||||
@@ -23,14 +24,17 @@ func (l *MAIN_LOGIN_IN) CheakSession() bool {
|
||||
// tt, _ := cool.CacheManager.Keys(context.Background())
|
||||
//g.Dump(tt)
|
||||
t1 := hex.EncodeToString(l.Sid)
|
||||
|
||||
t, err := share.ShareManager.GetSession(t1)
|
||||
r, err := cool.CacheManager.Get(context.Background(), fmt.Sprintf("session: %d", l.Head.UserID))
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
share.ShareManager.DeleteSession(t1)
|
||||
glog.Debug(context.Background(), "后端获取", t1, t, err)
|
||||
return t == l.Head.UserID
|
||||
if r.String() != t1 {
|
||||
return false
|
||||
}
|
||||
|
||||
cool.CacheManager.Remove(context.Background(), fmt.Sprintf("session: %d", l.Head.UserID))
|
||||
glog.Debug(context.Background(), "后端获取", t1, err)
|
||||
return true
|
||||
}
|
||||
|
||||
type LoginMSInfo struct {
|
||||
|
||||
31
logic/service/user/cdk.go
Normal file
31
logic/service/user/cdk.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package user
|
||||
|
||||
import "blazing/logic/service/common"
|
||||
|
||||
// C2S_GET_GIFT_COMPLETE 礼品兑换完成协议
|
||||
// 前端到后端
|
||||
type C2S_GET_GIFT_COMPLETE struct {
|
||||
Head common.TomeeHeader `cmd:"2801" struc:"skip"`
|
||||
PassText string `struc:"[16]byte"`
|
||||
}
|
||||
|
||||
// S2C_GET_GIFT_COMPLETE 礼品兑换完成协议
|
||||
// 后端到前端
|
||||
type S2C_GET_GIFT_COMPLETE struct {
|
||||
Flag uint32 `json:"flag"` // 0 代表sdk已被使用 1 表示兑换成功 如果返回0 那么后续数组不需要返回
|
||||
Tile uint32 `json:"tile"`
|
||||
GiftListLen uint32 `struc:"sizeof=GiftList"`
|
||||
GiftList []GiftInfo `json:"giftList"` // 物品id数组
|
||||
PetGiftLen uint32 `struc:"sizeof=PetGift"`
|
||||
PetGift []PetGiftInfo `json:"petGiftList"`
|
||||
}
|
||||
|
||||
// GiftInfo 礼品信息
|
||||
type GiftInfo struct {
|
||||
GiftID uint32 `json:"giftID"` // 就是物品id
|
||||
Count uint32 `json:"count"`
|
||||
}
|
||||
type PetGiftInfo struct {
|
||||
PetID uint32 `json:"petID"`
|
||||
CacthTime uint32 `json:"catchTime"`
|
||||
}
|
||||
@@ -25,6 +25,7 @@ var (
|
||||
r := parser.GetOpt("debug", false)
|
||||
if r.Bool() {
|
||||
g.DB().SetDebug(true)
|
||||
cool.Config.ServerInfo.IsDebug = 1
|
||||
}
|
||||
if cool.IsRedisMode {
|
||||
go cool.ListenFunc(ctx)
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
|
||||
"blazing/modules/base/service"
|
||||
|
||||
blazing "blazing/modules/blazing/service"
|
||||
blazing "blazing/modules/player/service"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
@@ -63,11 +63,16 @@ func (c *BaseSysUserController) GetSession(ctx context.Context, req *SessionReq)
|
||||
|
||||
}
|
||||
|
||||
if cool.Config.ServerInfo.IsDebug != 0 {
|
||||
res.IsDebug = 1
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
type SessionRes struct {
|
||||
UserID int `json:"userid"`
|
||||
Session string `json:"session"`
|
||||
IsDebug int `json:"isDebug"`
|
||||
//Server model.ServerList `json:"server"`
|
||||
}
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
package blazing
|
||||
|
||||
import (
|
||||
_ "blazing/modules/blazing/controller"
|
||||
_ "blazing/modules/blazing/model"
|
||||
_ "blazing/modules/blazing/service"
|
||||
)
|
||||
@@ -1,6 +0,0 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
_ "blazing/modules/blazing/controller/admin"
|
||||
_ "blazing/modules/blazing/controller/app"
|
||||
)
|
||||
@@ -3,6 +3,9 @@ package admin
|
||||
import (
|
||||
"blazing/cool"
|
||||
"blazing/modules/config/service"
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
type ServerController struct {
|
||||
@@ -20,3 +23,22 @@ func init() {
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// quit 退出
|
||||
type QuitSReq struct {
|
||||
g.Meta `path:"/quit" method:"POST"`
|
||||
ID uint32 `json:"id" v:"required#请选择要退出的服务器"`
|
||||
//code 0是非强制,1是强制QuitReq
|
||||
Code int `json:"code" v:"required#请选择退出类型"`
|
||||
}
|
||||
|
||||
func (this *ServerController) Quit(ctx context.Context, req *QuitSReq) (res *cool.BaseRes, err error) {
|
||||
res = &cool.BaseRes{}
|
||||
serv := service.NewServerService().GetServerID(uint16(req.ID))
|
||||
|
||||
aa, ok := cool.GetClient(serv.Port)
|
||||
if ok && aa != nil { //如果已经存在且这个端口已经被存过
|
||||
aa.QuitSelf(req.Code)
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
module blazing/modules/config
|
||||
|
||||
go 1.25.0
|
||||
|
||||
require github.com/aidarkhanov/nanoid/v2 v2.0.0-20210915221554-84fce99176fc // indirect
|
||||
|
||||
2
modules/config/go.sum
Normal file
2
modules/config/go.sum
Normal file
@@ -0,0 +1,2 @@
|
||||
github.com/aidarkhanov/nanoid/v2 v2.0.0-20210915221554-84fce99176fc h1:t/xPF/DMrr51WHT8rpHwMj5Xvle5xceEuRaxIY5kMOs=
|
||||
github.com/aidarkhanov/nanoid/v2 v2.0.0-20210915221554-84fce99176fc/go.mod h1:YF/U48D1yA3AoGGUdRrCV95J/KJBShvR9TyLqQwdtlI=
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
)
|
||||
|
||||
// 表名常量(遵循现有命名规范)
|
||||
const TableNamePlayerPetSpecialEffect = "player_pet_special_effect"
|
||||
const TableNamePlayerPetSpecialEffect = "config_boss_effect"
|
||||
|
||||
// PlayerPetSpecialEffect 精灵特效表(仅包含XML中指定的4个核心字段)
|
||||
// 对应XML中的<NewSeIdx>节点:Idx、Stat、Eid、Args
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
TableNameBossConfig = "config_pet_boss" // BOSS配置表(全量包含基础/奖励/护盾/捕捉/特效/世界野怪/地图费用/战斗通用逻辑)
|
||||
TableNameBossConfig = "config_boss" // BOSS配置表(全量包含基础/奖励/护盾/捕捉/特效/世界野怪/地图费用/战斗通用逻辑)
|
||||
)
|
||||
|
||||
// BossConfig BOSS配置模型(覆盖所有补充的配置项:GBTL/非VIP费用/首场景/战斗通用逻辑)
|
||||
|
||||
@@ -7,26 +7,25 @@ import (
|
||||
|
||||
// 表名常量定义:CDK配置表
|
||||
const (
|
||||
TableNameCDKConfig = "cdk_config" // CDK配置表(记录CDK编号、可兑换次数、奖励配置等核心信息)
|
||||
TableNameCDKConfig = "config_gift_cdk" // CDK配置表(记录CDK编号、可兑换次数、奖励配置等核心信息)
|
||||
)
|
||||
|
||||
// CDKConfig CDK核心配置模型(含可兑换次数,满足查询`where 可兑换次数 != 0`需求)
|
||||
type CDKConfig struct {
|
||||
*cool.Model `json:"-" gorm:"embedded"` // 嵌入通用Model(ID/创建时间/更新时间,不参与json序列化)
|
||||
*cool.Model
|
||||
|
||||
// 核心字段
|
||||
CDKCode string `gorm:"not null;size:64;uniqueIndex;comment:'CDK编号(唯一标识,用于玩家兑换)'" json:"cdk_code" description:"CDK编号"`
|
||||
CDKCode string `gorm:"not null;size:16;uniqueIndex;comment:'CDK编号(唯一标识,用于玩家兑换)'" json:"cdk_code" description:"CDK编号"`
|
||||
|
||||
//cdk可兑换次数,where不等于0
|
||||
ExchangeRemainCount uint32 `gorm:"not null;default:1;comment:'CDK剩余可兑换次数(不能为0才允许兑换,支持查询where !=0)'" json:"exchange_remain_count" description:"剩余可兑换次数"`
|
||||
ExchangeRemainCount int64 `gorm:"not null;default:1;comment:'CDK剩余可兑换次数(不能为0才允许兑换,支持查询where !=0)'" json:"exchange_remain_count" description:"剩余可兑换次数"`
|
||||
ItemRewardIds []uint32 `gorm:"not null;type:json;default:'[]';comment:'绑定奖励物品ID数组,关联item_gift表主键'" json:"item_reward_ids" description:"奖励物品数组"`
|
||||
ElfRewardIds []uint32 `gorm:"not null;type:json;default:'[]';comment:'绑定奖励精灵ID数组,关联config_pet_boss表主键'" json:"elf_reward_ids" description:"奖励精灵数组"`
|
||||
TitleRewardIds uint32 `gorm:"not null;default:0;comment:'绑定奖励称号'" json:"title_reward_ids" description:"绑定奖励称号"`
|
||||
|
||||
// 辅助配置字段
|
||||
ValidStartTime time.Time `gorm:"not null;comment:'CDK有效开始时间'" json:"valid_start_time" description:"有效开始时间"`
|
||||
ValidEndTime time.Time `gorm:"not null;comment:'CDK有效结束时间'" json:"valid_end_time" description:"有效结束时间"`
|
||||
IsEnabled uint32 `gorm:"not null;default:1;comment:'是否启用该CDK(0-禁用 1-启用)'" json:"is_enabled" description:"是否启用"`
|
||||
Remark string `gorm:"size:512;default:'';comment:'CDK备注'" json:"remark" description:"备注信息"`
|
||||
ValidEndTime time.Time `gorm:"not null;comment:'CDK有效结束时间'" json:"valid_end_time" description:"有效结束时间"`
|
||||
|
||||
Remark string `gorm:"size:512;default:'';comment:'CDK备注'" json:"remark" description:"备注信息"`
|
||||
//ItemGift []*ItemGift `gorm:"-" orm:"with:item_id=id"`
|
||||
}
|
||||
|
||||
@@ -41,16 +40,7 @@ func (*CDKConfig) GroupName() string {
|
||||
|
||||
func NewCDKConfig() *CDKConfig {
|
||||
return &CDKConfig{
|
||||
Model: cool.NewModel(),
|
||||
CDKCode: "",
|
||||
|
||||
ExchangeRemainCount: 1, // 剩余可兑换次数默认1,确保不为0
|
||||
ItemRewardIds: []uint32{},
|
||||
ElfRewardIds: []uint32{},
|
||||
ValidStartTime: time.Now(),
|
||||
ValidEndTime: time.Now().AddDate(1, 0, 0), // 默认有效期1年
|
||||
IsEnabled: 1,
|
||||
Remark: "",
|
||||
Model: cool.NewModel(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package model
|
||||
import "blazing/cool"
|
||||
|
||||
const (
|
||||
TableNamePetFusionMaterial = "pet_fusion_material" // 宠物融合材料表(子表)
|
||||
TableNamePetFusionMaterial = "config_fusion_material" // 宠物融合材料表(子表)
|
||||
)
|
||||
|
||||
// PetFusionMaterial 融合材料模型(与配方主表一对一关联)
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
TableNamePetFusion = "pet_fusion" // 宠物融合配方表(主表)
|
||||
TableNamePetFusion = "config_fusion_pet" // 宠物融合配方表(主表)
|
||||
)
|
||||
|
||||
// PetFusion 宠物融合配方主模型(核心配方规则)
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
|
||||
// 表名常量定义:物品奖励表(存储物品奖励的核心配置信息)
|
||||
const (
|
||||
TableNameItemGift = "item_gift" // 物品奖励配置表(包含物品关联、数量、启用状态、扭蛋标识及备注信息)
|
||||
TableNameItemGift = "config_gift_item" // 物品奖励配置表(包含物品关联、数量、启用状态、扭蛋标识及备注信息)
|
||||
)
|
||||
|
||||
// ItemGift 物品奖励基础配置模型(与数据库表 item_gift 字段一一对应,核心存储结构)
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
TableNameMonsterRefresh = "monster_refresh" // 怪物刷新规则表(地图-精灵等级-刷新脚本配置)
|
||||
TableNameMonsterRefresh = "config_monster_refresh" // 怪物刷新规则表(地图-精灵等级-刷新脚本配置)
|
||||
)
|
||||
|
||||
// MonsterRefresh 怪物刷新规则模型(对应前端配置的地图/精灵/等级/脚本配置)
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
TableNameMeleeConfig = "config_pet_melee" // BOSS配置表(全量包含基础/奖励/护盾/捕捉/特效/世界野怪/地图费用/战斗通用逻辑)
|
||||
TableNameMeleeConfig = "config_boss_melee" // BOSS配置表(全量包含基础/奖励/护盾/捕捉/特效/世界野怪/地图费用/战斗通用逻辑)
|
||||
)
|
||||
|
||||
// PetBaseConfig BOSS配置模型(覆盖所有补充的配置项:GBTL/非VIP费用/首场景/战斗通用逻辑)
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
|
||||
// 表名常量定义:精灵奖励表(存储精灵BOSS/普通精灵对应的奖励配置:掉落物品/数量/概率/获取条件等)
|
||||
const (
|
||||
TableNamePetReward = "config_pet_reward" // 精灵奖励配置表(包含基础掉落/稀有奖励/VIP专属奖励/保底机制)
|
||||
TableNamePetReward = "config_gift_pet" // 精灵奖励配置表(包含基础掉落/稀有奖励/VIP专属奖励/保底机制)
|
||||
)
|
||||
|
||||
// PetReward 精灵奖励基础配置模型(核心存储结构,与数据库表字段一一对应)
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
|
||||
// 表名常量定义:炫彩皮肤表
|
||||
const (
|
||||
TableNameColorfulSkin = "colorful_skin" // 炫彩皮肤表(记录炫彩皮肤颜色、光环、绑定精灵等核心配置)
|
||||
TableNameColorfulSkin = "config_shiny" // 炫彩皮肤表(记录炫彩皮肤颜色、光环、绑定精灵等核心配置)
|
||||
)
|
||||
|
||||
// ColorfulSkin 炫彩皮肤核心配置模型(完整保留原有字段,仅更名适配)
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
|
||||
// 表名常量定义:商店配置表
|
||||
const (
|
||||
TableNameShopConfig = "shop_config" // 商店配置表(记录商品信息、价格、库存、分类等)
|
||||
TableNameShopConfig = "config_shop" // 商店配置表(记录商品信息、价格、库存、分类等)
|
||||
)
|
||||
|
||||
// ShopConfig 商店商品核心配置模型
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* @Author: 昔念 12574910+72wo@users.noreply.github.com
|
||||
* @Date: 2025-12-31 02:42:41
|
||||
* @LastEditors: 昔念 12574910+72wo@users.noreply.github.com
|
||||
* @LastEditTime: 2026-01-18 11:37:05
|
||||
* @FilePath: \sun\modules\config\model\task.go
|
||||
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
||||
*/
|
||||
package model
|
||||
|
||||
import (
|
||||
@@ -15,11 +23,13 @@ type TaskConfig struct {
|
||||
|
||||
// 核心字段
|
||||
TaskId uint32 `gorm:"not null;comment:'任务唯一ID'" json:"task_id" description:"任务唯一ID"`
|
||||
OutState uint32 `gorm:"not null;default:0;comment:'任务分支'" json:"out_state" description:"任务分支"`
|
||||
OutState int `gorm:"not null;default:0;comment:'任务分支'" json:"out_state" description:"任务分支"`
|
||||
//父级任务
|
||||
ParentTaskId uint32 `gorm:"not null;default:0;comment:'父级任务ID'" json:"parent_task_id" description:"父级任务ID"`
|
||||
// type(任务类型,0为常规任务,1为日常任务),
|
||||
TaskType uint32 `gorm:"not null;default:0;comment:'任务类型'" json:"task_type" description:"任务类型"`
|
||||
//是否可以被接受TaskConfig
|
||||
IsAcceptable uint32 `gorm:"not null;default:1;comment:'是否可以被接受'" json:"is_acceptable" description:"是否可以被接受"`
|
||||
|
||||
// 奖励配置
|
||||
ItemRewardIds []uint32 `gorm:"not null;type:json;default:'[]';comment:'绑定奖励物品ID数组,关联item_gift表主键'" json:"item_reward_ids" description:"奖励物品数组"`
|
||||
|
||||
@@ -6,9 +6,9 @@ import (
|
||||
|
||||
// -------------------------- 表名常量定义(统一管理所有塔配置表名)--------------------------
|
||||
const (
|
||||
TableNamedARKTowerConfig = "tower_110_config" // 勇者之塔110配置表
|
||||
TableNameTrialTowerConfig = "trial_tower_config" // 试炼之塔500配置表
|
||||
TableNameBraveTowerConfig = "brave_tower_config" // 勇者之塔600配置表
|
||||
TableNamedARKTowerConfig = "config_tower_110" // 勇者之塔110配置表
|
||||
TableNameTrialTowerConfig = "config_tower_500" // 试炼之塔500配置表
|
||||
TableNameBraveTowerConfig = "config_tower_600" // 勇者之塔600配置表
|
||||
)
|
||||
|
||||
// -------------------------- 核心基类:所有塔配置的通用结构 --------------------------
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
)
|
||||
|
||||
// 表名常量(遵循现有命名规范:小写+下划线)
|
||||
const TableNameSignIn = "player_sign_in"
|
||||
const TableNameSignIn = "config_sign_in"
|
||||
|
||||
// SignIn 签到记录表
|
||||
// 核心字段:签到完成状态、状压签到进度、签到奖励脚本
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
)
|
||||
|
||||
// 表名常量(遵循项目现有命名规范)
|
||||
const TableNameMineralCollectionConfig = "mineral_collection_config"
|
||||
const TableNameMineralCollectionConfig = "config_talk"
|
||||
|
||||
// MineralCollectionConfig 挖矿/采集/采摘矿产配置表Model定义
|
||||
// 字段完全匹配数据表结构,包含最小/最大产出核心字段
|
||||
|
||||
@@ -3,7 +3,23 @@ package service
|
||||
import (
|
||||
"blazing/cool"
|
||||
"blazing/modules/config/model"
|
||||
)
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/util/grand"
|
||||
"github.com/google/uuid"
|
||||
) // 1. 扩展字符集:数字+大小写字母+安全符号(避开URL/输入易冲突的符号,如/、?、&)
|
||||
|
||||
const charsetWithSymbol = "0123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghjkmnpqrstuvwxyz"
|
||||
|
||||
func Generate16CharSecure() string {
|
||||
result := make([]byte, 16)
|
||||
for i := 0; i < 16; i++ {
|
||||
|
||||
result[i] = charsetWithSymbol[grand.N(0, len(charsetWithSymbol)-1)]
|
||||
}
|
||||
return string(result)
|
||||
}
|
||||
|
||||
type CdkService struct {
|
||||
*cool.Service
|
||||
@@ -13,6 +29,33 @@ func NewCdkService() *CdkService {
|
||||
return &CdkService{
|
||||
&cool.Service{
|
||||
Model: model.NewCDKConfig(),
|
||||
InsertParam: func(ctx context.Context) g.MapStrAny {
|
||||
uuid.NewV7()
|
||||
return g.MapStrAny{
|
||||
"cdk_code": Generate16CharSecure(),
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
func (s *CdkService) Get(id string) *model.CDKConfig {
|
||||
var item *model.CDKConfig
|
||||
dbm(s.Model).Where("cdk_code", id).WhereNot("exchange_remain_count", 0).Scan(&item)
|
||||
|
||||
return item
|
||||
|
||||
}
|
||||
func (s *CdkService) Set(id string) bool {
|
||||
|
||||
res, err := cool.DBM(s.Model).Where("cdk_code", id).WhereNot("exchange_remain_count", 0).Decrement("exchange_remain_count", 1)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
rows, _ := res.RowsAffected()
|
||||
if rows == 0 {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
|
||||
}
|
||||
|
||||
@@ -23,26 +23,13 @@ func NewTaskService() *TaskService {
|
||||
},
|
||||
}
|
||||
}
|
||||
func (s *TaskService) Get(id, os uint32) *model.TaskConfig {
|
||||
func (s *TaskService) Get(id, os int) *model.TaskConfig {
|
||||
var item []model.TaskConfig
|
||||
dbm(s.Model).Where("task_id", id).Scan(&item)
|
||||
var res *model.TaskConfig
|
||||
if len(item) == 1 { //只有一个直接默认
|
||||
if item[0].OutState == os {
|
||||
res = &item[0]
|
||||
}
|
||||
if item[0].OutState < 10 {
|
||||
res = &item[0]
|
||||
}
|
||||
|
||||
}
|
||||
if len(item) > 1 { //
|
||||
|
||||
for _, v := range item {
|
||||
if v.OutState == os {
|
||||
res = &item[os]
|
||||
return res
|
||||
}
|
||||
for _, v := range item {
|
||||
if v.OutState == os {
|
||||
res = &v
|
||||
|
||||
}
|
||||
|
||||
@@ -53,13 +40,20 @@ func (s *TaskService) Get(id, os uint32) *model.TaskConfig {
|
||||
}
|
||||
func (s *TaskService) GetDaily() []model.TaskConfig {
|
||||
var item []model.TaskConfig
|
||||
cool.DBM(s.Model).Where("task_type", 1).
|
||||
Cache(gdb.CacheOption{
|
||||
// Duration: time.Hour,
|
||||
|
||||
Force: false,
|
||||
}).Scan(&item)
|
||||
dbm(s.Model).Where("task_type", 1).Scan(&item)
|
||||
|
||||
return item
|
||||
|
||||
}
|
||||
func (s *TaskService) IsAcceptable(taskid uint32) bool {
|
||||
|
||||
con, _ := cool.DBM(s.Model).Where("is_acceptable", 1).Where("task_id", taskid).
|
||||
Cache(gdb.CacheOption{
|
||||
// Duration: time.Hour,
|
||||
|
||||
Force: false,
|
||||
}).Count()
|
||||
|
||||
return con > 0
|
||||
|
||||
}
|
||||
|
||||
@@ -68,28 +68,15 @@ func (m *UnifiedTowerModel) GroupName() string {
|
||||
// Boss 根据塔等级获取对应的Boss配置(统一入口)
|
||||
func (s *TowerService) Boss(towerLevel uint32) *model.BaseTowerConfig {
|
||||
// 构建基础查询条件
|
||||
query := cool.DBM(s.Model).Where("tower_level = ?", towerLevel)
|
||||
query := cool.DBM(s.Model).Where("tower_level = ?", towerLevel).Where("is_enabled", 1)
|
||||
|
||||
// 根据塔类型处理不同的缓存逻辑
|
||||
switch s.towerType {
|
||||
case TowerType110, TowerType500:
|
||||
// 110塔和500塔使用普通查询
|
||||
var config model.BaseTowerConfig
|
||||
query.Scan(&config)
|
||||
return &config
|
||||
|
||||
case TowerType600:
|
||||
// 600塔专属的缓存配置
|
||||
var config model.BaseTowerConfig
|
||||
query.Cache(gdb.CacheOption{
|
||||
// Duration: time.Hour, // 可根据需要开启缓存时长
|
||||
Force: false,
|
||||
}).Scan(&config)
|
||||
return &config
|
||||
|
||||
default:
|
||||
return nil // 非支持类型返回nil,也可根据业务需求调整
|
||||
}
|
||||
// 600塔专属的缓存配置
|
||||
var config model.BaseTowerConfig
|
||||
query.Cache(gdb.CacheOption{
|
||||
// Duration: time.Hour, // 可根据需要开启缓存时长
|
||||
Force: false,
|
||||
}).Scan(&config)
|
||||
return &config
|
||||
}
|
||||
|
||||
// 兼容原有调用方式的快捷构造函数(可选,保证代码平滑迁移)
|
||||
@@ -103,4 +90,4 @@ func NewTower500Service() *TowerService {
|
||||
|
||||
func NewTower600Service() *TowerService {
|
||||
return NewTowerService(TowerType600)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@ package modules
|
||||
|
||||
import (
|
||||
_ "blazing/modules/base"
|
||||
_ "blazing/modules/blazing"
|
||||
_ "blazing/modules/config"
|
||||
_ "blazing/modules/dict"
|
||||
_ "blazing/modules/player"
|
||||
_ "blazing/modules/space"
|
||||
_ "blazing/modules/task"
|
||||
)
|
||||
|
||||
7
modules/player/blazing.go
Normal file
7
modules/player/blazing.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package blazing
|
||||
|
||||
import (
|
||||
_ "blazing/modules/player/controller"
|
||||
_ "blazing/modules/player/model"
|
||||
_ "blazing/modules/player/service"
|
||||
)
|
||||
@@ -2,7 +2,7 @@ package admin
|
||||
|
||||
import (
|
||||
"blazing/cool"
|
||||
"blazing/modules/blazing/service"
|
||||
"blazing/modules/player/service"
|
||||
)
|
||||
|
||||
type ItemBagController struct {
|
||||
@@ -2,8 +2,8 @@ package admin
|
||||
|
||||
import (
|
||||
"blazing/cool"
|
||||
"blazing/modules/blazing/model"
|
||||
"blazing/modules/blazing/service"
|
||||
"blazing/modules/player/model"
|
||||
"blazing/modules/player/service"
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
@@ -2,7 +2,7 @@ package admin
|
||||
|
||||
import (
|
||||
"blazing/cool"
|
||||
"blazing/modules/blazing/service"
|
||||
"blazing/modules/player/service"
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
50
modules/player/controller/admin/title.go
Normal file
50
modules/player/controller/admin/title.go
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* @Author: 昔念 12574910+72wo@users.noreply.github.com
|
||||
* @Date: 2026-01-18 11:55:13
|
||||
* @LastEditors: 昔念 12574910+72wo@users.noreply.github.com
|
||||
* @LastEditTime: 2026-01-18 11:59:32
|
||||
* @FilePath: \sun\modules\blazing\controller\admin\title.go
|
||||
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
||||
*/
|
||||
package admin
|
||||
|
||||
import (
|
||||
"blazing/cool"
|
||||
"blazing/modules/player/service"
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
type TitleController struct {
|
||||
*cool.Controller
|
||||
}
|
||||
|
||||
func init() {
|
||||
var task_info_controller = &TitleController{
|
||||
&cool.Controller{
|
||||
Prefix: "/admin/game/title",
|
||||
Api: []string{"Delete", "Update", "Info", "List", "Page"},
|
||||
Service: service.NewItemService(0), //因为page已经过滤,所以这里需要改成0
|
||||
},
|
||||
}
|
||||
// 注册路由
|
||||
cool.RegisterController(task_info_controller)
|
||||
}
|
||||
|
||||
type GetReq struct {
|
||||
g.Meta `path:"/get" method:"POST"`
|
||||
ID uint32 `json:"id"`
|
||||
}
|
||||
|
||||
func (c *TitleController) Get(ctx context.Context, req *GetReq) (res *cool.BaseRes, err error) {
|
||||
res = &cool.BaseRes{}
|
||||
var (
|
||||
admin = cool.GetAdmin(ctx)
|
||||
//r = g.RequestFromCtx(ctx)
|
||||
)
|
||||
|
||||
res.Data = service.NewUserService(uint32(admin.UserId)).Title.Get()
|
||||
return
|
||||
|
||||
}
|
||||
@@ -3,8 +3,8 @@ package app
|
||||
import (
|
||||
"blazing/cool"
|
||||
baseservice "blazing/modules/base/service"
|
||||
blazing "blazing/modules/blazing/service"
|
||||
"blazing/modules/config/service"
|
||||
blazing "blazing/modules/player/service"
|
||||
|
||||
"context"
|
||||
"fmt"
|
||||
6
modules/player/controller/controller.go
Normal file
6
modules/player/controller/controller.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
_ "blazing/modules/player/controller/admin"
|
||||
_ "blazing/modules/player/controller/app"
|
||||
)
|
||||
@@ -1,4 +1,4 @@
|
||||
module blazing/modules/blazing
|
||||
module blazing/modules/player
|
||||
|
||||
go 1.20
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
|
||||
// 表名常量定义:精灵捕捉击杀数量记录表
|
||||
const (
|
||||
TableNamePetCatchKillCount = "pet_catch_kill_count" // 精灵捕捉击杀数量表(记录每个精灵的捕捉总数量、击杀总数量)
|
||||
TableNamePetCatchKillCount = "player_catch_kill_count" // 精灵捕捉击杀数量表(记录每个精灵的捕捉总数量、击杀总数量)
|
||||
)
|
||||
|
||||
// PetBargeListInfo 精灵捕捉击杀数量核心模型(简化版,直接记录数量,摒弃状态判断)
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
|
||||
// 表名常量定义:金豆消费记录表
|
||||
const (
|
||||
TableNameGoldBeanConsume = "gold_bean_consume_record" // 金豆消费记录表(记录用户金豆消耗的明细、类型、关联业务等信息)
|
||||
TableNameGoldBeanConsume = "player_gold_log" // 金豆消费记录表(记录用户金豆消耗的明细、类型、关联业务等信息)
|
||||
)
|
||||
|
||||
// 通过金豆消费时间来确认金豆物品的购买重置周期
|
||||
37
modules/player/model/cdk.go
Normal file
37
modules/player/model/cdk.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"blazing/cool"
|
||||
)
|
||||
|
||||
// 表名常量
|
||||
const TableNamePlayerCdkLog = "player_cdk_log"
|
||||
|
||||
// CdkLog 对应数据库表 player_cdk_log,用于记录CDK兑换日志
|
||||
type CdkLog struct {
|
||||
Base
|
||||
PlayerID uint64 `gorm:"not null;index:idx_player_cdk_log_by_player_id;comment:'所属玩家ID'" json:"player_id"`
|
||||
CodeID uint32 `gorm:"not null;comment:'CDK编号'" json:"code_id"`
|
||||
}
|
||||
|
||||
// TableName 返回表名
|
||||
func (*CdkLog) TableName() string {
|
||||
return TableNamePlayerCdkLog
|
||||
}
|
||||
|
||||
// GroupName 返回表组名
|
||||
func (*CdkLog) GroupName() string {
|
||||
return "default"
|
||||
}
|
||||
|
||||
// NewCdkLog 创建一个新的CDK记录
|
||||
func NewCdkLog() *CdkLog {
|
||||
return &CdkLog{
|
||||
Base: *NewBase(),
|
||||
}
|
||||
}
|
||||
|
||||
// init 程序启动时自动创建表
|
||||
func init() {
|
||||
cool.CreateTable(&CdkLog{})
|
||||
}
|
||||
@@ -17,16 +17,7 @@ var MilestoneMode = enum.New[struct {
|
||||
Task EnumMilestone
|
||||
}]()
|
||||
|
||||
// 里程碑数据结构,与DoneEvent对应,记录单条里程碑的详细信息
|
||||
// type MilestoneData struct {
|
||||
// DoneType EnumMilestone `json:"done_type"` // 里程碑类型(如:0-地图解锁,1-BOSS击杀,2-物品收集等)
|
||||
// Args []uint32 `json:"args"` // 关联ID列表(如地图ID、BOSSID、物品ID等)
|
||||
// Results []uint32 `json:"results"` // 完成情况参数(如:击杀次数、收集数量阈值等)
|
||||
// Count uint32 `json:"count"` // 累计完成次数(如:某BOSS累计击杀3次)
|
||||
// //IsCompleted bool `json:"is_completed"` // 是否完全达成(用于区分阶段性里程碑)
|
||||
// }
|
||||
|
||||
const TableNameMilestone = "milestone"
|
||||
const TableNameMilestone = "player_milestone"
|
||||
|
||||
// Milestone 数据库存储结构体,映射milestone表
|
||||
type Milestone struct {
|
||||
@@ -1,51 +1,51 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"blazing/cool"
|
||||
)
|
||||
|
||||
const TableNamePlayerBagItem = "player_bag_item"
|
||||
|
||||
// PlayerBagItem mapped from table <player_bag_item>
|
||||
type Item struct {
|
||||
Base
|
||||
PlayerID uint64 `gorm:"not null;index:idx_player_bag_item_by_player_id;comment:'所属玩家ID'" json:"player_id"`
|
||||
// 物品Id,
|
||||
ItemId uint32 `json:"item_id"`
|
||||
|
||||
// 物品数量,
|
||||
ItemCnt uint32 `json:"item_cnt"`
|
||||
}
|
||||
|
||||
type SingleItemInfo struct {
|
||||
// 物品Id,
|
||||
ItemId uint32 `json:"itemId"`
|
||||
// 物品数量,
|
||||
ItemCnt uint32 `json:"itemCnt"`
|
||||
// 固定值360000,
|
||||
LeftTime uint32 `json:"leftTime"`
|
||||
// 固定值0,
|
||||
ItemLevel uint32 `json:"itemLevel"`
|
||||
}
|
||||
|
||||
// TableName PlayerBagItem's table name
|
||||
func (*Item) TableName() string {
|
||||
return TableNamePlayerBagItem
|
||||
}
|
||||
|
||||
// GroupName PlayerBagItem's table group
|
||||
func (*Item) GroupName() string {
|
||||
return "default"
|
||||
}
|
||||
|
||||
// NewPlayerBagItem create a new PlayerBagItem
|
||||
func NewPlayerBag() *Item {
|
||||
return &Item{
|
||||
Base: *NewBase(),
|
||||
}
|
||||
}
|
||||
|
||||
// init 创建表
|
||||
func init() {
|
||||
cool.CreateTable(&Item{})
|
||||
}
|
||||
package model
|
||||
|
||||
import (
|
||||
"blazing/cool"
|
||||
)
|
||||
|
||||
const TableNamePlayerBagItem = "player_item"
|
||||
|
||||
// PlayerBagItem mapped from table <player_bag_item>
|
||||
type Item struct {
|
||||
Base
|
||||
PlayerID uint64 `gorm:"not null;index:idx_player_bag_item_by_player_id;comment:'所属玩家ID'" json:"player_id"`
|
||||
// 物品Id,
|
||||
ItemId uint32 `json:"item_id"`
|
||||
|
||||
// 物品数量,
|
||||
ItemCnt uint32 `json:"item_cnt"`
|
||||
}
|
||||
|
||||
type SingleItemInfo struct {
|
||||
// 物品Id,
|
||||
ItemId uint32 `json:"itemId"`
|
||||
// 物品数量,
|
||||
ItemCnt uint32 `json:"itemCnt"`
|
||||
// 固定值360000,
|
||||
LeftTime uint32 `json:"leftTime"`
|
||||
// 固定值0,
|
||||
ItemLevel uint32 `json:"itemLevel"`
|
||||
}
|
||||
|
||||
// TableName PlayerBagItem's table name
|
||||
func (*Item) TableName() string {
|
||||
return TableNamePlayerBagItem
|
||||
}
|
||||
|
||||
// GroupName PlayerBagItem's table group
|
||||
func (*Item) GroupName() string {
|
||||
return "default"
|
||||
}
|
||||
|
||||
// NewPlayerBagItem create a new PlayerBagItem
|
||||
func NewPlayerBag() *Item {
|
||||
return &Item{
|
||||
Base: *NewBase(),
|
||||
}
|
||||
}
|
||||
|
||||
// init 创建表
|
||||
func init() {
|
||||
cool.CreateTable(&Item{})
|
||||
}
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
"github.com/samber/lo"
|
||||
)
|
||||
|
||||
const TableNamePet = "pet"
|
||||
const TableNamePet = "player_pet"
|
||||
|
||||
// Pet mapped from table <pet>
|
||||
type Pet struct {
|
||||
@@ -54,6 +54,8 @@ type PetInfo struct {
|
||||
|
||||
// 名字:默认为全0,补齐到16字节(固定长度 → [16]byte)
|
||||
Name string `struc:"[16]byte" json:"Name,omitempty"`
|
||||
//generation
|
||||
Generation uint32 `fieldDesc:"世代" `
|
||||
|
||||
// 个体值(@UInt long → uint32)
|
||||
Dv uint32 `struc:"uint32" `
|
||||
@@ -128,10 +130,10 @@ const (
|
||||
// 功能:为宠物6个EV值增加增量,保证单个≤255、总和≤510
|
||||
// 参数:evadd - 6个EV字段的增量数组(长度必须为6)
|
||||
// 返回:error - 参数非法/逻辑异常时返回错误;bool - 是否触发了超额削减(方便业务监控)
|
||||
func (pet *PetInfo) AddEV(evadd []uint32) (bool, error) {
|
||||
func (pet *PetInfo) AddEV(ev_add []uint32) (bool, error) {
|
||||
// 1. 参数安全校验:避免数组越界panic
|
||||
if len(evadd) != evFieldCount {
|
||||
return false, fmt.Errorf("evadd长度必须为%d,当前为%d", evFieldCount, len(evadd))
|
||||
if len(ev_add) != evFieldCount {
|
||||
return false, fmt.Errorf("evadd长度必须为%d,当前为%d", evFieldCount, len(ev_add))
|
||||
}
|
||||
if len(pet.Ev) != evFieldCount {
|
||||
return false, errors.New("pet.Ev未初始化或长度不为6")
|
||||
@@ -141,7 +143,7 @@ func (pet *PetInfo) AddEV(evadd []uint32) (bool, error) {
|
||||
var tempEV [evFieldCount]uint32
|
||||
for i := 0; i < evFieldCount; i++ {
|
||||
// 直接累加增量
|
||||
tempEV[i] = pet.Ev[i] + evadd[i]
|
||||
tempEV[i] = pet.Ev[i] + ev_add[i]
|
||||
// 单项不超过255
|
||||
if tempEV[i] > maxSingleEV {
|
||||
tempEV[i] = maxSingleEV
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user