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CAAC,IAAI,CAAC;SACzB;aAAM;YACH,OAAO,IAAI,CAAC,SAAS,CAAC;SACzB;IACL,CAAC;IAEM,WAAW,CAAC,IAAY;QAC3B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IAC1B,CAAC;CAEJ;AA5LD,oCA4LC","file":"","sourceRoot":"/","sourcesContent":["import { DeepReadonlyObject } from \"simba-utils\";\r\nimport { IRole } from \"../../config/Role\";\r\nimport { GameRecord } from \"../../avg/game-data/GameRecord\";\r\nimport { GameModelManager } from \"./GameModelManager\";\r\nimport { ConfigManager } from \"../../common/gameplay/managers/ConfigManager\";\r\nimport { itemConfig } from \"../../config/ItemConfig\";\r\nimport { relationLevelConfig } from \"../../config/RelationLevelConfig\";\r\nimport { FaceType } from \"../../avg/EditorEnums\";\r\n\r\nexport default class GameRoleDataModel {\r\n private _cfg: DeepReadonlyObject<IRole> = undefined as unknown as DeepReadonlyObject<IRole>;\r\n private _goldcoin: number = 0;//金币\r\n private _clothcoin: number = 0;//服装币\r\n private _skins: number[] = [];\r\n private _curSkin: number = -1;\r\n private _skinMaps: Set<number> = new Set<number>();\r\n private _roleName: string = \"\";\r\n private _energyValue: number = 0;//灵力值\r\n\r\n private _itemMaps: Map<number, number> = new Map<number, number>();\r\n\r\n public setConfig(cfg: DeepReadonlyObject<IRole>) {\r\n this._cfg = cfg;\r\n this.initDate();\r\n }\r\n\r\n public getConfig() {\r\n return this._cfg;\r\n }\r\n\r\n initDate() {\r\n this.initSkin();\r\n this.initCoin();\r\n this.initData();\r\n }\r\n\r\n hasSkin(id: number) {\r\n return this._skinMaps.has(id);\r\n }\r\n\r\n getRoleLike() {\r\n return GameRecord.globalVariables[\"like\" + this._cfg.id] + GameRecord.recordVariables[\"like\" + this._cfg.id];\r\n }\r\n\r\n getPortrait(face = FaceType.Normal, skin?: number) { // TODO 默认皮肤更改?\r\n if (skin === undefined && this._curSkin > 0) skin = this._curSkin;\r\n return \"textures/portrait/\" + this._cfg.id + \"/\" + (skin !== undefined ? skin + \"/\" : \"\") + face;\r\n }\r\n\r\n getBust(skin?: number) {\r\n if (skin === undefined && this._curSkin > 0) skin = this._curSkin;\r\n let ret = \"textures/bust/\" + this._cfg.id;\r\n if (skin) {\r\n ret += skin;\r\n }\r\n return ret;\r\n }\r\n\r\n getHeadIcon(small = false) {\r\n let ret = \"textures/head_icon/\" + (small ? \"small/\" : \"large/\") + this._cfg.id;\r\n if (this._curSkin > 0) {\r\n ret += \"_\" + this._curSkin;\r\n }\r\n return ret;\r\n }\r\n\r\n getRoleLikeLevel() {\r\n let configs = ConfigManager.getAllConfig(relationLevelConfig);\r\n let level = 0;\r\n let like = this.getRoleLike();\r\n const maxLevel = Object.keys(configs).length;\r\n let levelValue = 0;\r\n for (let id = 1; id <= maxLevel; id++) {\r\n levelValue = configs[id].relation_value;\r\n if (like >= levelValue) {\r\n like -= levelValue;\r\n level = id;\r\n } else {\r\n break;\r\n }\r\n }\r\n return { level, currLike: like, nextLevelLike: levelValue, maxLevel };\r\n }\r\n\r\n addSkin(id: number) {\r\n this._skinMaps.add(id);\r\n let skinsstr = \"\";\r\n let index = 0;\r\n for (let value of this._skinMaps) {\r\n skinsstr += value;\r\n if (index != this._skinMaps.size - 1) {\r\n skinsstr += \",\";\r\n }\r\n ++index;\r\n }\r\n\r\n GameRecord.globalVariables[\"skins_\" + this._cfg.id + \"_skins\"] = skinsstr;\r\n GameRecord.autoSave();\r\n }\r\n\r\n initSkin() {\r\n let curSkin = GameRecord.globalVariables[\"curskin_\" + this._cfg.id + \"_skin\"];\r\n this._curSkin = curSkin === undefined ? this._cfg['drawing'] : curSkin;\r\n\r\n let skins = GameRecord.globalVariables[\"skins_\" + this._cfg.id + \"_skins\"] as string;\r\n skins = skins === undefined ? \"\" : skins;\r\n let skinSpilt = skins.split(\",\");\r\n for (let index = 0; index < skinSpilt.length; ++index) {\r\n this._skinMaps.add(parseInt(skinSpilt[index]));\r\n }\r\n }\r\n\r\n initCoin() {\r\n let goldcoin = GameRecord.globalVariables[\"goldcoin_\" + this._cfg.id + \"_num\"] as number;\r\n this._goldcoin = goldcoin === undefined ? 0 : goldcoin;\r\n let clothcoin = GameRecord.globalVariables[\"clothcoin_\" + this._cfg.id + \"_num\"] as number;\r\n this._clothcoin = clothcoin === undefined ? 0 : clothcoin;\r\n }\r\n\r\n initData() {\r\n this._itemMaps.clear();\r\n let props = GameModelManager.getItemConfigs();\r\n for (let key in props) {\r\n let value = props[key];\r\n let recordNum = GameRecord.globalVariables[\"prop_\" + this._cfg.id + value.id + \"_num\"] as number;\r\n recordNum = recordNum === undefined ? 0 : recordNum;\r\n this._itemMaps.set(value.id, recordNum);\r\n }\r\n\r\n this._energyValue = GameRecord.globalVariables[\"energy_\" + this._cfg.id];\r\n this._energyValue = this._energyValue === undefined ? 0 : this._energyValue;\r\n }\r\n\r\n public getProps(id: number) {\r\n return this._itemMaps.get(id);\r\n }\r\n\r\n public addProps(id: number, num: number) {\r\n let value = this._itemMaps.get(id) as number;\r\n value += num;\r\n value = Math.max(0, value);\r\n this._itemMaps.set(id, value);\r\n GameRecord.globalVariables[\"prop_\" + this._cfg.id + \"\" + id + \"_num\"] = value;\r\n GameRecord.autoSave();\r\n }\r\n\r\n public getEnergy(isceil: boolean = true): number {\r\n if (isceil) {\r\n return Math.ceil(this._energyValue);\r\n }\r\n return this._energyValue;\r\n }\r\n\r\n public addEnergy(value: number) {\r\n let max = 100;\r\n let min = 0;\r\n this._energyValue += value;\r\n this._energyValue = Math.max(min, this._energyValue);\r\n this._energyValue = Math.min(max, this._energyValue);\r\n GameRecord.globalVariables[\"energy_\" + this._cfg.id] = this._energyValue;\r\n GameRecord.autoSave();\r\n }\r\n\r\n public getGoldCoin(): number {\r\n return this._goldcoin;\r\n }\r\n\r\n public addGoldCoin(addvalue: number) {\r\n this._goldcoin += addvalue;\r\n GameRecord.globalVariables[\"goldcoin_\" + this._cfg.id + \"_num\"] = this._goldcoin;\r\n GameRecord.autoSave();\r\n }\r\n\r\n public getClothCoin() {\r\n return this._clothcoin;\r\n //return 10000;\r\n }\r\n\r\n public addClothCoin(addvalue: number) {\r\n this._clothcoin += addvalue;\r\n\r\n GameRecord.globalVariables[\"clothcoin_\" + this._cfg.id + \"_num\"] = this._clothcoin;\r\n GameRecord.autoSave();\r\n }\r\n\r\n public getRoleName() {\r\n if (!this._roleName || this._roleName === \"\") {\r\n return this._cfg.name;\r\n } else {\r\n return this._roleName;\r\n }\r\n }\r\n\r\n public setRoleName(name: string) {\r\n this._roleName = name;\r\n }\r\n\r\n}"]}