添加刷新消耗

This commit is contained in:
luying
2021-01-08 16:41:24 +08:00
parent 12f308f0f5
commit e17ed4cd47
10 changed files with 66 additions and 23 deletions
+14 -2
View File
@@ -3,10 +3,10 @@
*/
import { PvpDefenseModel, Heroes, OppPlayers, Robot, PvpDefenseType, HeroScores } from '../db/PvpDefense';
import { RoleType } from '../db/Role';
import { PVP_HERO_POS, ROBOT_NAME, REDIS_KEY } from '../consts';
import { PVP_HERO_POS, ROBOT_NAME, REDIS_KEY, PVP_CONST } from '../consts';
import { setPvpDefResult } from '../services/timeTaskService';
import { dicPvpOpponent, DicPvpOpponent } from "../pubUtils/dictionary/DicPvpOpponent";
import { getRandomIndexByLen, genCode, getRandomByLen } from '../pubUtils/util';
import { getRandomIndexByLen, genCode, getRandomByLen, shouldRefresh } from '../pubUtils/util';
import { oppPlayersInter, RankParam } from '../pubUtils/interface';
import { gameData, getPLvByScore } from "../pubUtils/data";
import { PVP } from '../pubUtils/dicParam';
@@ -267,3 +267,15 @@ export async function findPvpDefByRoleId(roleId: string) {
return {pvpDefense, warId};
}
}
// 获取刷新对手次数及消耗
export function getRefOppCnt(refOppCnt: number, refOppTime: Date) {
let curTime = new Date();
if(shouldRefresh(refOppTime, curTime, PVP_CONST.REFRESH_TIME)) {
refOppCnt = 0; refOppTime = curTime;
}
return {
refOppCnt, refOppTime,
consume: gameData.pvpRefreshConsume.get(refOppCnt + 1)
}
}