123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195 |
- package model
- import (
- "leafstalk/otherutils/deepcopy"
- "strconv"
- "time"
- "xorm.io/xorm"
- )
- // 1 累计登录天数达[0]天
- // 2 主角等级达到[0]级
- // 3 激活[0]个天赋
- // 4 累计获得[0]金币
- // 5 累计消耗[0]钻石
- // 6 [0]关卡通过第[0]层[0]次
- // 7 主线关卡中击杀[0]个首领
- // 8 招募达人:累计招募[0]次
- // 9 局内英雄合成[0]次
- // 10 英雄升级[0]次
- // 11 宝物升级[0]次
- // 12 局内强化[0]次
- // 13 通关第[0]大章
- // 14 获得[0]个神话英雄
- // 15 累计购买[0]次体力
- // 16 参与合作模式[0]次
- // 17 关卡内击杀怪物[0]次
- // 18 关卡内刷新[0]次
- // 19 观看广告[0]次
- // 20 宝物抽卡[0]次
- // 21 符文强化[0]次
- // 22 符文分解[0]次
- // 23 通关主线[]
- const (
- TaskTypeLogin = 1 // (已上报)
- TaskTypeLevel = 2 //传递主角等级(已上报)
- TaskTypeTalent = 3 //传递总天赋个数(已上报)
- TaskTypeGetCoin = 4 //传递变化值 正数(已上报)
- TaskTypeCostDiamond = 5 //传递变化值 正数(已上报)
- TaskTypeChapterWave = 6 //(已上报)
- TaskTypeKillBoss = 7
- TaskTypeHeroRecruit = 8 //(已上报)
- TaskTypeHeroCompose = 9
- TaskTypeHeroUpgrade = 10 //(已上报)
- TaskTypeArtifactUpgrade = 11 //(已上报)
- TaskTypeStrengthen = 12
- TaskTypeChapterPass = 13 //传递总值 第几章节
- TaskTypeGetMythicHero = 14 //传递总值 几个神话英雄 (已上报招募和购买)
- TaskTypeBuyStamina = 15 //传递变化值 购买次数的变化值(已上报)
- TaskTypeCoop = 16
- TaskTypeKillMonster = 17
- TaskTypeGameInRefresh = 18
- TaskTypeAd = 19
- TaskTypeTreasureRecruit = 20 //(已上报)
- TaskTypeRuneStrengthen = 21
- TaskTypeRuneDecompose = 22 //(已上报)
- TaskTypeChapterLevelPass = 23
- TaskTypeAnyHeroLevel = 24 //(已上报)
- TaskTypeFortLevel = 25 //(已上报)
- TaskTypeCooperationNormalPass = 26
- TaskTypeCooperationHardPass = 27
- TaskTypeCooperationNightmarePass = 28
- TaskTypeElitePass = 29
- TaskTypeAnyMainChapterPass = 30
- TaskTypeArenaPass = 31
- TaskTypeArenaVictory = 32
- TaskTypeInviteEnterGame = 33
- )
- // type TaskType int64
- const (
- DailyTask int64 = iota + 1
- WeeklyTask
- PeriodicTask
- )
- type TaskStatus int
- const (
- NotStarted TaskStatus = iota
- InProgress
- Completed
- Claimed
- )
- func NewPlayerTasks() *PlayerTasks {
- return &PlayerTasks{
- DailyTasks: make(map[int64]*TaskProgress),
- WeeklyTasks: make(map[int64]*TaskProgress),
- Achievements: make(map[int64]*TaskProgress),
- DailyActivity: ActivityReward{Progress: 0, DrawStatus: make(map[int64]int64)},
- LastDailyRefresh: time.Now().Unix(),
- LastWeeklyRefresh: time.Now().Unix(),
- }
- }
- type PlayerTasks struct {
- Id int64
- PlayerId int64 `xorm:"BIGINT index 'playerid'"`
- DailyTasks map[int64]*TaskProgress `xorm:"Text json 'dailyTasks'"`
- WeeklyTasks map[int64]*TaskProgress `xorm:"Text json 'weeklyTasks'"`
- DailyActivity ActivityReward `xorm:"Text json 'dailyActivity'"`
- Achievements map[int64]*TaskProgress `xorm:"Text json 'achievements'"` // 玩家的成就进度
- LastDailyRefresh int64 `xorm:"BIGINT 'lastDailyRefresh'"`
- LastWeeklyRefresh int64 `xorm:"BIGINT 'lastWeeklyRefresh'"`
- }
- type TaskProgress struct {
- TaskID int64 `json:"taskId"`
- Progress int64 `json:"progress"`
- Status TaskStatus `json:"status"`
- Reward [][]int64 `json:"reward,omitempty"`
- }
- type ActivityReward struct {
- Progress int64 `json:"progress"`
- DrawStatus map[int64]int64 `json:"drawStatus"`
- }
- // type TaskReward struct {
- // ItemID int64
- // Amount int64
- // }
- // type Task struct {
- // ID int64
- // Type TaskType
- // Description string
- // Goal int64
- // Rewards []TaskReward
- // }
- func (m PlayerTasks) TableName() string {
- return "player_tasks"
- }
- // 需要保存的数据需确保在这里能复制到new1 中
- //func (m *PlayerTasks) DeepCopy() interface{} {
- // new1 := new(PlayerTasks)
- // *new1 = *m
- //
- // return new1
- //}
- func (m *PlayerTasks) QueryExist(eng *xorm.Engine) (bool, error) {
- player := new(PlayerTasks)
- player.PlayerId = m.PlayerId
- return eng.Exist(player)
- }
- func (m *PlayerTasks) UpdateDB(eng *xorm.Engine) (int64, error) {
- return eng.Where("playerid=?", m.PlayerId).AllCols().Update(m)
- }
- func (m *PlayerTasks) GetUniqueKey() string {
- //return m.UserId
- return strconv.FormatInt(m.PlayerId, 10)
- }
- func CopyPlayerTasks(old *PlayerTasks) *PlayerTasks {
- new2, err := deepcopy.Copy(old) //
- if err != nil {
- return nil
- }
- return new2.(*PlayerTasks)
- }
- // 任务表-Task exported from 日常任务配置.xlsx
- type Task struct {
- Uid int64 `json:"Uid"` // 唯一ID
- Type int64 `json:"Type"` // 大类 1-日常任务 2--挑战任务
- Time int64 `json:"Time"` // 重置周期(天
- Des string `json:"Des"` // 任务描述
- TaskType int64 `json:"TaskType"` // 任务类型
- Value []int64 `json:"Value"` // 任务参数
- Reward [][]int64 `json:"Reward"` // 任务奖励 道具ID,数量
- } // package model
- // 日常任务宝箱表-TaskBox exported from 日常任务配置.xlsx
- type TaskBox struct {
- Uid int64 `json:"Uid"` // 唯一ID
- Points int64 `json:"Points"` // 档位
- Reward [][]int64 `json:"Reward"` // 奖励 道具ID,数量
- } // package model
- // 任务表-TaskAc exported from 成就任务配置.xlsx
- type TaskAc struct {
- Uid int64 `json:"Uid"` // 唯一ID
- NextId int64 `json:"NextId"` // 下档任务ID
- Des string `json:"Des"` // 任务描述
- TaskType int64 `json:"TaskType"` // 任务类型
- Value []int64 `json:"Value"` // 任务参数
- Reward [][]int64 `json:"Reward"` // 任务奖励
- }
|