增加获取物品接口
This commit is contained in:
parent
a64781da95
commit
55ae9859c2
@ -78,7 +78,7 @@ let ItemMan = {
|
||||
},
|
||||
|
||||
/**
|
||||
* findItem
|
||||
* findItem:根据物品id查找物品对象
|
||||
*/
|
||||
findItem(itemid: number): CommonItem {
|
||||
return this._items.get(itemid);
|
||||
@ -93,6 +93,26 @@ let ItemMan = {
|
||||
return item? item.isPackage(): false;
|
||||
},
|
||||
|
||||
/**
|
||||
* 根据字符串获取物品列表
|
||||
* @param infostr : id1:count1|id2:count2|...
|
||||
* @returns 物品列表
|
||||
*/
|
||||
getItemsByInfo(infostr: string): ItemInfo[]{
|
||||
let reslst: ItemInfo[] = [];
|
||||
let lst = infostr.split('|');
|
||||
lst.forEach((v: string) =>{
|
||||
let item = new ItemInfo();
|
||||
if(item.loadInfo(v)){
|
||||
let obj = this.findItem(item.id);
|
||||
obj && (item.type = obj._type);
|
||||
reslst.push(item);
|
||||
}
|
||||
});
|
||||
|
||||
return reslst;
|
||||
},
|
||||
|
||||
_useItem(item: CommonItem, count: number, dpcard: boolean, reslst: CIC[]){
|
||||
if(item.isPackage() && item._isautoopen){
|
||||
this._openItemPkg(item, count, false, reslst);
|
||||
|
@ -55,6 +55,19 @@ export class ItemInfo{
|
||||
loadData(itemid: number, itemcount: number){
|
||||
this.id = itemid;
|
||||
this.count = itemcount;
|
||||
};
|
||||
|
||||
loadInfo(infostr: string){
|
||||
if(!infostr){
|
||||
return false;
|
||||
}
|
||||
let l = infostr.split(':');
|
||||
if(l.length >= 2){
|
||||
this.id = parseInt(l[0]);
|
||||
this.count = parseInt(l[1]);
|
||||
return this.id > 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
@ -93,9 +106,8 @@ export class CommonItem{
|
||||
|
||||
let lst = aitem.decomposition_to_obtain.split('|');
|
||||
lst.forEach((v: string) => {
|
||||
let l = v.split(':');
|
||||
if(l.length >= 2){
|
||||
let item = new ItemInfo(parseInt(l[0]), parseInt(l[1]));
|
||||
let item = new ItemInfo();
|
||||
if(item.loadInfo(v)){
|
||||
if(!this._solidsubitems){
|
||||
this._solidsubitems = [item];
|
||||
}else{
|
||||
@ -117,16 +129,12 @@ export class CommonItem{
|
||||
this._randsubtype = aitem.candtypeid;
|
||||
this._randsubgrade = aitem.candgradeid;
|
||||
|
||||
let lst = aitem.Price.split(':');
|
||||
if(lst.length >= 2){
|
||||
this._priceinfo.loadData(parseInt(lst[0]), parseInt(lst[1]));
|
||||
}
|
||||
this._priceinfo.loadInfo(aitem.Price);
|
||||
|
||||
lst = aitem.drop.split('|');
|
||||
let lst = aitem.drop.split('|');
|
||||
lst.forEach((v: string) => {
|
||||
let l = v.split(':');
|
||||
if(l.length >= 2){
|
||||
let item = new ItemInfo(parseInt(l[0]), parseInt(l[1]));
|
||||
let item = new ItemInfo();
|
||||
if(item.loadInfo(v)){
|
||||
if(!this._solidsubitems){
|
||||
this._solidsubitems = [item];
|
||||
}else{
|
||||
|
Loading…
x
Reference in New Issue
Block a user