UserData.ts 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. heroToken: manual[] = []
  47. maxFightRoleNum: number = DataConfig[DIS_ID.heroSlot].data1
  48. maxFightCardNum: number = DataConfig[DIS_ID.cardSlot].data1
  49. roleSlotLv: number[] = DataConfig[DIS_ID.heroSlot].data5
  50. cardSlotLv: number[] = DataConfig[DIS_ID.cardSlot].data5
  51. maxGradeArr: number[] = DataConfig[DIS_ID.heroQuality].data5
  52. altarInfoList: altarInfo[] = [] //祭坛上阵英雄
  53. altarTopFive: string[] = [] //祭坛前五英雄
  54. gradeArr: number[] = []
  55. qualityTypeArr: number[] = []
  56. talents: number[] = []
  57. readyOpenBox: idNum[] = []
  58. init() {
  59. this.goods = new Map<number, number>()
  60. this.gradeArr.length = 0
  61. for (let i = 0; i < this.maxGradeArr.length; i++) {
  62. let maxGrade = this.maxGradeArr[i]
  63. if (i == this.maxGradeArr.length - 1) {
  64. maxGrade = 10
  65. }
  66. for (let j = 0; j <= maxGrade; j++) {
  67. this.gradeArr.push(j)
  68. }
  69. }
  70. let roleKeys = Object.keys(RoleConfig)
  71. this.qualityTypeArr = [0]
  72. let minxQualityType = 0
  73. for (let i = 0; i < roleKeys.length; i++) {
  74. let role = RoleConfig[roleKeys[i]]
  75. if (role.qualityType >= minxQualityType) {
  76. this.qualityTypeArr.push(role.qualityType)
  77. minxQualityType = role.qualityType
  78. } else {
  79. break
  80. }
  81. }
  82. }
  83. reset() {
  84. this.goods?.clear()
  85. }
  86. }