EquipData.ts 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import { ItemEnum } from "../common/InterfaceAddEnum";
  2. import { EquipConf } from "../config/EquipConf";
  3. import { EquipManager } from "../manager/EquipManager";
  4. export interface Equip {
  5. id: string;
  6. count: number;
  7. exp: number;
  8. star: number;
  9. wear: boolean;
  10. type: ItemEnum;
  11. fightForce: number
  12. conf: {};
  13. }
  14. class Data {
  15. private _equipData: { [id: string]: Equip } = {};
  16. private _bagData: { [id: string]: Equip } = {};
  17. init(): void {
  18. this.reset();
  19. }
  20. reset(): void {
  21. this._equipData = {};
  22. this._bagData = {};
  23. }
  24. purge(): void {
  25. this.reset();
  26. }
  27. setData(bagData, equipData) {
  28. this._equipData = {};
  29. this._bagData = {};
  30. for (const key in bagData) {
  31. if (Object.prototype.hasOwnProperty.call(bagData, key)) {
  32. const element = bagData[key];
  33. let equip = EquipManager.getEquipById(key, element, false);
  34. if (equip) {
  35. this._bagData[key] = equip;
  36. }
  37. }
  38. }
  39. let conf = EquipConf.data;
  40. for (const race in equipData) {
  41. if (Object.prototype.hasOwnProperty.call(equipData, race)) {
  42. const element = equipData[race];
  43. for (const key in element) {
  44. if (Object.prototype.hasOwnProperty.call(element, key)) {
  45. const eid = element[key];
  46. if (eid != 0) {
  47. let equip = EquipManager.getEquipById(eid, 1, true);
  48. if (equip) {
  49. this._bagData[key + '_' + race] = equip;
  50. }
  51. }
  52. }
  53. }
  54. }
  55. }
  56. console.log('=========_bagData========',this._bagData);
  57. }
  58. getData() {
  59. return this._bagData;
  60. }
  61. }
  62. export let EquipData = new Data;