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GAAG,GAAG,GAAG,EAAE,GAAG,MAAM,CAAC,GAAG,KAAK,CAAC;QAC/E,gBAAU,CAAC,UAAU,EAAE,CAAC;QACxB,OAAO,GAAG,CAAC;IACf,CAAC;IAGM,WAAW;QACd,IAAI,CAAC,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,SAAS,KAAK,EAAE,EAAE;YAC1C,OAAO,IAAI,CAAC,IAAI,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;IAED;;;OAGG;IACI,sBAAsB,CAAC,IAAa;QACvC,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI;YACzB,OAAO,oBAAoB,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,GAAG,GAAG,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;SAEjG;aAAM;YACH,OAAO,oBAAoB,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,GAAG,GAAG,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,sBAAQ,CAAC,MAAM,CAAC;SAE/G;IACL,CAAC;CAEJ;AA5OD,oCA4OC","file":"","sourceRoot":"/","sourcesContent":["import { ConfigManager } from \"simba-config-manager\";\r\nimport { DeepReadonlyObject } from \"simba-utils\";\r\nimport { GameRecord, PlotManager } from \"../../avg/AVG\";\r\nimport { FaceType, RoleType } from \"../../avg/EditorEnums\";\r\nimport { GameTextData } from \"../../common/gameplay/gamedata/GameTextData\";\r\nimport { UIManager } from \"../../common/gameplay/managers/UIManager\";\r\nimport { StringUtils } from \"../../common/utils/StringUtils\";\r\nimport { relationLevelConfig } from \"../../config/RelationLevelConfig\";\r\nimport { IRole } from \"../../config/Role\";\r\nimport { GameModelManager } from \"./GameModelManager\";\r\n\r\nexport default class GameRoleDataModel {\r\n private _cfg: DeepReadonlyObject<IRole> = undefined as unknown as DeepReadonlyObject<IRole>;\r\n private _curSkin: number = -1;\r\n private _skinMaps: Set<number> = new Set<number>();\r\n private _roleName: string = \"\";\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.initData();\r\n this.initVariablesChange();\r\n }\r\n\r\n initVariablesChange() {\r\n let func = (scope: string, varName: string, prevValue: string | number, value: string | number) => {\r\n value = value === undefined ? 0 : value;\r\n prevValue = prevValue === undefined ? 0 : prevValue;\r\n let newLike = (value as number) - (prevValue as number);\r\n UIManager.showToast(StringUtils.format(GameModelManager.getLanguageTxt(GameTextData.GAME_TEXT_LIKE_CHANGE_VALUE), this._cfg.name, newLike));\r\n }\r\n\r\n GameRecord.onRecordVariableChange(\"like\" + this._cfg.id, func);\r\n\r\n GameRecord.onGlobalVariableChange(\"like\" + this._cfg.id, func);\r\n }\r\n\r\n hasSkin(id: number) {\r\n return this._skinMaps.has(id);\r\n }\r\n\r\n getRoleLike(): number {\r\n let g = GameRecord.globalVariables[\"like\" + this._cfg.id];\r\n g = g ? g : 0;\r\n // let r = GameRecord.recordVariables[\"like\" + this._cfg.id];\r\n let r = PlotManager.getAllRecordVariableValue(\"like\" + this._cfg.id);\r\n r = r ? r : 0;\r\n let l = g + r;\r\n return l;\r\n }\r\n\r\n addRoleLike(like: number, globalRecord: boolean = true) {\r\n let pre = this.getRoleLike();\r\n let after = pre + like;\r\n after = after > 0 ? after : 0;\r\n let offset = after - pre;\r\n if (globalRecord) {\r\n let g = GameRecord.globalVariables[\"like\" + this._cfg.id];\r\n g = g ? g : 0;\r\n g += offset;\r\n GameRecord.globalVariables[\"like\" + this._cfg.id] = g;\r\n } else {\r\n let r = GameRecord.recordVariables[\"like\" + this._cfg.id] as number;\r\n r = r ? r : 0;\r\n r += offset;\r\n GameRecord.recordVariables[\"like\" + this._cfg.id] = r;\r\n }\r\n GameRecord.saveRecord();\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() {\r\n let ret = \"/textures/head_icon/\" + 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 getNameIcon() {\r\n let ret = \"/textures/name_icon/\" + this._cfg.id;\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 setCurSkin(id: number) {\r\n this._curSkin = id;\r\n GameRecord.globalVariables[\"curskin_\" + this._cfg.id + \"_skin\"] = id;\r\n GameRecord.autoSave();\r\n }\r\n\r\n getCurSkin(): number {\r\n return this._curSkin;\r\n }\r\n\r\n initSkin() {\r\n this._curSkin = GameRecord.globalVariables[\"curskin_\" + this._cfg.id + \"_skin\"];\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 getOwnedSkins(): Set<number> {\r\n return this._skinMaps;\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\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): { result: boolean, errorinfo: string } {\r\n let ret: { result: boolean, errorinfo: string } = { result: false, errorinfo: \"\" };\r\n let cfg = GameModelManager.getItemConfig(id);\r\n let validProp: boolean = cfg ? true : false;\r\n if (!validProp) {\r\n ret.errorinfo = \"prop id \" + id + \" not exist\";\r\n return ret;\r\n }\r\n let max = cfg['max_num'] ? cfg['max_num'] : Number.MAX_VALUE;\r\n if (Math.abs(num) > max) {\r\n ret.errorinfo = \"input num over max , num abs value limit \" + max;\r\n return ret;\r\n }\r\n let value = this._itemMaps.get(id) as number;\r\n if (value >= max && num > 0) {\r\n ret.result = false;\r\n ret.errorinfo = \"cur value over or equal max value limit \" + max;\r\n return ret;\r\n } else {\r\n value += num;\r\n ret.result = true;\r\n }\r\n if (value > max) {\r\n ret.errorinfo = \"value over max , set num as max\";\r\n } else if (value === max) {\r\n ret.errorinfo = \"value equal max\";\r\n } else if (value < 0) {\r\n ret.errorinfo = \"value less 0 , set num as 0\";\r\n } else {\r\n ret.errorinfo = \"succeed\";\r\n }\r\n value = value > max ? max : value;\r\n value = value < 0 ? 0 : value;\r\n this._itemMaps.set(id, value);\r\n GameRecord.globalVariables[\"prop_\" + this._cfg.id + \"_\" + id + \"_num\"] = value;\r\n GameRecord.saveRecord();\r\n return ret;\r\n }\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 /**\r\n * \r\n * @param skin 皮肤id\r\n */\r\n public getBagPortraitByRoleId(skin?: number) {\r\n if (this._cfg.id == 2) { //自己\r\n return \"textures/portrait/\" + this._cfg.id + \"/\" + (skin !== undefined ? skin + \"/\" : \"\") + 7;\r\n\r\n } else {\r\n return \"textures/portrait/\" + this._cfg.id + \"/\" + (skin !== undefined ? skin + \"/\" : \"\") + FaceType.Normal;\r\n\r\n }\r\n }\r\n\r\n}"]}