1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- /** @format */
- import {observable} from 'mobx'
- import {DataConfig} from '../config/DataConfig'
- import {altarInfo, idNum, manual} from '../proto/typedef'
- import {RoleConfig} from '../config/RoleConfig'
- import {ICard, ICardDebris, ICastleSkill, IEquip, IRole} from '../interface/GlobalInterface'
- import {DIS_ID} from '../enums/Enum'
- export class UserData {
- account: string = ''
- @observable
- nickname: string = ''
- uid: string = ''
- @observable
- level: number = 1
- @observable
- exp: number = 0
- @observable
- avatar: number = 0
- set avatarUrl(value: string) {
- this._avatarUrl = value
- cc.assetManager.loadRemote<cc.Texture2D>(value, {ext: '.png'}, (err, texture) => {
- if (!err) this.avatarTex = texture
- })
- }
- private _avatarUrl: string = ''
- avatarTex: cc.Texture2D = null
- renameTime: number = 0
- goods: Map<number, number>
- roles: IRole[] = []
- @observable
- rolesDirty: boolean = false
- cards: ICard[] = []
- @observable
- cardsDirty: boolean = false
- cardDebris: ICardDebris[] = []
- teamRole: IRole[] = []
- teamCard: ICard[] = []
- equips: IEquip[] = []
- castleSkills: ICastleSkill[] = []
- useCastleSkillID: number
- @observable
- equipsDirty: boolean = false
- createTime: number = 0
- adventureId: number = 0
- eliteId: number = 0
- heroToken: manual[] = []
- maxFightRoleNum: number = DataConfig[DIS_ID.heroSlot].data1
- maxFightCardNum: number = DataConfig[DIS_ID.cardSlot].data1
- roleSlotLv: number[] = DataConfig[DIS_ID.heroSlot].data5
- cardSlotLv: number[] = DataConfig[DIS_ID.cardSlot].data5
- maxGradeArr: number[] = DataConfig[DIS_ID.heroQuality].data5
- altarInfoList: altarInfo[] = [] //祭坛上阵英雄
- altarTopFive: string[] = [] //祭坛前五英雄
- gradeArr: number[] = []
- qualityTypeArr: number[] = []
- talents: number[] = []
- readyOpenBox: idNum[] = []
- init() {
- this.goods = new Map<number, number>()
- this.gradeArr.length = 0
- for (let i = 0; i < this.maxGradeArr.length; i++) {
- let maxGrade = this.maxGradeArr[i]
- if (i == this.maxGradeArr.length - 1) {
- maxGrade = 10
- }
- for (let j = 0; j <= maxGrade; j++) {
- this.gradeArr.push(j)
- }
- }
- let roleKeys = Object.keys(RoleConfig)
- this.qualityTypeArr = [0]
- let minxQualityType = 0
- for (let i = 0; i < roleKeys.length; i++) {
- let role = RoleConfig[roleKeys[i]]
- if (role.qualityType >= minxQualityType) {
- this.qualityTypeArr.push(role.qualityType)
- minxQualityType = role.qualityType
- } else {
- break
- }
- }
- }
- reset() {
- this.goods?.clear()
- }
- }
|