diff --git a/src/common/GConfig.ts b/src/common/GConfig.ts index ce749ec..cda2338 100644 --- a/src/common/GConfig.ts +++ b/src/common/GConfig.ts @@ -7,6 +7,7 @@ import { DropItemCfg } from '../cfg/parsers/DropItemCfg' import { ItemCardCfg } from '../cfg/parsers/ItemCardCfg' import { MatchCfg } from '../cfg/parsers/MatchCfg' import { ItemFuncCfg } from '../cfg/parsers/ItemFuncCfg' +import ItemCtrl from "logic/ItemCtrl"; export function initData() { @@ -19,6 +20,6 @@ export function initData() { rP(BaseConst.MATCH, MatchCfg); rP(BaseConst.ITEMFUNC, ItemFuncCfg); DataParser.loadAll(); - + ItemCtrl.initItems(); } diff --git a/src/logic/ItemCtrl.ts b/src/logic/ItemCtrl.ts index 0725ea0..5656c4b 100644 --- a/src/logic/ItemCtrl.ts +++ b/src/logic/ItemCtrl.ts @@ -2,11 +2,13 @@ import { DropItemCfg } from "cfg/parsers/DropItemCfg"; import { ItemCardCfg } from "cfg/parsers/ItemCardCfg"; import { ZError } from "common/ZError"; import { BaseConst } from "constants/BaseConst"; -import { CommonItem, ItemInfo } from "./ItemDef"; +import { CommonItem, COMMON_ITEM_TYPE, ItemInfo } from "./ItemDef"; let ItemMan = { - // 卡牌按品质分 - _card_lvs: new Map(), + // 物品按品质分 + _item_grades: new Map(), + // 物品按类型分 + _item_types: new Map(), // 卡牌按子类型分 _card_types: new Map(), @@ -59,6 +61,7 @@ let ItemMan = { }, initItems(){ + return; this._items.clear(); // 默认id都唯一 @@ -91,32 +94,42 @@ let ItemMan = { }, handleItems(){ - this.handCardCaches(); + this.handCaches(); this.handRandWeights(); }, - handCardCaches(){ - this._card_lvs.clear(); + handCaches(){ + this._item_grades.clear(); this._card_types.clear(); this._items.forEach((v: CommonItem, k: number) =>{ - let lst = this._card_lvs.get(v._grade); + let lst = this._item_grades.get(v._grade); if(!lst){ lst = [v]; - this._card_lvs.set(v._grade, lst); + this._item_grades.set(v._grade, lst); }else{ lst.push(v); } - lst = this._card_types.get(v._type); + lst = this._item_types.get(v._type); if(!lst){ lst = [v]; - this._card_types.set(v._type, lst); + this._item_types.set(v._type, lst); }else{ lst.push(v); } + if(v._type == COMMON_ITEM_TYPE.CARD){ + lst = this._card_types.get(v._subtype); + if(!lst){ + lst = [v]; + this._card_types.set(v._subtype, lst); + }else{ + lst.push(v); + } + } + v._randexitems && v._randexitems.forEach((item: ItemInfo) =>{ let obj: CommonItem = this._items.get(item.id); obj && (item.weight = obj._weight); @@ -127,7 +140,19 @@ let ItemMan = { handRandWeights(){ this._items.forEach((v: CommonItem, k: number) =>{ if(v._randexitems || v._randsubgrade || v._randsubtype){ - + if(!v._randsubitems){ + v._randsubitems = []; + } + let lst = []; + if(v._randsubtype == COMMON_ITEM_TYPE.CARD && v._randsubgrade){ + lst = this._card_types.get(v._randsubgrade); + }else{ + lst = this._item_types.get(v._randsubtype); + } + + lst.forEach((element: CommonItem) => { + + }); } }); }