mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-02-04 15:52:27 +08:00
拆分了聊天数据,减小玩家数据结构大小
This commit is contained in:
@@ -9,24 +9,24 @@ import (
|
||||
)
|
||||
|
||||
type Avatar struct {
|
||||
AvatarId uint32 `bson:"avatarId"` // 角色id
|
||||
LifeState uint16 `bson:"lifeState"` // 存活状态
|
||||
Level uint8 `bson:"level"` // 等级
|
||||
Exp uint32 `bson:"exp"` // 经验值
|
||||
Promote uint8 `bson:"promote"` // 突破等阶
|
||||
Satiation uint32 `bson:"satiation"` // 饱食度
|
||||
SatiationPenalty uint32 `bson:"satiationPenalty"` // 饱食度溢出
|
||||
CurrHP float64 `bson:"currHP"` // 当前生命值
|
||||
CurrEnergy float64 `bson:"currEnergy"` // 当前元素能量值
|
||||
FetterList []uint32 `bson:"fetterList"` // 资料解锁条目
|
||||
SkillLevelMap map[uint32]uint32 `bson:"skillLevelMap"` // 技能等级数据
|
||||
SkillDepotId uint32 `bson:"skillDepotId"` // 技能库id
|
||||
FlyCloak uint32 `bson:"flyCloak"` // 当前风之翼
|
||||
Costume uint32 `bson:"costume"` // 当前衣装
|
||||
BornTime int64 `bson:"bornTime"` // 获得时间
|
||||
FetterLevel uint8 `bson:"fetterLevel"` // 好感度等级
|
||||
FetterExp uint32 `bson:"fetterExp"` // 好感度经验
|
||||
PromoteRewardMap map[uint32]bool `bson:"promoteRewardMap"` // 突破奖励 map[突破等级]是否已被领取
|
||||
AvatarId uint32 // 角色id
|
||||
LifeState uint16 // 存活状态
|
||||
Level uint8 // 等级
|
||||
Exp uint32 // 经验值
|
||||
Promote uint8 // 突破等阶
|
||||
Satiation uint32 // 饱食度
|
||||
SatiationPenalty uint32 // 饱食度溢出
|
||||
CurrHP float64 // 当前生命值
|
||||
CurrEnergy float64 // 当前元素能量值
|
||||
FetterList []uint32 // 资料解锁条目
|
||||
SkillLevelMap map[uint32]uint32 // 技能等级数据
|
||||
SkillDepotId uint32 // 技能库id
|
||||
FlyCloak uint32 // 当前风之翼
|
||||
Costume uint32 // 当前衣装
|
||||
BornTime int64 // 获得时间
|
||||
FetterLevel uint8 // 好感度等级
|
||||
FetterExp uint32 // 好感度经验
|
||||
PromoteRewardMap map[uint32]bool // 突破奖励 map[突破等级]是否已被领取
|
||||
Guid uint64 `bson:"-" msgpack:"-"`
|
||||
EquipGuidMap map[uint64]uint64 `bson:"-" msgpack:"-"`
|
||||
EquipWeapon *Weapon `bson:"-" msgpack:"-"`
|
||||
|
||||
@@ -6,11 +6,11 @@ const (
|
||||
)
|
||||
|
||||
type ChatMsg struct {
|
||||
Time uint32 `bson:"time"`
|
||||
ToUid uint32 `bson:"toUid"`
|
||||
Uid uint32 `bson:"uid"`
|
||||
IsRead bool `bson:"isRead"`
|
||||
MsgType uint8 `bson:"msgType"`
|
||||
Text string `bson:"text"`
|
||||
Icon uint32 `bson:"icon"`
|
||||
Time uint32
|
||||
ToUid uint32
|
||||
Uid uint32
|
||||
IsRead bool
|
||||
MsgType uint8
|
||||
Text string
|
||||
Icon uint32
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package model
|
||||
|
||||
type GachaPoolInfo struct {
|
||||
GachaType uint32 `bson:"gachaType"` // 卡池类型
|
||||
OrangeTimes uint32 `bson:"orangeTimes"` // 5星保底计数
|
||||
PurpleTimes uint32 `bson:"purpleTimes"` // 4星保底计数
|
||||
MustGetUpOrange bool `bson:"mustGetUpOrange"` // 是否5星大保底
|
||||
MustGetUpPurple bool `bson:"mustGetUpPurple"` // 是否4星大保底
|
||||
GachaType uint32 // 卡池类型
|
||||
OrangeTimes uint32 // 5星保底计数
|
||||
PurpleTimes uint32 // 4星保底计数
|
||||
MustGetUpOrange bool // 是否5星大保底
|
||||
MustGetUpPurple bool // 是否4星大保底
|
||||
}
|
||||
|
||||
type DropInfo struct {
|
||||
GachaPoolInfo map[uint32]*GachaPoolInfo `bson:"gachaPoolInfo"`
|
||||
GachaPoolInfo map[uint32]*GachaPoolInfo
|
||||
}
|
||||
|
||||
func NewDropInfo() (r *DropInfo) {
|
||||
|
||||
@@ -2,61 +2,61 @@ package model
|
||||
|
||||
// GCGCard 卡牌
|
||||
type GCGCard struct {
|
||||
CardId uint32 `bson:"cardId"` // 卡牌Id
|
||||
Num uint32 `bson:"num"` // 数量
|
||||
FaceType uint32 `bson:"faceType"` // 卡面类型
|
||||
UnlockFaceTypeList []uint32 `bson:"unlockFaceTypeList"` // 解锁的卡面类型
|
||||
Proficiency uint32 `bson:"proficiency"` // 熟练程度等级
|
||||
ProficiencyRewardTakenIdxList []uint32 `bson:"faceType"` // 熟练程度奖励列表
|
||||
CardId uint32 // 卡牌Id
|
||||
Num uint32 // 数量
|
||||
FaceType uint32 // 卡面类型
|
||||
UnlockFaceTypeList []uint32 // 解锁的卡面类型
|
||||
Proficiency uint32 // 熟练程度等级
|
||||
ProficiencyRewardTakenIdxList []uint32 // 熟练程度奖励列表
|
||||
}
|
||||
|
||||
// GCGDeck 卡组
|
||||
type GCGDeck struct {
|
||||
Name string `bson:"name"` // 卡组名
|
||||
CharacterCardList []uint32 `bson:"characterCardList"` // 角色牌列表
|
||||
CardList []uint32 `bson:"cardList"` // 卡牌列表
|
||||
FieldId uint32 `bson:"fieldId"` // 牌盒样式Id
|
||||
CardBackId uint32 `bson:"cardBackId"` // 牌背样式Id
|
||||
CreateTime int64 `bson:"createTime"` // 卡组创建时间
|
||||
Name string // 卡组名
|
||||
CharacterCardList []uint32 // 角色牌列表
|
||||
CardList []uint32 // 卡牌列表
|
||||
FieldId uint32 // 牌盒样式Id
|
||||
CardBackId uint32 // 牌背样式Id
|
||||
CreateTime int64 // 卡组创建时间
|
||||
}
|
||||
|
||||
// GCGTavernChallenge 酒馆挑战信息
|
||||
type GCGTavernChallenge struct {
|
||||
CharacterId uint32 `bson:"characterId"` // 角色Id
|
||||
UnlockLevelIdList []uint32 `bson:"unlockLevelIdList"` // 解锁的等级Id
|
||||
CharacterId uint32 // 角色Id
|
||||
UnlockLevelIdList []uint32 // 解锁的等级Id
|
||||
}
|
||||
|
||||
// GCGBossChallenge Boss挑战信息
|
||||
type GCGBossChallenge struct {
|
||||
Id uint32 `bson:"Id"` // BossId
|
||||
UnlockLevelIdList []uint32 `bson:"unlockLevelIdList"` // 解锁的等级Id
|
||||
Id uint32 // BossId
|
||||
UnlockLevelIdList []uint32 // 解锁的等级Id
|
||||
}
|
||||
|
||||
// GCGLevelChallenge 等级挑战信息
|
||||
type GCGLevelChallenge struct {
|
||||
LevelId uint32 `bson:"levelId"` // 等级Id
|
||||
FinishedChallengeIdList []uint32 `bson:"finishedChallengeIdList"` // 完成的挑战Id列表
|
||||
LevelId uint32 // 等级Id
|
||||
FinishedChallengeIdList []uint32 // 完成的挑战Id列表
|
||||
}
|
||||
|
||||
// GCGInfo 七圣召唤信息
|
||||
type GCGInfo struct {
|
||||
// 基础信息
|
||||
Level uint32 `bson:"level"` // 等级
|
||||
Exp uint32 `bson:"exp"` // 经验
|
||||
Level uint32 // 等级
|
||||
Exp uint32 // 经验
|
||||
// 卡牌
|
||||
CardList map[uint32]*GCGCard `bson:"cardList"` // 拥有的卡牌 uint32 -> CardId(卡牌Id)
|
||||
CurDeckId uint32 `bson:"CurDeckId"` // 现行的卡组Id
|
||||
DeckList []*GCGDeck `bson:"deckList"` // 卡组列表
|
||||
UnlockDeckIdList []uint32 `bson:"unlockDeckIdList"` // 解锁的卡组
|
||||
UnlockCardBackIdList []uint32 `bson:"unlockCardBackIdList"` // 解锁的卡背
|
||||
UnlockFieldIdList []uint32 `bson:"unlockFieldIdList"` // 解锁的牌盒
|
||||
CardList map[uint32]*GCGCard // 拥有的卡牌 uint32 -> CardId(卡牌Id)
|
||||
CurDeckId uint32 // 现行的卡组Id
|
||||
DeckList []*GCGDeck // 卡组列表
|
||||
UnlockDeckIdList []uint32 // 解锁的卡组
|
||||
UnlockCardBackIdList []uint32 // 解锁的卡背
|
||||
UnlockFieldIdList []uint32 // 解锁的牌盒
|
||||
// 挑战
|
||||
TavernChallengeMap map[uint32]*GCGTavernChallenge `bson:"tavernChallengeMap"` // 酒馆挑战 uint32 -> CharacterId(角色Id)
|
||||
LevelChallengeMap map[uint32]*GCGLevelChallenge `bson:"levelChallengeMap"` // 等级挑战 uint32 -> LevelId(等级Id)
|
||||
UnlockBossChallengeMap map[uint32]*GCGBossChallenge `bson:"unlockBossChallengeMap"` // 解锁的Boss挑战 uint32 -> Id
|
||||
UnlockWorldChallengeList []uint32 `bson:"unlockWorldChallengeList"` // 解锁的世界挑战
|
||||
TavernChallengeMap map[uint32]*GCGTavernChallenge // 酒馆挑战 uint32 -> CharacterId(角色Id)
|
||||
LevelChallengeMap map[uint32]*GCGLevelChallenge // 等级挑战 uint32 -> LevelId(等级Id)
|
||||
UnlockBossChallengeMap map[uint32]*GCGBossChallenge // 解锁的Boss挑战 uint32 -> Id
|
||||
UnlockWorldChallengeList []uint32 // 解锁的世界挑战
|
||||
// 其他
|
||||
BanCardList []uint32 `bson:"banCardList"` // 被禁止的卡牌列表
|
||||
BanCardList []uint32 // 被禁止的卡牌列表
|
||||
}
|
||||
|
||||
func NewGCGInfo() *GCGInfo {
|
||||
|
||||
@@ -3,8 +3,8 @@ package model
|
||||
import "hk4e/common/constant"
|
||||
|
||||
type Item struct {
|
||||
ItemId uint32 `bson:"itemId"` // 道具id
|
||||
Count uint32 `bson:"count"` // 道具数量
|
||||
ItemId uint32 // 道具id
|
||||
Count uint32 // 道具数量
|
||||
Guid uint64 `bson:"-" msgpack:"-"`
|
||||
}
|
||||
|
||||
|
||||
@@ -26,36 +26,34 @@ type GameObject interface {
|
||||
type Player struct {
|
||||
// 离线数据 请尽量不要定义接口等复杂数据结构
|
||||
ID primitive.ObjectID `bson:"_id,omitempty"`
|
||||
PlayerID uint32 `bson:"playerID"` // 玩家uid
|
||||
NickName string `bson:"nickname"` // 玩家昵称
|
||||
Signature string `bson:"signature"` // 玩家签名
|
||||
HeadImage uint32 `bson:"headImage"` // 玩家头像
|
||||
Birthday []uint8 `bson:"birthday"` // 生日
|
||||
NameCard uint32 `bson:"nameCard"` // 当前名片
|
||||
NameCardList []uint32 `bson:"nameCardList"` // 已解锁名片列表
|
||||
FriendList map[uint32]bool `bson:"friendList"` // 好友uid列表
|
||||
FriendApplyList map[uint32]bool `bson:"friendApplyList"` // 好友申请uid列表
|
||||
OfflineTime uint32 `bson:"offlineTime"` // 离线时间点
|
||||
OnlineTime uint32 `bson:"onlineTime"` // 上线时间点
|
||||
TotalOnlineTime uint32 `bson:"totalOnlineTime"` // 玩家累计在线时长
|
||||
PropertiesMap map[uint16]uint32 `bson:"propertiesMap"` // 玩家自身相关的一些属性
|
||||
RegionId uint32 `bson:"regionId"` // regionId
|
||||
FlyCloakList []uint32 `bson:"flyCloakList"` // 风之翼列表
|
||||
CostumeList []uint32 `bson:"costumeList"` // 角色衣装列表
|
||||
SceneId uint32 `bson:"sceneId"` // 场景
|
||||
SafePos *Vector `bson:"safePos"` // 玩家在陆地时的坐标
|
||||
Pos *Vector `bson:"pos"` // 玩家坐标
|
||||
Rot *Vector `bson:"rot"` // 玩家朝向
|
||||
ItemMap map[uint32]*Item `bson:"itemMap"` // 玩家统一大背包仓库
|
||||
WeaponMap map[uint64]*Weapon `bson:"weaponMap"` // 玩家武器背包
|
||||
ReliquaryMap map[uint64]*Reliquary `bson:"reliquaryMap"` // 玩家圣遗物背包
|
||||
TeamConfig *TeamInfo `bson:"teamConfig"` // 队伍配置
|
||||
AvatarMap map[uint32]*Avatar `bson:"avatarMap"` // 角色信息
|
||||
DropInfo *DropInfo `bson:"dropInfo"` // 掉落信息
|
||||
MainCharAvatarId uint32 `bson:"mainCharAvatarId"` // 主角id
|
||||
ChatMsgMap map[uint32][]*ChatMsg `bson:"chatMsgMap"` // 聊天信息
|
||||
GCGInfo *GCGInfo `bson:"gcgInfo"` // 七圣召唤信息
|
||||
IsGM uint8 `bson:"isGM"` // 管理员权限等级
|
||||
PlayerID uint32 `bson:"PlayerID"` // 玩家uid
|
||||
NickName string // 玩家昵称
|
||||
Signature string // 玩家签名
|
||||
HeadImage uint32 // 玩家头像
|
||||
Birthday []uint8 // 生日
|
||||
NameCard uint32 // 当前名片
|
||||
NameCardList []uint32 // 已解锁名片列表
|
||||
FriendList map[uint32]bool // 好友uid列表
|
||||
FriendApplyList map[uint32]bool // 好友申请uid列表
|
||||
OfflineTime uint32 // 离线时间点
|
||||
OnlineTime uint32 // 上线时间点
|
||||
TotalOnlineTime uint32 // 玩家累计在线时长
|
||||
PropertiesMap map[uint16]uint32 // 玩家自身相关的一些属性
|
||||
FlyCloakList []uint32 // 风之翼列表
|
||||
CostumeList []uint32 // 角色衣装列表
|
||||
SceneId uint32 // 场景
|
||||
SafePos *Vector // 玩家在陆地时的坐标
|
||||
Pos *Vector // 玩家坐标
|
||||
Rot *Vector // 玩家朝向
|
||||
ItemMap map[uint32]*Item // 玩家统一大背包仓库
|
||||
WeaponMap map[uint64]*Weapon // 玩家武器背包
|
||||
ReliquaryMap map[uint64]*Reliquary // 玩家圣遗物背包
|
||||
TeamConfig *TeamInfo // 队伍配置
|
||||
AvatarMap map[uint32]*Avatar // 角色信息
|
||||
DropInfo *DropInfo // 掉落信息
|
||||
MainCharAvatarId uint32 // 主角id
|
||||
GCGInfo *GCGInfo // 七圣召唤信息
|
||||
IsGM uint8 // 管理员权限等级
|
||||
// 在线数据 请随意 记得加忽略字段的tag
|
||||
LastSaveTime uint32 `bson:"-" msgpack:"-"` // 上一次保存时间
|
||||
EnterSceneToken uint32 `bson:"-" msgpack:"-"` // 玩家的世界进入令牌
|
||||
@@ -79,6 +77,8 @@ type Player struct {
|
||||
GateAppId string `bson:"-" msgpack:"-"` // 网关服务器的appid
|
||||
FightAppId string `bson:"-" msgpack:"-"` // 战斗服务器的appid
|
||||
GCGCurGameGuid uint32 `bson:"-" msgpack:"-"` // GCG玩家所在的游戏guid
|
||||
// 特殊数据
|
||||
ChatMsgMap map[uint32][]*ChatMsg `bson:"-" msgpack:"-"` // 聊天信息 数据量偏大 只从db读写 不保存到redis
|
||||
}
|
||||
|
||||
func (p *Player) GetNextGameObjectGuid() uint64 {
|
||||
|
||||
@@ -6,15 +6,15 @@ import (
|
||||
)
|
||||
|
||||
type Reliquary struct {
|
||||
ReliquaryId uint64 `bson:"reliquaryId"` // 圣遗物的唯一id
|
||||
ItemId uint32 `bson:"itemId"` // 圣遗物的道具id
|
||||
Level uint8 `bson:"level"` // 等级
|
||||
Exp uint32 `bson:"exp"` // 当前经验值
|
||||
Promote uint8 `bson:"promote"` // 突破等阶
|
||||
Lock bool `bson:"lock"` // 锁定状态
|
||||
AffixIdList []uint32 `bson:"affixIdList"` // 词缀
|
||||
MainPropId uint32 `bson:"mainPropId"` // 主词条id
|
||||
AvatarId uint32 `bson:"avatarId"` // 装备角色id
|
||||
ReliquaryId uint64 // 圣遗物的唯一id
|
||||
ItemId uint32 // 圣遗物的道具id
|
||||
Level uint8 // 等级
|
||||
Exp uint32 // 当前经验值
|
||||
Promote uint8 // 突破等阶
|
||||
Lock bool // 锁定状态
|
||||
AffixIdList []uint32 // 词缀
|
||||
MainPropId uint32 // 主词条id
|
||||
AvatarId uint32 // 装备角色id
|
||||
Guid uint64 `bson:"-" msgpack:"-"`
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
)
|
||||
|
||||
type Team struct {
|
||||
Name string `bson:"name"`
|
||||
AvatarIdList []uint32 `bson:"avatarIdList"`
|
||||
Name string
|
||||
AvatarIdList []uint32
|
||||
}
|
||||
|
||||
func (t *Team) GetAvatarIdList() []uint32 {
|
||||
@@ -33,9 +33,9 @@ func (t *Team) SetAvatarIdList(avatarIdList []uint32) {
|
||||
}
|
||||
|
||||
type TeamInfo struct {
|
||||
TeamList []*Team `bson:"teamList"`
|
||||
CurrTeamIndex uint8 `bson:"currTeamIndex"`
|
||||
CurrAvatarIndex uint8 `bson:"currAvatarIndex"`
|
||||
TeamList []*Team
|
||||
CurrTeamIndex uint8
|
||||
CurrAvatarIndex uint8
|
||||
TeamResonances map[uint16]bool `bson:"-" msgpack:"-"`
|
||||
TeamResonancesConfig map[int32]bool `bson:"-" msgpack:"-"`
|
||||
}
|
||||
|
||||
@@ -3,9 +3,9 @@ package model
|
||||
import "math"
|
||||
|
||||
type Vector struct {
|
||||
X float64 `bson:"x"`
|
||||
Y float64 `bson:"y"`
|
||||
Z float64 `bson:"z"`
|
||||
X float64
|
||||
Y float64
|
||||
Z float64
|
||||
}
|
||||
|
||||
// Distance 两坐标之间的距离
|
||||
|
||||
@@ -6,15 +6,15 @@ import (
|
||||
)
|
||||
|
||||
type Weapon struct {
|
||||
WeaponId uint64 `bson:"weaponId"` // 武器的唯一id
|
||||
ItemId uint32 `bson:"itemId"` // 武器的道具id
|
||||
Level uint8 `bson:"level"` // 等级
|
||||
Exp uint32 `bson:"exp"` // 当前经验值
|
||||
Promote uint8 `bson:"promote"` // 突破等阶
|
||||
Lock bool `bson:"lock"` // 锁定状态
|
||||
AffixIdList []uint32 `bson:"affixIdList"` // 词缀
|
||||
Refinement uint8 `bson:"refinement"` // 精炼等阶
|
||||
AvatarId uint32 `bson:"avatarId"` // 装备角色id
|
||||
WeaponId uint64 // 武器的唯一id
|
||||
ItemId uint32 // 武器的道具id
|
||||
Level uint8 // 等级
|
||||
Exp uint32 // 当前经验值
|
||||
Promote uint8 // 突破等阶
|
||||
Lock bool // 锁定状态
|
||||
AffixIdList []uint32 // 词缀
|
||||
Refinement uint8 // 精炼等阶
|
||||
AvatarId uint32 // 装备角色id
|
||||
Guid uint64 `bson:"-" msgpack:"-"`
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user