装备:分解装备获得奖励合起来
This commit is contained in:
@@ -38,7 +38,7 @@ export async function handleCost(roleId: string, sid: string, goods: Array<ItemI
|
||||
}
|
||||
//检查装备是否存在
|
||||
if (equips.length > 0) {
|
||||
resEquips = await EquipModel.getEquips(equipSeqIds);
|
||||
resEquips = await EquipModel.getEquips(roleId, equipSeqIds);
|
||||
if (resEquips.length < equips.length)
|
||||
return false;
|
||||
}
|
||||
@@ -109,7 +109,7 @@ export async function addItems(roleId: string, roleName: string, sid: string, go
|
||||
for (let equip of equipInfos) {
|
||||
showItems.push({ seqId: equip.seqId, id: equip.id, count: 1, isBag: true });
|
||||
}
|
||||
for(let equip of combineEquips(mailEquips)) {
|
||||
for(let equip of combineItems(mailEquips)) {
|
||||
showItems.push({ id: equip.id, count: equip.count, isBag: false });
|
||||
}
|
||||
//装备推送
|
||||
@@ -123,7 +123,7 @@ export async function addItems(roleId: string, roleName: string, sid: string, go
|
||||
}
|
||||
// 发邮件的
|
||||
if(mailEquips.length > 0) {
|
||||
await sendMailByContent(MAIL_TYPE.EQUIP_OVER, roleId, { goods: combineEquips(mailEquips) });
|
||||
await sendMailByContent(MAIL_TYPE.EQUIP_OVER, roleId, { goods: combineItems(mailEquips) });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,14 +195,14 @@ export async function addItems(roleId: string, roleName: string, sid: string, go
|
||||
return showItems;
|
||||
}
|
||||
|
||||
function combineEquips(equips: { id?: number }[]) {
|
||||
export function combineItems(items: { id?: number, count?: number }[]) {
|
||||
let result: { id: number, count: number }[] = [];
|
||||
for(let { id } of equips) {
|
||||
for(let { id, count = 1 } of items) {
|
||||
let index = result.findIndex(cur => cur.id == id);
|
||||
if(index == -1) {
|
||||
result.push({ id, count: 1 });
|
||||
result.push({ id, count });
|
||||
} else {
|
||||
result[index].count ++;
|
||||
result[index].count += count;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user