import { Framework } from "../../framework/Framework"; import { ItemEnum } from "../common/InterfaceAddEnum"; import { MaterialConf } from "../config/MaterialConf"; import { GameEvent } from "./GameEvent"; interface BaseItem { conf: {}; id: string; count: number; type: ItemEnum; } class Data { private _goodsData: { [id: string]: BaseItem } = {}; init(): void { this.reset(); } reset(): void { this._goodsData = {}; } purge(): void { this.reset(); } setAllGoods(data) { this._goodsData = {}; let conf = MaterialConf.data; for (const key in data) { if (Object.prototype.hasOwnProperty.call(data, key)) { const element = data[key]; let mConf = conf[key]; if (mConf) { let item = { id: key, count: Number(element), type: ItemEnum.material, conf: mConf, } this._goodsData[key] = item; } } } } getAllGoods() { return this._goodsData; } } export let GoodsData = new Data;