物品处理逻辑(未完)
This commit is contained in:
parent
c23bac2d9f
commit
c8a9e89be7
@ -48,6 +48,16 @@ let ItemMan = {
|
|||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取单个物品价格
|
||||||
|
* @param itemid : 物品id
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
getItemPrice(itemid: number): ItemInfo{
|
||||||
|
let item: CommonItem = this._items.get(itemid);
|
||||||
|
return item? item._priceinfo: new ItemInfo();
|
||||||
|
},
|
||||||
|
|
||||||
initItems(){
|
initItems(){
|
||||||
this._items.clear();
|
this._items.clear();
|
||||||
|
|
||||||
@ -63,37 +73,63 @@ let ItemMan = {
|
|||||||
map.forEach((v: DropItemCfg, k: number) => {
|
map.forEach((v: DropItemCfg, k: number) => {
|
||||||
if(k != 0){
|
if(k != 0){
|
||||||
let item = new CommonItem();
|
let item = new CommonItem();
|
||||||
|
item.loadDropItem(v);
|
||||||
|
this._items.set(k, item);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
initCardItems(){
|
initCardItems(){
|
||||||
this._card_lvs.clear();
|
|
||||||
this._card_types.clear();
|
|
||||||
|
|
||||||
let map: Map<number, ItemCardCfg> = global.$cfg.get(BaseConst.ITEMCARD);
|
let map: Map<number, ItemCardCfg> = global.$cfg.get(BaseConst.ITEMCARD);
|
||||||
map.forEach((v: ItemCardCfg, k: number) => {
|
map.forEach((v: ItemCardCfg, k: number) => {
|
||||||
let lst = this._card_lvs.get(v.gradeid);
|
if(k != 0){
|
||||||
if(!lst){
|
let item = new CommonItem();
|
||||||
lst = [v];
|
item.loadCardItem(v);
|
||||||
this._card_lvs.set(v.gradeid, lst);
|
this._items.set(k, item);
|
||||||
}else{
|
|
||||||
lst.push(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
lst = this._card_types.get(v.typeid);
|
|
||||||
if(!lst){
|
|
||||||
lst = [v];
|
|
||||||
this._card_types.set(v.typeid, lst);
|
|
||||||
}else{
|
|
||||||
lst.push(v);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
handleItems(){
|
handleItems(){
|
||||||
|
this.handCardCaches();
|
||||||
|
|
||||||
|
this.handRandWeights();
|
||||||
|
},
|
||||||
|
|
||||||
|
handCardCaches(){
|
||||||
|
this._card_lvs.clear();
|
||||||
|
this._card_types.clear();
|
||||||
|
|
||||||
|
this._items.forEach((v: CommonItem, k: number) =>{
|
||||||
|
let lst = this._card_lvs.get(v._grade);
|
||||||
|
if(!lst){
|
||||||
|
lst = [v];
|
||||||
|
this._card_lvs.set(v._grade, lst);
|
||||||
|
}else{
|
||||||
|
lst.push(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
lst = this._card_types.get(v._type);
|
||||||
|
if(!lst){
|
||||||
|
lst = [v];
|
||||||
|
this._card_types.set(v._type, 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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
handRandWeights(){
|
||||||
|
this._items.forEach((v: CommonItem, k: number) =>{
|
||||||
|
if(v._randexitems || v._randsubgrade || v._randsubtype){
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -42,10 +42,15 @@ export class ItemInfo{
|
|||||||
id: number;
|
id: number;
|
||||||
count: number;
|
count: number;
|
||||||
weight: number = 0;
|
weight: number = 0;
|
||||||
constructor(itemid: number, itemcount: number, itemweight: number = 0){
|
constructor(itemid?: number, itemcount?: number, itemweight?: number){
|
||||||
|
this.id = itemid? itemid: 0;
|
||||||
|
this.count = itemcount? itemcount: 0;
|
||||||
|
this.weight = itemweight? itemweight: 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
loadData(itemid: number, itemcount: number){
|
||||||
this.id = itemid;
|
this.id = itemid;
|
||||||
this.count = itemcount;
|
this.count = itemcount;
|
||||||
this.weight = itemweight;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -58,6 +63,7 @@ export class CommonItem{
|
|||||||
public _isautoopen: boolean = false;
|
public _isautoopen: boolean = false;
|
||||||
|
|
||||||
public _weight: number = 0;
|
public _weight: number = 0;
|
||||||
|
public _priceinfo: ItemInfo = null;
|
||||||
|
|
||||||
public _randsubtype: number = 0;
|
public _randsubtype: number = 0;
|
||||||
public _randsubgrade: number = 0;
|
public _randsubgrade: number = 0;
|
||||||
@ -68,6 +74,10 @@ export class CommonItem{
|
|||||||
|
|
||||||
public _randsubitems: ItemInfo[];
|
public _randsubitems: ItemInfo[];
|
||||||
|
|
||||||
|
constructor(){
|
||||||
|
this._priceinfo = new ItemInfo();
|
||||||
|
};
|
||||||
|
|
||||||
public loadCardItem(aitem: ItemCardCfg){
|
public loadCardItem(aitem: ItemCardCfg){
|
||||||
this._id = aitem.id;
|
this._id = aitem.id;
|
||||||
this._type = COMMON_ITEM_TYPE.CARD;
|
this._type = COMMON_ITEM_TYPE.CARD;
|
||||||
@ -103,7 +113,12 @@ export class CommonItem{
|
|||||||
this._randsubtype = aitem.candtypeid;
|
this._randsubtype = aitem.candtypeid;
|
||||||
this._randsubgrade = aitem.candgradeid;
|
this._randsubgrade = aitem.candgradeid;
|
||||||
|
|
||||||
let lst = aitem.drop.split('|');
|
let lst = aitem.Price.split(':');
|
||||||
|
if(lst.length >= 2){
|
||||||
|
this._priceinfo.loadData(parseInt(lst[0]), parseInt(lst[1]));
|
||||||
|
}
|
||||||
|
|
||||||
|
lst = aitem.drop.split('|');
|
||||||
lst.forEach((v: string) => {
|
lst.forEach((v: string) => {
|
||||||
let l = v.split(':');
|
let l = v.split(':');
|
||||||
if(l.length >= 2){
|
if(l.length >= 2){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user