import { RoleConf } from "../ui/tower/conf/RoleConf"; import { UserData } from "./UserData"; //服务器端返回的英雄数据 interface RoleServer { id: string; //英雄id 动物形象id grade: number; //星级 dna_lv: string; //基因等级 dna_attr:{any} //基因属性 equip: [];//读取状态 skin: [];//皮肤 fight_force: number;//战力 conf:{}//配置 } class Data { private _roles: { [id: string]: RoleServer } = {}; setData(data: {[id: string]:RoleServer}): void { let rConf = RoleConf.data; if (data) { for(const id in data) { if (data.hasOwnProperty(id)) { if (rConf[id]){ const role = data[id]; role.conf = rConf[id]; this._roles[id] = role; // console.log(`ID: ${id}, Name: ${role.name}, Level: ${role.level}`); } } } } } getData(id: string): RoleServer { return this._roles[id]; } } export let RoleData = new Data;