forage.go 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. package model
  2. import (
  3. "leafstalk/otherutils/deepcopy"
  4. "strconv"
  5. "xorm.io/xorm"
  6. )
  7. type ForagePointsSetting struct {
  8. Count int64 `json:"count"` // 总点数
  9. PointsAllocation map[int64]int64 `json:"pointsAllocation"` // 点数分配 {配置表id:分配点数} 点数-1表示未激活
  10. }
  11. type ForagePrivilegeCard struct {
  12. Typ int64 `json:"typ"` // 特权卡类型 1战斗特权卡 2钻石特权卡
  13. PurchaseTime int64 `json:"purchaseTime"` // 购买时间
  14. }
  15. type ForageSetting struct {
  16. Points ForagePointsSetting `json:"points"`
  17. PrivilegeCards map[int64]int64 `json:"privilegeCards"`
  18. // 超值月卡购买时间
  19. MonthCardsBuyTs map[int64]int64 `json:"monthCardsBuyTs"` // {月卡id:购买时间}
  20. }
  21. // type RewardInfo struct {
  22. // Id int64 `json:"id"`
  23. // Type int64 `json:"type"`
  24. // Count int64 `json:"count"`
  25. // }
  26. // type RewardData struct {
  27. // Exp int64 `json:"userExp"`
  28. // Items map[int64]*RewardInfo `json:"items"`
  29. // Runes map[int64]*BagRune `json:"runes"`
  30. // }
  31. type RewardRemainder struct {
  32. Exp float64 `json:"exp"`
  33. Gold float64 `json:"gold"`
  34. Diamond float64 `json:"diamond"`
  35. Rune float64 `json:"rune"`
  36. Legend float64 `json:"legend"`
  37. Resonance float64 `json:"resonance"`
  38. RuneMaterial float64 `json:"runeMaterial"`
  39. Other float64 `json:"other"`
  40. }
  41. func NewForagePlayer() *ForagePlayer {
  42. return &ForagePlayer{
  43. ForageSetting: &ForageSetting{
  44. Points: ForagePointsSetting{
  45. Count: 0,
  46. PointsAllocation: make(map[int64]int64),
  47. },
  48. PrivilegeCards: map[int64]int64{},
  49. MonthCardsBuyTs: map[int64]int64{},
  50. },
  51. Reward: make(map[int64]*DropedItem),
  52. RewardRemainder: &RewardRemainder{},
  53. }
  54. }
  55. type ForagePlayer struct {
  56. Id int64
  57. PlayerId int64 `xorm:"BIGINT index 'playerid'"`
  58. Level int64 `xorm:"int 'level'"`
  59. ForageSetting *ForageSetting `xorm:"Text json 'forageSetting'"` // 巡逻配置
  60. AdNum int64 `xorm:"int 'adNum'"` // 广告使用次数
  61. FastNum int64 `xorm:"int 'fastNum'"` // 快速巡逻使用次数
  62. LastFastTime int64 `xorm:"BIGINT 'lastFastTime'"` // 最后一次使用广告或快速巡逻时间(用来重置次数)
  63. Reward map[int64]*DropedItem `xorm:"Text json 'reward'"` // 已获得奖励
  64. RewardRemainder *RewardRemainder `xorm:"Text json 'rewardRemainder'"` // 未满1的奖励余数
  65. StartTime int64 `xorm:"BIGINT 'startTime'"` // 开始时间
  66. LastRewardTime int64 `xorm:"BIGINT 'lastRewardTime'"` // 最后一次计算奖励的时间
  67. TimeLen int64 `xorm:"BIGINT 'timeLen'"` // 已经巡逻时长 防止调系统时间
  68. }
  69. func (m ForagePlayer) TableName() string {
  70. return "player_forage"
  71. }
  72. // 需要保存的数据需确保在这里能复制到new1 中
  73. //func (m *ForagePlayer) DeepCopy() interface{} {
  74. // new1 := new(ForagePlayer)
  75. // *new1 = *m
  76. //
  77. // return new1
  78. //}
  79. func (m *ForagePlayer) QueryExist(eng *xorm.Engine) (bool, error) {
  80. player := new(ForagePlayer)
  81. player.PlayerId = m.PlayerId
  82. return eng.Exist(player)
  83. }
  84. func (m *ForagePlayer) UpdateDB(eng *xorm.Engine) (int64, error) {
  85. return eng.Where("playerid=?", m.PlayerId).AllCols().Update(m)
  86. }
  87. func (m *ForagePlayer) GetUniqueKey() string {
  88. //return m.UserId
  89. return strconv.FormatInt(m.PlayerId, 10)
  90. }
  91. // 实现DeepCopy接口
  92. func CopyForagePlayer(old *ForagePlayer) *ForagePlayer {
  93. new2, err := deepcopy.Copy(old) //
  94. if err != nil {
  95. return nil
  96. }
  97. return new2.(*ForagePlayer)
  98. }
  99. const (
  100. OutputBase = 1000 //产出量分母
  101. //巡逻加成类型
  102. PatrolBonusTypeExp = 1
  103. PatrolBonusTypeGold = 2
  104. PatrolBonusTypeDiamond = 3
  105. PatrolBonusTypeOther = 4
  106. PatrolBonusTypeRune = 5
  107. PatrolBonusTypeLegend = 6
  108. )
  109. // 巡逻Base-PatrolBase exported from 巡逻配置.xlsx
  110. type PatrolBase struct {
  111. PatrolTimeMax int64 `json:"PatrolTimeMax"` // 巡逻基础 上限时间 /小时
  112. DiamondOutput int64 `json:"DiamondOutput"` // 钻石产出基础量 /小时
  113. FastPatrolNum int64 `json:"FastPatrolNum"` // 每日快速巡逻次数
  114. FastPatrolConsume int64 `json:"FastPatrolConsume"` // 快速巡逻消耗体力量
  115. ADNum int64 `json:"ADNum"` // 每日广告巡逻次数
  116. ADID int64 `json:"ADID"` // 广告点ID
  117. RewardCycle float64 `json:"RewardCycle"` // 可领取时间 生成奖励周期 /小时
  118. } // package model
  119. // 巡逻基础产出-PatrolOutput exported from 巡逻配置.xlsx
  120. type PatrolOutput struct {
  121. Grade int64 `json:"Grade"` // 等级
  122. LevelID int64 `json:"LevelID"` // 解锁关卡编号
  123. GoldNum int64 `json:"GoldNum"` // 金币量 (千分位) /分钟
  124. ExpNum int64 `json:"ExpNum"` // 经验量 (千分位) /分钟
  125. EquipGroup int64 `json:"EquipGroup"` // 符文(装备) 随机掉落组号
  126. EquipNum int64 `json:"EquipNum"` // 符文(装备) (千分位) /分钟
  127. LegendGroup int64 `json:"LegendGroup"` // 铭文 随机掉落组号
  128. LegendNum int64 `json:"LegendNum"` // 铭文 (千分位) /分钟
  129. MaterialGroup1 int64 `json:"MaterialGroup1"` // 共鸣材料 随机掉落组号
  130. MaterialNum1 int64 `json:"MaterialNum1"` // 共鸣材料 (千分位) /分钟
  131. MaterialGroup2 int64 `json:"MaterialGroup2"` // 符文升级材料 随机掉落组号
  132. MaterialNum2 int64 `json:"MaterialNum2"` // 符文升级材料 (千分位) /分钟
  133. MaterialGroup3 int64 `json:"MaterialGroup3"` // 其它道具 随机掉落组号
  134. MaterialNum3 int64 `json:"MaterialNum3"` // 其它道具 (千分位) /分钟
  135. } // package model
  136. // 加成点数-PatrolBonusDot exported from 巡逻配置.xlsx
  137. type PatrolBonusDot struct {
  138. Num int64 `json:"Num"` // 加成点数数量
  139. LevelID int64 `json:"LevelID"` // 解锁关卡
  140. } // package model
  141. // 巡逻加成量-PatrolBonus exported from 巡逻配置.xlsx
  142. type PatrolBonus struct {
  143. Type int64 `json:"Type"` // 类型
  144. TypeName string `json:"TypeName"` // 类型名字
  145. DanNum int64 `json:"DanNum"` // 基础档位数量
  146. DanBonus float64 `json:"DanBonus"` // 每档增加 /百分比
  147. Icon string `json:"Icon"` // 图标
  148. }