RoleData.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { RoleConf } from "../ui/tower/conf/RoleConf";
  2. import { UserData } from "./UserData";
  3. //服务器端返回的英雄数据
  4. interface RoleServer {
  5. id: string; //英雄id 动物形象id
  6. grade: number; //星级
  7. dna_lv: string; //基因等级
  8. dna_attr:{any} //基因属性
  9. equip: [];//读取状态
  10. skin: [];//皮肤
  11. fight_force: number;//战力
  12. conf:{}//配置
  13. }
  14. class Data {
  15. private _roles: { [id: string]: RoleServer } = {};
  16. setData(data: {[id: string]:RoleServer}): void {
  17. let rConf = RoleConf.data;
  18. if (data) {
  19. for(const id in data) {
  20. if (data.hasOwnProperty(id)) {
  21. if (rConf[id]){
  22. const role = data[id];
  23. role.conf = rConf[id];
  24. this._roles[id] = role;
  25. // console.log(`ID: ${id}, Name: ${role.name}, Level: ${role.level}`);
  26. }
  27. }
  28. }
  29. }
  30. }
  31. getData(id: string): RoleServer {
  32. return this._roles[id];
  33. }
  34. }
  35. export let RoleData = new Data;