123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753 |
- package model
- import (
- "fmt"
- "sort"
- "strconv"
- "time"
- "leafstalk/otherutils/deepcopy"
- "xorm.io/xorm"
- )
- const (
- MapValueMainChapterRankReward = "ChapterFirstPassed" //主线排名奖励
- MapValueCooperationRankReward = "CoopFirstPassed" //合作排名奖励
- MapValueChangedNickNum = "NickChanged" // 改名次数
- MapValueCreditScore = "CreditScore" // 信用积分
- MapValueRenown = "renown" //军衔 声望
- MapValueLoginDays = "loginDays" // 登录天数
- )
- const (
- StatsTypeRecritHeroCount = "recruitHero" // 招募英雄次数
- StatsTypeRecritTreasureCount = "recruitTreasure" // 招募宝物次数
- StatsTypeRecritLegendCount = "recruitLegend" // 招募铭文次数
- )
- type EnterRoomData struct {
- SyncRoomId int64 `json:"syncRoomId,string"`
- Seed int64 `json:"seed"`
- LevelId int64 `json:"chapterId"`
- Players []*EnterChapterDataItem `json:"players"`
- ArenasWear int64 `json:"arenasWear"` //当前游戏装配场景id -> 0 表示未装配 -> 装配玩家id
- GameSyncAddr string `json:"gameSyncAddr"`
- }
- type EnterChapterDataItem struct {
- PlayerId int64 `json:"userId"`
- HeadId int64 `json:"headId"`
- FrameId int64 `json:"frameId"`
- Nick string `json:"nick"`
- Heros map[int64]*Hero `json:"heros"`
- Fort *EntryDataFort `json:"fort"`
- Runes map[string]*BagRune `json:"runes"`
- Treasures map[int64]*GrowableTreasure `json:"treasures"`
- Emojis map[int64]struct{} `json:"emojis"`
- Resonances []*GrowableResonance `json:"resonances"`
- Renown int64 `json:"renown"`
- Arenas ClientArena `json:"arenas"`
- ArenaSkins map[int64]int64 `json:"arenaSkins"`
- Legend *LegendCalc `json:"legend"`
- }
- type ClientArena struct {
- Arenas map[int64]int64 `json:"arenas"` //场景id:星级
- Wear int64 `json:"wear"` //装配场景id
- Skills [3]int64 `json:"skill"` //装配技能对应的场景id
- }
- type EntryDataFort struct {
- Level int64 `json:"level"` //等级
- Parts [6]*FortPart `json:"parts"` //部位
- TalentTree [2]int64 `json:"talents"` //天赋树
- Skin *FortSkin `json:"skin"` //皮肤
- SkillIds [3]int64 `json:"skill"` //技能
- }
- type Hero struct {
- ID int64 `json:"id"`
- Level int64 `json:"level"` // 当等级=0时,表示英雄未解锁,可以拥有皮肤
- Wear int64 `json:"wear"`
- Skins []int64 `json:"skins"`
- }
- type FortSkin struct {
- Wear int64 `json:"wear"`
- Skins map[int64]int64 `json:"skins"` //皮肤id:星级
- }
- type LoginToken struct {
- AccId int64
- OpenId string
- Token string
- NickName string
- ImgUrl string
- GdtVid string // 进入所点击广告ID
- AdId string
- AdSrc string
- Flag int //用户标志
- Plat string
- PlatSessionKey string
- }
- type PlayerSummary struct {
- LineId int `json:"serverId"`
- Level int `json:"level"`
- }
- // Player 玩家信息
- type Player struct {
- Id int64
- AccId int64 `xorm:"BIGINT index 'accId'"`
- OpenID string `xorm:"varchar(255) index 'openid'"`
- NickName string `xorm:"varchar(255) 'nickname'" json:"nickName"`
- AvatarURL string `xorm:"varchar(512) 'avatar'" json:"avatarUrl"` // 目前由world维护 login储存
- Account string `xorm:"varchar(255) 'account'"`
- Passwod string `xorm:"varchar(255) 'password'" json:"-"`
- Inviter int64 `xorm:"BIGINT 'inviter'"`
- InviteServer int64 `xorm:"BIGINT 'inviteServer'"`
- PlatOpenID string `xorm:"varchar(255) 'platopenid'"`
- Unionid string `xorm:"varchar(255) 'unionid'"`
- Plat int `xorm:"int 'plat'"`
- SessionKey string `xorm:"varchar(512) 'sessionkey'"`
- SelectServer int `xorm:"int 'server'"` // 选择登录线
- Summary []*PlayerSummary `xorm:"varchar(1024) json 'summary'"` // 玩家在各服的档案信息
- Ban int `xorm:"int 'ban'"`
- Flag int `xorm:"default 0 int 'flag'"` //用户标记,老用户为0,新用户根据openid计算,奇数为1,偶数为0
- IDCard string `xorm:"varchar(255) 'idcard'"`
- RealName string `xorm:"varchar(255) 'name'"`
- BornTime int64 `xorm:"BIGINT 'borntime'"`
- GameTime int64 `xorm:"BIGINT 'gametime'"`
- GameTimeLen int `xorm:"int 'gametimelen'"`
- ClickId string `xorm:"varchar(255) 'clickId'"` // 进入所点击广告ID
- AdId string `xorm:"varchar(128) 'aId'"` //广告ID
- AdSrc string `xorm:"varchar(128) 'adSrc'"` //广告来源
- UpdateTime int64 `xorm:"'updated' updated"`
- CreateTime int64 `xorm:"'createtime' created" json:"createtime"`
- ClientVersion string `xorm:"varchar(255) 'clientVersion'"` // 客户端储存的验证版本相关信息 服务器只做储存 客户端不会发 ;
- TableNo int `xorm:"-"`
- }
- // TableName 表名
- func (player *Player) TableName() string {
- if player.TableNo > 0 {
- return fmt.Sprintf("user_account_%v", player.TableNo)
- }
- return "user_account"
- }
- func (p *Player) GlobalId() int64 {
- return p.AccId
- }
- func (p *Player) Key() string {
- if len(p.OpenID) > 0 {
- return p.OpenID
- }
- if len(p.Account) > 0 {
- return fmt.Sprintf("%v@%v", p.Account, LoginPlatAccount)
- }
- return fmt.Sprintf("%v@%v", "test", LoginPlatAccount)
- }
- // 成长性英雄
- type GrowableHero struct {
- // ID int64 `json:"id"`
- Level int64 `json:"level"`
- Skin int64 `json:"wear"`
- }
- type HeroShow struct {
- ID int64 `json:"id"`
- Level int64 `json:"level"`
- Skin int64 `json:"wear"`
- }
- // // 要塞时装(皮肤)
- // type FortSkin struct {
- // Wear int64 `json:"wear"`
- // Skins map[int64]struct{} `json:"skins"` //皮肤星级id:
- // }
- // func (fs *GrowableFort) FindStarSkinByModeId(modelId int64) int64 {
- // for starId := range fs.Skins {
- // if starId/100 == modelId {
- // return starId
- // }
- // }
- // return 0
- // }
- // func (fs *GrowableFort) HasStarSkin(skinId int64) bool {
- // _, ok := fs.Skins[skinId]
- // return ok
- // }
- // func (fs *GrowableFort) GetSkinModeIds() []int64 {
- // var lst []int64
- // for starId, _ := range fs.Skins {
- // lst = append(lst, starId/100)
- // }
- // return lst
- // }
- func FortSkinStarIdToSkinId(skinStarId int64) int64 {
- return skinStarId / 100
- }
- func FortSkinIdToStarId(skinId int64, level int64) int64 {
- return (skinId*100 + level)
- }
- // 要塞部位
- type FortPart struct {
- Level int64 `json:"level"` //部位等级
- WearRune int64 `json:"wear,string"` //部位镶嵌的符文
- }
- // 部位展示
- type PartShow struct {
- Pos int64 `json:"pos"` // 部位
- Level int64 `json:"level"` // 部位等级
- Rune int64 `json:"rune"` // 符文模型ID
- }
- // 要塞
- type GrowableFort struct {
- Level int64 `json:"level"` //等级
- Parts [6]*FortPart `json:"parts"` //部位
- TalentTree [2]int64 `json:"talents"` //天赋树
- WearSkin int64 `json:"wear"`
- SkillIds [3]int64 `json:"skill"` //技能对应的皮肤ID 不时星级ID
- // Skins map[int64]int64 `json:"skins"` //皮肤id:星级
- // Skin *FortSkin `json:"skin"` //皮肤
- }
- // 场景
- type GrowableArena struct {
- // Arenas map[int64]int64 `json:"arenas"` //场景id:星级
- Wear int64 `json:"wear"` //装配场景id
- Skills [3]int64 `json:"skill"` //装配技能对应的场景id
- }
- func NewGrowableArena() *GrowableArena {
- it := new(GrowableArena)
- // it.FortArenas = make(map[int64]int64)
- return it
- }
- // type DropMaterial struct {
- // MaterialData map[int64]*MaterialData `json:"materialData"`
- // }
- type HeadFrame struct {
- HeadId int64 `json:"headId"` // 头像 -1 代表使用 AvatarURL 微信授权头像
- FrameId int64 `json:"frameId"` // 头像框
- HIdEndTs int64 `json:"hEndTs"` // 头像结束时间 -1 无限制
- FIdEndTs int64 `json:"fEndTs"` // 头像框结束时间
- }
- type RuneAffix struct {
- Type int64 `json:"typ"`
- Value float64 `json:"val"`
- }
- type RuneAffixAndPos struct {
- *RuneAffix //`json:"runeAffix"` //
- Pos int `json:"pos"` //
- }
- type RuneRecastAttr struct {
- Gid int64
- Ts int64
- Items []*RuneAffixAndPos
- }
- // 符文
- type BagRune struct {
- ModeId int64 `json:"id"`
- Attrs []*RuneAffix `json:"attrs,omitempty"` // 附加属性 [几条属性][属性类型,值]
- // WearPos int64 `json:"pos,omitempty"` // 穿戴位置
- }
- // type ClientBagRune struct {
- // ModeId int64 `json:"id"`
- // Attrs []*RuneAffix `json:"attrs,omitempty"` // 附加属性 [几条属性][属性类型,值]
- // // WearPos int64 `json:"pos,omitempty"` // 穿戴位置
- // }
- type DropedRune struct {
- *BagRune
- GId int64 `json:"gId"`
- }
- func NewChapterSummary() *ChapterSummary {
- it := new(ChapterSummary)
- it.Process = make([]*ChapterProcess, 0, 1)
- it.Levels = make(map[int64]*LevelSummary)
- return it
- }
- type ChapterSummary struct {
- Process []*ChapterProcess `json:"process"`
- Levels map[int64]*LevelSummary `json:"levels"`
- }
- func NewChapterProcess2(typ int64) *ChapterProcess {
- it := new(ChapterProcess)
- it.Type = typ
- return it
- }
- type ChapterProcess struct {
- Type int64 `json:"type"`
- Chapter int64 `json:"chapter"`
- Level int64 `json:"level"`
- Wave int64 `json:"wave"`
- Passed int64 `json:"passed"`
- }
- func NewLevelSummary() *LevelSummary {
- it := new(LevelSummary)
- return it
- }
- type LevelSummary struct {
- // Level int64 `json:"id"`
- Wave int64 `json:"wave"`
- Geted int64 `json:"geted"`
- SubWave int64 `json:"subWave"`
- SubGeted int64 `json:"subGeted"`
- JoinTs int64 `json:"joinTs"`
- }
- type ChapterProcess2 struct {
- ChapterLevels map[int64][2]int64 `json:"cl"` //已解锁的章节关卡 章节[小章节ID,是否已通关?1:0]
- LevelWaves map[int64]*LevelSummary `json:"levels"` //需要处理的关卡进度及奖励 关卡编号[大章节ID,关卡ID,首次通过波数,首通奖励领取到的波次,循环通过的波次,循环奖励领取到的波次,循环波次完成时间]
- // Chapter int64 `json:"id"` //大章节ID
- // Level int64 `json:"lv"` //关卡 1,2,3,。。
- // First [2]int `json:"fw"` //首次通过波数 [首次通过波数,首次奖励领取到的波次]
- // Cycle [2]int `json:"cw"` //循环通过的波次 [循环通过的波次,循环奖励领取到的波次]
- // FirstReward int64 `json:"fr"` //首通奖励领取到的波次
- // CycleWave int64 `json:"cw"` //循环通过的波次
- // CycleReward int64 `json:"cr"` //循环奖励领取到的波次
- // Chpater int64 `json:"id"` //关卡ID
- // Door int64 `json:"door"` //关卡门
- // FirstWave int64 `json:"fw"` //首次通过波数
- // FirstReward int64 `json:"fr"` //首通奖励领取到的波次
- // CycleWave int64 `json:"cw"` //循环通过的波次
- // CycleReward int64 `json:"cr"` //循环奖励领取到的波次
- // FirstPass int64 `json:"pass"` //是否通关
- }
- // type WaveAndReward struct {
- // Wave int64 `json:"w"` //首次通过波数
- // Reward int64 `json:"r"` //首通奖励领取到的波次
- // }
- type ChapterLevel2 struct {
- First [2]int64 `json:"fw"` //首次通过波数 [首次通过波数,首次奖励领取到的波次]
- Normal [2]int64 `json:"nw"` //循环通过的波次 [循环通过的波次,循环奖励领取到的波次]
- JoinTs int64 `json:"js"` //循环波次完成时间
- // Chapter int64 `json:"id"` //大章节ID
- // Level int64 `json:"lv"` //关卡 1,2,3,。。
- // Chapter int64 `json:"id"` //关卡ID
- // Level int64 `json:"lv"` //关卡
- // FirstWave int64 `json:"fw"` //首次通过波数
- // FirstReward int64 `json:"fr"` //首通奖励领取到的波次
- // CycleWave int64 `json:"cw"` //循环通过的波次
- // CycleReward int64 `json:"cr"` //循环奖励领取到的波次
- // CycleTs int64 `json:"ts"` //循环波次完成时间
- // // FirstPass int64 `json:"pass"` //是否通关
- }
- // 宝物
- type GrowableTreasure struct {
- Level int64 `json:"level"` // 等级
- Star int64 `json:"star"` // 星级
- }
- type TreasureShow struct {
- Id int64 `json:"id"` // 宝物id
- Level int64 `json:"level"` // 等级
- Star int64 `json:"star"` // 星级
- }
- type RecruitStatis struct {
- HeroNum int64 `json:"heroNum"` // 英雄招募次数(暗保底使用,触发暗保底后会清0)
- TreasureNum [2]int64 `json:"treasureNum"` // 宝物招募次数(暗保底使用,触发暗保底后会清0) 10次保底和500次保底
- LegendNum [2]int64 `json:"epigraphNum"` // 铭文招募次数(暗保底使用,触发暗保底后会清0) 10次保底和500次保底
- }
- type RecoverItem struct {
- ItemId int64 `json:"itemId"`
- LastRecoverTs int64 `json:"lastStamTick"` // 开始恢复的时间
- DayBuyTs int64 `json:"dayStamTick"` // 购买时间
- DayBuyCount int `json:"dayStamBuyCount"` // 今日购买次数
- DayAdCount int `json:"adStamCount"` // 今日使用免费次数
- // Stamina int `json:"stamina"` // 当前体力 放背包
- }
- func NewRecoverItem(recoverId int64) *RecoverItem {
- recoveritem := new(RecoverItem)
- recoveritem.ItemId = recoverId
- recoveritem.LastRecoverTs = time.Now().Unix()
- recoveritem.DayBuyTs = 0
- recoveritem.DayBuyCount = 0
- recoveritem.DayAdCount = 0
- return recoveritem
- }
- // type RecoverItem2 struct {
- // // Stamina int `json:"stamina"` // 当前体力 放背包
- // LastStamTick int64 `json:"lastStamTick"` // 生效时间
- // DayStamTick int64 `json:"dayStamTick"` // 购买时间
- // DayStamBuyCount int `json:"dayStamBuyCount"` // 今日购买次数
- // AdStamCount int `json:"adStamCount"` // 今日使用免费次数
- // LastEnergyTick int64 `json:"lastEnergyTick"` // 精力生效时间
- // DayEnergyTick int64 `json:"dayEnergyTick"` // 精力购买时间
- // DayEnergyBuyCount int `json:"dayEnergyBuyCount"` // 今日精力购买次数
- // AdEnergyCount int `json:"adEnergyCount"` // 今日精力使用免费次数
- // }
- type GrowableResonance struct {
- Faction int64 `json:"faction"` //阵营
- Level int64 `json:"level"` //等级
- Slots []*ResonanceSlot `json:"heros"` //英雄
- }
- func NewGrowableResonance(faction int64) *GrowableResonance {
- return &GrowableResonance{
- Faction: faction,
- Slots: make([]*ResonanceSlot, 0),
- }
- }
- type ResonanceSlot struct {
- Pos int `json:"pos"` //位置
- HeroId int64 `json:"heroId"` //英雄ID
- RemoveTs int64 `json:"removeTs"` //移除时间
- }
- //type BagLegendItem struct {
- // ModeId int64 `json:"id"`
- // SlotId int64 `json:"slotId"`
- //}
- type GrowableLegend struct {
- Level int64 `json:"level"` // 精通等级
- SlotWear map[int64]int64 `json:"slotWear"` // {slotId:modelId}
- // Legends map[int64]int64 `json:"legends"` // {modelId:num}
- }
- func NewGrowableLegend() *GrowableLegend {
- return &GrowableLegend{
- // Legends: make(map[int64]int64),
- SlotWear: make(map[int64]int64),
- }
- }
- type LegendCalc struct {
- Level int64 `json:"level"` // 精通等级
- SlotWear map[int64]int64 `json:"legends"` // {slotId:modelId}
- }
- const (
- // GameStatusLogin = int64(1)
- GameStatusChapterMatch = int64(2)
- // GameStatusLogout = int64(3)
- )
- // type GameSetting struct {
- // Bgm bool `json:"bgm"`
- // BgSound bool `json:"bgSound"`
- // DamageFloatText bool `json:"damageFloatText"`
- // }
- type GamePlayer struct {
- Id int64 //`xorm:"BIGINT pk autoincr 'id'"`
- PlayerId int64 `xorm:"BIGINT index 'playerid'"`
- AccId int64 `xorm:"BIGINT index(serveracc) 'accId'"`
- LineId int64 `xorm:"int index(serveracc) 'line'"`
- Level int64 `xorm:"int 'level'"`
- Exp int64 `xorm:"BIGINT 'exp'"`
- LastLoginTick int64 `xorm:"BIGINT 'lastlogintick'"`
- LastLogoutTick int64 `xorm:"BIGINT 'lastlogouttick'"`
- OpenId string `xorm:"VARCHAR(255) 'openId'"`
- NickName string `xorm:"VARCHAR(255) index 'nickName'"`
- ImgUrl string `xorm:"VARCHAR(512) 'imgUrl'"`
- HeadId int64 `xorm:"int 'headId'"` // 头像 -1 代表使用 AvatarURL 微信授权头像
- HeadFrameId int64 `xorm:"int 'frameId'"` // 头像框
- CreateTime time.Time `xorm:"created"`
- Ban int `xorm:"int 'ban'"`
- AdId string `xorm:"VARCHAR(128) 'adId'"`
- ClickId string `xorm:"VARCHAR(255) 'clickId'"`
- AdSrc string `xorm:"VARCHAR(128) 'adSrc'"`
- Plat string `xorm:"VARCHAR(20) 'plat'"` // wx tt
- SubPlat int `xorm:"int default 0 subPlat"` // 1 抖音; 2 抖音极速
- Flag int `xorm:"int 'flag'"` //标记
- SessionKey string `xorm:"-"` // 小游戏登录凭证
- GateId int64 `xorm:"-"` // 所在网关
- Online bool `xorm:"-"` // 在线状态 上线 下线
- GameState int64 `xorm:"-"` // 游戏状态 匹配状态
- GameSyncRoomId int64 `xorm:"BIGINT 'gameSyncRoomId'"` // 游戏同步房间id
- GameSyncData *EnterRoomData `xorm:"-"`
- Materials map[int64]int64 `xorm:"Text 'materials'"` // 道具
- Heros map[int64]*GrowableHero `xorm:"Text json 'heros'"` // 英雄
- HeroSkins map[int64]struct{} `xorm:"Text json 'heroSkins'"` // 英雄皮肤,玩家可以不拥有英雄却拥有皮肤。所以单独记录。
- Fort *GrowableFort `xorm:"Text json 'fort'"` //时装
- FortSkins map[int64]int64 `xorm:"Text 'fortSkins'"` //皮肤id:星级
- Runes map[int64]*BagRune `xorm:"MEDIUMTEXT 'runes'"` //符文
- Chapters *ChapterSummary `xorm:"Text json 'chapters'"` //章节进度
- Treasures map[int64]*GrowableTreasure `xorm:"Text json 'treasures'"` // 宝物
- Recruit *RecruitStatis `xorm:"Text json 'recruit'"` // 招募
- RuneRecast *RuneRecastAttr `xorm:"Text json 'recast'"` //符文重铸
- Crystals map[int64]int64 `xorm:"Text 'crystal'"` //水晶 [水晶id]领取过奖励
- Recovers []*RecoverItem `xorm:"Text json 'recovers'"` // 体力 精力信息
- CoopTickets map[int64]int64 `xorm:"Text json 'coopTickets'"` // 作战卷轴 【卷轴ID】开始恢复时间
- Arenas *GrowableArena `xorm:"Text json 'arena'"` //场景
- ArenaSkins map[int64]int64 `xorm:"Text 'arenaSkins'"` //场景id:星级
- Resonances []*GrowableResonance `xorm:"Text json 'resonance'"` //共鸣
- LegendFoster *GrowableLegend `xorm:"Text json 'legendFoster'"` // 铭文
- Legends map[int64]int64 `xorm:"Text legends"` // {modelId:num}
- Heads map[int64]struct{} `xorm:"Text heads"` //头像
- HeadFrames map[int64]struct{} `xorm:"Text headFrames"` //头像框
- Emojis map[int64]struct{} `xorm:"Text emojis"` //聊天表情
- MapValues map[string]int64 `xorm:"Text states"` // 各种游戏状态, 见MapValueXXX
- Statistics map[string]int64 `xorm:"Text stats"` // 玩家统计信息
- Cards *CardActivity `xorm:"Text json 'cards'"` // 精彩活动
- ShareReward *EnterShareReward `xorm:"Text json 'shareReward'"` // 分享奖励
- AdInvite *InviteSummary `xorm:"Text json 'inviteSummary'"` // 推广邀请奖励
- OffLineStat *OffLineSummary `xorm:"Text json 'offLineStat'"` // 离线时长统计
- // GameSetting *GameSetting `xorm:"Text json 'gameSetting'"` //游戏设置
- // WearRunes map[int64]struct{} `xorm:"-"` //穿戴的符文[符文类型]符文id
- // StaminaInfo *StaminaData `xorm:"Text json 'stamina'"` // 体力信息
- }
- type EnterShareReward struct {
- AddToDesk int `json:"addToDesk"` // 添加奖励
- LastLaunchTs int64 `json:"lastLaunchTs"` // 最后领取侧边栏进入奖励的时间
- LastShareTs int64 `json:"lastShareTs"` // 最后分享视频的时间
- ShareCount int64 `json:"shareCount"` // 当天分享次数
- }
- type InviteSummary struct {
- Num int64 `json:"num"` // 邀请次数
- Reward int64 `json:"reward"` // 邀请奖励
- }
- type OffLineSummary struct {
- CalcTs int64 `json:"calcTs"` // 计算今日离线时间
- OffLineTl int64 `json:"offLineTs"` //今日离线时长
- YesterdayOffLineTl int64 `json:"offLineTime"` //昨日离线时长
- }
- func NewCardActivity() *CardActivity {
- return &CardActivity{
- MonthCards: &MonthCards{
- DailyRewardTs: 0,
- Cards: make(map[int64]*MonthCardItem),
- },
- PrivilegeCards: make(map[int64]int64),
- }
- }
- // 精彩活动
- type CardActivity struct {
- MonthCards *MonthCards `json:"monthCards"` // 月卡
- PrivilegeCards map[int64]int64 `json:"privilegeCards"` // 特权卡[类型:购买时间]
- }
- type MonthCards struct {
- DailyRewardTs int64 `json:"dailyRewardTs"` // 每日福利领取时间
- Cards map[int64]*MonthCardItem `json:"cards"` // 月卡状态
- }
- type MonthCardItem struct {
- // 购买时间
- BuyTs int64 `json:"buyTs"`
- // 今日奖励领取时间
- TodayRewardTs int64 `json:"todayRewardTs"`
- }
- func (m GamePlayer) TableName() string {
- return "player_attr"
- }
- func (m *GamePlayer) QueryExist(eng *xorm.Engine) (bool, error) {
- player := new(GamePlayer)
- player.PlayerId = m.PlayerId
- return eng.Exist(player)
- }
- func (m *GamePlayer) UpdateDB(eng *xorm.Engine) (int64, error) {
- return eng.Where("playerid=?", m.PlayerId).MustCols("stamina", "lastStamTick").Update(m)
- }
- func (m *GamePlayer) GetUniqueKey() string {
- return strconv.FormatInt(m.PlayerId, 10)
- }
- func (t *GamePlayer) GetUniqueIntKey() int64 {
- return t.PlayerId
- }
- func (t *GamePlayer) GetRuneShow() []PartShow {
- its := make([]PartShow, 6)
- if t.Fort == nil {
- for i := range 6 {
- its[i].Pos = int64(i)
- }
- return its
- }
- for k, v := range t.Fort.Parts {
- its[k].Pos = int64(k)
- its[k].Level = v.Level
- if wr, ok := t.Runes[v.WearRune]; ok {
- its[k].Rune = wr.ModeId
- }
- }
- return its
- }
- func (t *GamePlayer) GetHeroShow() []*HeroShow {
- lst := make([]*HeroShow, 0)
- for k, v := range t.Heros {
- if !IsMythicHero(k) {
- continue
- }
- it := new(HeroShow)
- it.ID = k
- it.Level = v.Level
- it.Skin = v.Skin
- lst = append(lst, it)
- }
- sort.Sort(HeroShowList(lst))
- return lst
- }
- func (t *GamePlayer) GetTreasureShow() []*TreasureShow {
- lst := make([]*TreasureShow, 0)
- for k, v := range t.Treasures {
- if !IsMythicTreasure(k) {
- continue
- }
- it := new(TreasureShow)
- it.Id = k
- it.Level = v.Level
- it.Star = v.Star
- lst = append(lst, it)
- }
- sort.Sort(TreasureShowList(lst))
- return lst
- }
- // func (t *GamePlayer) GetRuneCalc() int64 {
- // return t.PlayerId
- // }
- // 实现DeepCopy接口
- func CopyGamePlayer(old *GamePlayer) *GamePlayer {
- new2, err := deepcopy.Copy(old) //
- if err != nil {
- return nil
- }
- return new2.(*GamePlayer)
- }
- func (t *GamePlayer) SetGameState(status int64) int64 {
- old := t.GameState
- t.GameState = status
- return old
- }
- // 上下线状态
- func (t *GamePlayer) SetOnlineState(online bool) {
- t.Online = online
- if !online {
- fmt.Println("玩家下线")
- }
- }
- func (t *GamePlayer) IsOnline() bool {
- return t.Online
- }
- // 需要保存的数据需确保在这里能复制到new1 中
- // func (m *GamePlayer) DeepCopy() interface{} {
- // new1 := new(GamePlayer)
- // *new1 = *m
- // return new1
- // }
- func GetRecoverItem(user *GamePlayer, recoverId int64) *RecoverItem {
- var recoveritem *RecoverItem
- for _, it := range user.Recovers {
- if it.ItemId == recoverId {
- recoveritem = it
- }
- }
- return recoveritem
- }
- // 获取关卡进度
- func FindChapterProcess(process []*ChapterProcess, typ int64) *ChapterProcess {
- for _, v := range process {
- if v.Type == typ {
- return v
- }
- }
- return nil
- }
- type HeroShowList []*HeroShow
- func (m HeroShowList) Len() int { return len(m) }
- func (m HeroShowList) Swap(i, j int) { m[i], m[j] = m[j], m[i] }
- func (m HeroShowList) Less(i, j int) bool {
- if m[i].Level < m[j].Level {
- return true
- } else if m[i].Level > m[j].Level {
- return false
- } else {
- return m[i].ID < m[j].ID
- }
- }
- type TreasureShowList []*TreasureShow
- func (m TreasureShowList) Len() int { return len(m) }
- func (m TreasureShowList) Swap(i, j int) { m[i], m[j] = m[j], m[i] }
- func (m TreasureShowList) Less(i, j int) bool {
- if m[i].Star < m[j].Star {
- return true
- } else if m[i].Star > m[j].Star {
- return false
- } else {
- return m[i].Id < m[j].Id
- }
- }
|