武将重生:添加消耗记录
This commit is contained in:
@@ -7,7 +7,7 @@ import { Teraph, RoleModel, RoleType, RoleUpdate } from '../db/Role';
|
||||
import { SCHOOL } from '../pubUtils/dicParam';
|
||||
import { gameData } from '../pubUtils/data';
|
||||
import { SchoolModel } from '../db/School';
|
||||
import { SclResultInter, SclPosInter, RewardInter } from '../pubUtils/interface';
|
||||
import { SclResultInter, SclPosInter, RewardInter, ItemInter } from '../pubUtils/interface';
|
||||
import { CheckMeterial } from './rewardService';
|
||||
import { HeroUpdate } from '../db/Hero';
|
||||
import { SkinUpdate } from '../db/Skin';
|
||||
@@ -153,9 +153,22 @@ export function getInitHeroById(hid: number) {
|
||||
}
|
||||
}
|
||||
|
||||
export function addConsumeToHero(oldConsume: Reward[], consumes: RewardInter[]) {
|
||||
export function addConsumeToHero(oldConsume: Reward[] = [], consumes: ItemInter[] = []) {
|
||||
let consumeMap = new Map<number, number>();
|
||||
for(let { id, count = 1 } of consumes) {
|
||||
consumeMap.set(id, count);
|
||||
}
|
||||
let newConsume: Reward[] = [];
|
||||
for(let {id, count} of oldConsume) {
|
||||
|
||||
if(consumeMap.has(id)) {
|
||||
newConsume.push({ id, count: count + consumeMap.get(id)});
|
||||
consumeMap.delete(id);
|
||||
} else {
|
||||
newConsume.push({ id, count });
|
||||
}
|
||||
}
|
||||
for(let [id, count] of consumeMap) {
|
||||
newConsume.push({ id, count });
|
||||
}
|
||||
return newConsume;
|
||||
}
|
||||
Reference in New Issue
Block a user