领取奇遇事件
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
|
||||
import { ActionPointModel } from '../../../db/ActionPoint';
|
||||
import { BattleDropModel } from '../../../db/BattleDrop';
|
||||
import { CounterModel } from '../../../db/Counter';
|
||||
import { EquipModel } from '../../../db/Equip';
|
||||
|
||||
import { getWarById, getGoodById } from '../../../util/gamedata';
|
||||
import { decodeStr } from '../../../util/util';
|
||||
import { decodeStr, Reward } from '../../../util/util';
|
||||
import { ACTION_POIN, BATTLE_REWARD_TYPE, GOOD_TYPE } from '../../../consts/consts';
|
||||
|
||||
export async function getAp(now: number, roleId: string) {
|
||||
@@ -127,41 +125,9 @@ export class WarReward {
|
||||
await this.handleConditionReward(num);
|
||||
await this.handleRandomReward(num);
|
||||
|
||||
let returnGoods = new Array();
|
||||
for(let goods of this.rewards) {
|
||||
let goodInfo = getGoodById(goods.gid);
|
||||
if(goodInfo.goodType == GOOD_TYPE.EQUIP) { // 装备
|
||||
let result = await this.rewardWeapons(goodInfo, {id: goods.gid, cnt: goods.count });
|
||||
for(let obj of result) {
|
||||
returnGoods.push({dropType: goods.type, ...obj})
|
||||
}
|
||||
}
|
||||
}
|
||||
let rewardObject = new Reward(this.roleId, this.roleName, this.rewards);
|
||||
let returnGoods = await rewardObject.saveReward();
|
||||
return returnGoods;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private async rewardWeapons (dicGood: any, weapon: {id:number,cnt:number }) {
|
||||
|
||||
let weaponsData = [];
|
||||
let cnt = weapon.cnt;
|
||||
while (cnt > 0) {
|
||||
const seqId = await CounterModel.getNewCounter('eid');
|
||||
const equipInfo = {
|
||||
roleId: this.roleId,
|
||||
roleName: this.roleName,
|
||||
eid: weapon.id,
|
||||
eName: dicGood.name,
|
||||
seqId,
|
||||
quality: dicGood.lv,
|
||||
type: dicGood.goodType
|
||||
}
|
||||
const equip = await EquipModel.createEquip(equipInfo);
|
||||
cnt -= 1;
|
||||
weaponsData.push(equip);
|
||||
}
|
||||
return weaponsData;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user