天梯派遣功能
fix:
天梯挂机等bug修复
This commit is contained in:
liangtongchuan
2020-10-15 23:17:01 +08:00
parent 85940779d2
commit 31c1190e2c
7 changed files with 245 additions and 45 deletions
+57 -1
View File
@@ -1,10 +1,11 @@
import { HeroModel } from './../db/Hero';
import { HangUpRecordModel } from './../db/HangUpRecord';
import { ChannelService } from 'pinus';
import { HANG_UP_CONSTS } from './../consts/consts';
import { BattleRecordModel } from './../db/BattleRecord';
import { TowerRecordModel } from './../db/TowerRecord';
import { RoleModel } from './../db/Role';
import { getTowerDataByLv } from "../util/gamedata"
import { getHeroInfoById, getJobInfoById, getTowerDataByLv } from "../util/gamedata"
import { decodeArrayStr, shouldRefresh } from '../util/util';
import { handleFixedReward } from './rewardService';
@@ -119,4 +120,59 @@ export async function calcuHangUpReward(roleId: string, speedUp = false, speedUp
timeReward: towerInfo.timeReward,
multi
};
}
async function checkCond(roleId: string, heroes, type: number, parm: number, cnt: number) {
let heroCnt = 0;
switch (type) {
case 1:
for(let hid of heroes) {
const rec = await HeroModel.findByHidAndRole(hid, roleId);
if (rec.star >= parm) {
heroCnt++;
}
}
break;
case 2:
for(let hid of heroes) {
const hInfo = getHeroInfoById(hid);
if (hInfo.camp === parm) {
heroCnt++;
}
}
break;
case 3:
for(let hid of heroes) {
const hInfo = getHeroInfoById(hid);
if (getJobInfoById(hInfo.jobid) === parm) {
heroCnt++;
}
}
break;
default:
break;
}
if (heroCnt >= cnt) {
return true;
}
return false;
}
export async function checkTaskConditions(roleId: string, heroes: Array<number>, conditionsStr: string) {
const condArr = conditionsStr.split('|');
if (condArr.length < 1) return false;
let res = true;
for (let cond of condArr) {
const condDetail = cond.split('&');
if (condDetail && condDetail.length === 3) {
const checkRes = await checkCond(roleId, heroes, parseInt(condDetail[0]), parseInt(condDetail[1]), parseInt(condDetail[2]))
if (!checkRes) {
res = false;
break;
}
}
}
return res;
}