task.go 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. package model
  2. import (
  3. "leafstalk/otherutils/deepcopy"
  4. "strconv"
  5. "time"
  6. "xorm.io/xorm"
  7. )
  8. // 1 累计登录天数达[0]天
  9. // 2 主角等级达到[0]级
  10. // 3 激活[0]个天赋
  11. // 4 累计获得[0]金币
  12. // 5 累计消耗[0]钻石
  13. // 6 [0]关卡通过第[0]层[0]次
  14. // 7 主线关卡中击杀[0]个首领
  15. // 8 招募达人:累计招募[0]次
  16. // 9 局内英雄合成[0]次
  17. // 10 英雄升级[0]次
  18. // 11 宝物升级[0]次
  19. // 12 局内强化[0]次
  20. // 13 通关第[0]大章
  21. // 14 获得[0]个神话英雄
  22. // 15 累计购买[0]次体力
  23. // 16 参与合作模式[0]次
  24. // 17 关卡内击杀怪物[0]次
  25. // 18 关卡内刷新[0]次
  26. // 19 观看广告[0]次
  27. // 20 宝物抽卡[0]次
  28. // 21 符文强化[0]次
  29. // 22 符文分解[0]次
  30. // 23 通关主线[]
  31. const (
  32. TaskTypeLogin = 1 // (已上报)
  33. TaskTypeLevel = 2 //传递主角等级(已上报)
  34. TaskTypeTalent = 3 //传递总天赋个数(已上报)
  35. TaskTypeGetCoin = 4 //传递变化值 正数(已上报)
  36. TaskTypeCostDiamond = 5 //传递变化值 正数(已上报)
  37. TaskTypeChapterWave = 6 //(已上报)
  38. TaskTypeKillBoss = 7
  39. TaskTypeHeroRecruit = 8 //(已上报)
  40. TaskTypeHeroCompose = 9
  41. TaskTypeHeroUpgrade = 10 //(已上报)
  42. TaskTypeArtifactUpgrade = 11 //(已上报)
  43. TaskTypeStrengthen = 12
  44. TaskTypeChapterPass = 13 //传递总值 第几章节
  45. TaskTypeGetMythicHero = 14 //传递总值 几个神话英雄 (已上报招募和购买)
  46. TaskTypeBuyStamina = 15 //传递变化值 购买次数的变化值(已上报)
  47. TaskTypeCoop = 16
  48. TaskTypeKillMonster = 17
  49. TaskTypeGameInRefresh = 18
  50. TaskTypeAd = 19
  51. TaskTypeTreasureRecruit = 20 //(已上报)
  52. TaskTypeRuneStrengthen = 21
  53. TaskTypeRuneDecompose = 22 //(已上报)
  54. TaskTypeChapterLevelPass = 23
  55. TaskTypeAnyHeroLevel = 24 //(已上报)
  56. TaskTypeFortLevel = 25 //(已上报)
  57. TaskTypeCooperationNormalPass = 26
  58. TaskTypeCooperationHardPass = 27
  59. TaskTypeCooperationNightmarePass = 28
  60. TaskTypeElitePass = 29
  61. TaskTypeAnyMainChapterPass = 30
  62. TaskTypeArenaPass = 31
  63. TaskTypeArenaVictory = 32
  64. TaskTypeInviteEnterGame = 33
  65. )
  66. // type TaskType int64
  67. const (
  68. DailyTask int64 = iota + 1
  69. WeeklyTask
  70. PeriodicTask
  71. )
  72. type TaskStatus int
  73. const (
  74. NotStarted TaskStatus = iota
  75. InProgress
  76. Completed
  77. Claimed
  78. )
  79. func NewPlayerTasks() *PlayerTasks {
  80. return &PlayerTasks{
  81. DailyTasks: make(map[int64]*TaskProgress),
  82. WeeklyTasks: make(map[int64]*TaskProgress),
  83. Achievements: make(map[int64]*TaskProgress),
  84. DailyActivity: ActivityReward{Progress: 0, DrawStatus: make(map[int64]int64)},
  85. LastDailyRefresh: time.Now().Unix(),
  86. LastWeeklyRefresh: time.Now().Unix(),
  87. }
  88. }
  89. type PlayerTasks struct {
  90. Id int64
  91. PlayerId int64 `xorm:"BIGINT index 'playerid'"`
  92. DailyTasks map[int64]*TaskProgress `xorm:"Text json 'dailyTasks'"`
  93. WeeklyTasks map[int64]*TaskProgress `xorm:"Text json 'weeklyTasks'"`
  94. DailyActivity ActivityReward `xorm:"Text json 'dailyActivity'"`
  95. Achievements map[int64]*TaskProgress `xorm:"Text json 'achievements'"` // 玩家的成就进度
  96. LastDailyRefresh int64 `xorm:"BIGINT 'lastDailyRefresh'"`
  97. LastWeeklyRefresh int64 `xorm:"BIGINT 'lastWeeklyRefresh'"`
  98. }
  99. type TaskProgress struct {
  100. TaskID int64 `json:"taskId"`
  101. Progress int64 `json:"progress"`
  102. Status TaskStatus `json:"status"`
  103. Reward [][]int64 `json:"reward,omitempty"`
  104. }
  105. type ActivityReward struct {
  106. Progress int64 `json:"progress"`
  107. DrawStatus map[int64]int64 `json:"drawStatus"`
  108. }
  109. // type TaskReward struct {
  110. // ItemID int64
  111. // Amount int64
  112. // }
  113. // type Task struct {
  114. // ID int64
  115. // Type TaskType
  116. // Description string
  117. // Goal int64
  118. // Rewards []TaskReward
  119. // }
  120. func (m PlayerTasks) TableName() string {
  121. return "player_tasks"
  122. }
  123. // 需要保存的数据需确保在这里能复制到new1 中
  124. //func (m *PlayerTasks) DeepCopy() interface{} {
  125. // new1 := new(PlayerTasks)
  126. // *new1 = *m
  127. //
  128. // return new1
  129. //}
  130. func (m *PlayerTasks) QueryExist(eng *xorm.Engine) (bool, error) {
  131. player := new(PlayerTasks)
  132. player.PlayerId = m.PlayerId
  133. return eng.Exist(player)
  134. }
  135. func (m *PlayerTasks) UpdateDB(eng *xorm.Engine) (int64, error) {
  136. return eng.Where("playerid=?", m.PlayerId).AllCols().Update(m)
  137. }
  138. func (m *PlayerTasks) GetUniqueKey() string {
  139. //return m.UserId
  140. return strconv.FormatInt(m.PlayerId, 10)
  141. }
  142. func CopyPlayerTasks(old *PlayerTasks) *PlayerTasks {
  143. new2, err := deepcopy.Copy(old) //
  144. if err != nil {
  145. return nil
  146. }
  147. return new2.(*PlayerTasks)
  148. }
  149. // 任务表-Task exported from 日常任务配置.xlsx
  150. type Task struct {
  151. Uid int64 `json:"Uid"` // 唯一ID
  152. Type int64 `json:"Type"` // 大类 1-日常任务 2--挑战任务
  153. Time int64 `json:"Time"` // 重置周期(天
  154. Des string `json:"Des"` // 任务描述
  155. TaskType int64 `json:"TaskType"` // 任务类型
  156. Value []int64 `json:"Value"` // 任务参数
  157. Reward [][]int64 `json:"Reward"` // 任务奖励 道具ID,数量
  158. } // package model
  159. // 日常任务宝箱表-TaskBox exported from 日常任务配置.xlsx
  160. type TaskBox struct {
  161. Uid int64 `json:"Uid"` // 唯一ID
  162. Points int64 `json:"Points"` // 档位
  163. Reward [][]int64 `json:"Reward"` // 奖励 道具ID,数量
  164. } // package model
  165. // 任务表-TaskAc exported from 成就任务配置.xlsx
  166. type TaskAc struct {
  167. Uid int64 `json:"Uid"` // 唯一ID
  168. NextId int64 `json:"NextId"` // 下档任务ID
  169. Des string `json:"Des"` // 任务描述
  170. TaskType int64 `json:"TaskType"` // 任务类型
  171. Value []int64 `json:"Value"` // 任务参数
  172. Reward [][]int64 `json:"Reward"` // 任务奖励
  173. }