/** @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(value, {ext: '.png'}, (err, texture) => { if (!err) this.avatarTex = texture }) } private _avatarUrl: string = '' avatarTex: cc.Texture2D = null renameTime: number = 0 goods: Map 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 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() 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() } }