UserData.ts 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /** @format */
  2. import {observable} from 'mobx'
  3. import {DataConfig} from '../config/DataConfig'
  4. import {altarInfo, idNum, manual} from '../proto/typedef'
  5. import {RoleConfig} from '../config/RoleConfig'
  6. import {ICard, ICardDebris, ICastleSkill, IEquip, IRole} from '../interface/GlobalInterface'
  7. import {DIS_ID} from '../enums/Enum'
  8. export class UserData {
  9. account: string = ''
  10. @observable
  11. nickname: string = ''
  12. uid: string = ''
  13. @observable
  14. level: number = 1
  15. @observable
  16. exp: number = 0
  17. @observable
  18. avatar: number = 0
  19. set avatarUrl(value: string) {
  20. this._avatarUrl = value
  21. cc.assetManager.loadRemote<cc.Texture2D>(value, {ext: '.png'}, (err, texture) => {
  22. if (!err) this.avatarTex = texture
  23. })
  24. }
  25. private _avatarUrl: string = ''
  26. avatarTex: cc.Texture2D = null
  27. renameTime: number = 0
  28. goods: Map<number, number>
  29. roles: IRole[] = []
  30. @observable
  31. rolesDirty: boolean = false
  32. cards: ICard[] = []
  33. @observable
  34. cardsDirty: boolean = false
  35. cardDebris: ICardDebris[] = []
  36. teamRole: IRole[] = []
  37. teamCard: ICard[] = []
  38. equips: IEquip[] = []
  39. castleSkills: ICastleSkill[] = []
  40. useCastleSkillID: number
  41. @observable
  42. equipsDirty: boolean = false
  43. createTime: number = 0
  44. adventureId: number = 0
  45. eliteId: number = 0
  46. maxFightRoleNum: number = DataConfig[DIS_ID.heroSlot].data1
  47. maxFightCardNum: number = DataConfig[DIS_ID.cardSlot].data1
  48. roleSlotLv: number[] = DataConfig[DIS_ID.heroSlot].data5
  49. cardSlotLv: number[] = DataConfig[DIS_ID.cardSlot].data5
  50. maxGradeArr: number[] = DataConfig[DIS_ID.heroQuality].data5
  51. altarInfoList: altarInfo[] = [] //祭坛上阵英雄
  52. altarTopFive: string[] = [] //祭坛前五英雄
  53. gradeArr: number[] = []
  54. qualityTypeArr: number[] = []
  55. talents: number[] = []
  56. readyOpenBox: idNum[] = []
  57. init() {
  58. this.goods = new Map<number, number>()
  59. this.gradeArr.length = 0
  60. for (let i = 0; i < this.maxGradeArr.length; i++) {
  61. let maxGrade = this.maxGradeArr[i]
  62. if (i == this.maxGradeArr.length - 1) {
  63. maxGrade = 10
  64. }
  65. for (let j = 0; j <= maxGrade; j++) {
  66. this.gradeArr.push(j)
  67. }
  68. }
  69. let roleKeys = Object.keys(RoleConfig)
  70. this.qualityTypeArr = [0]
  71. let minxQualityType = 0
  72. for (let i = 0; i < roleKeys.length; i++) {
  73. let role = RoleConfig[roleKeys[i]]
  74. if (role.qualityType >= minxQualityType) {
  75. this.qualityTypeArr.push(role.qualityType)
  76. minxQualityType = role.qualityType
  77. } else {
  78. break
  79. }
  80. }
  81. }
  82. reset() {
  83. this.goods?.clear()
  84. }
  85. }