// 商店商品表 import { readFileAndParse } from '../util' import { FILENAME } from '../../consts' export interface DicShop { // 商品id readonly id: number; // 物品表id readonly goodId: number; // 物品表名 readonly goodName: number; // 商店id 对应 dic_zyz_shoplist的id readonly shop: number; // 商店标签 对应 dic_zyz_shopType的id readonly type: number; // 军团等级需求 readonly guildLvLimit: number; // 玩家等级需求 readonly lvLimit: number; // 购买次数限制 readonly purchaseLimit: number; // vip购买次数限制 readonly vipPurchaseLimit: number; // 刷新类型 1-每日 2-每周 3-每月 readonly refreshType: number; // 用于购买的货币 readonly money: number; // 价格 readonly price: string; } export const dicShopItem = new Map(); // itemid => DicShop export const dicShopByType = new Map(); // shop + type => DicShop[] export function loadShop() { dicShopItem.clear(); dicShopByType.clear(); let arr = readFileAndParse(FILENAME.DIC_SHOP); arr.forEach(o => { o.guildLvLimit = o.guildLvLimit == '&'?0: o.guildLvLimit; o.lvLimit = o.lvLimit == '&'?0: o.lvLimit; o.purchaseLimit = o.purchaseLimit == '&'?-1: (o.purchaseLimit||0); o.vipPurchaseLimit = o.vipPurchaseLimit == '&'? 0: (o.vipPurchaseLimit||0); let key = `${o.shop}_${o.type}`; if(!dicShopByType.has(key)) { dicShopByType.set(key, { shop: o.shop, type: o.type, items: [] }); } else { dicShopByType.get(key).items.push(o); } dicShopItem.set(o.id, o); }); arr = undefined; }