添加远征每日重置
This commit is contained in:
@@ -5,8 +5,8 @@ import { HANG_UP_CONSTS, TOWER_TASK_CONST } from './../consts/consts';
|
||||
import { BattleRecordModel } from './../db/BattleRecord';
|
||||
import { TowerRecordModel } from './../db/TowerRecord';
|
||||
import { RoleModel } from './../db/Role';
|
||||
import { getHeroInfoById, getJobInfoById, getTowerDataByLv, getTaskById, getTaskIdByFloor } from "../pubUtils/gamedata"
|
||||
import { decodeArrayStr, shouldRefresh, resResult, decodeStr, cal, getRandomWithWeight, getRefTime } from '../pubUtils/util';
|
||||
import { getHeroInfoById, getJobInfoById, getTowerDataByLv, getTaskById, getGamedata } from "../pubUtils/gamedata"
|
||||
import { decodeArrayStr, shouldRefresh, resResult, decodeStr, cal, getRandomWithWeight, getRefTime, decodeStrSingle } from '../pubUtils/util';
|
||||
import { handleFixedReward } from './rewardService';
|
||||
import { STATUS } from '../consts/statusCode';
|
||||
import { HangUpSpdUpRecModel } from '../db/HangUpSpdUpRec';
|
||||
@@ -197,15 +197,16 @@ async function checkCond(roleId: string, heroes, type: number, param: number, cn
|
||||
|
||||
switch (type) {
|
||||
case 1:
|
||||
for(let hid of heroes) {
|
||||
const rec = await HeroModel.findByHidAndRole(hid, roleId);
|
||||
for(let seqId of heroes) {
|
||||
const rec = await HeroModel.findBySeqIdAndRole(seqId, roleId);
|
||||
if (rec.star >= param) {
|
||||
heroCnt++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
for(let hid of heroes) {
|
||||
for(let seqId of heroes) {
|
||||
let {hid} = await HeroModel.findBySeqIdAndRole(seqId, roleId);
|
||||
const hInfo = getHeroInfoById(hid);
|
||||
if (hInfo.camp === param) {
|
||||
heroCnt++;
|
||||
@@ -213,7 +214,8 @@ async function checkCond(roleId: string, heroes, type: number, param: number, cn
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
for(let hid of heroes) {
|
||||
for(let seqId of heroes) {
|
||||
let {hid} = await HeroModel.findBySeqIdAndRole(seqId, roleId);
|
||||
const hInfo = getHeroInfoById(hid);
|
||||
if (getJobInfoById(hInfo.jobid) === param) {
|
||||
heroCnt++;
|
||||
@@ -252,8 +254,16 @@ export async function checkTaskConditions(roleId: string, heroes: Array<number>,
|
||||
export async function createCurTasks(towerLv: number, roleId: string, roleName: string) {
|
||||
|
||||
let taskIds = [];
|
||||
const taskList = getTaskIdByFloor(towerLv)||[];
|
||||
const randomList = taskList.map(taskId => getTaskById(taskId));
|
||||
let randomList = [];
|
||||
let dicTask = getGamedata('dic_zyz_search');
|
||||
for(let task of dicTask) {
|
||||
let {suitFloor} = task;
|
||||
let {min, max} = decodeStrSingle('suitLevel', suitFloor);
|
||||
let flag = max?(towerLv >= min && towerLv <= max): (towerLv >= min);
|
||||
if(flag) {
|
||||
randomList.push(task);
|
||||
}
|
||||
}
|
||||
for(let i = 0; i < TOWER_TASK_CONST.RAND_CNT; i++) {
|
||||
let list = randomList.filter(cur => !taskIds.includes(cur.taskId));
|
||||
let {dic: tmp} = getRandomWithWeight(list);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
|
||||
import { ExpeditionPointModel } from '../db/ExpeditionPoint';
|
||||
import { RoleModel } from '../db/Role';
|
||||
import Role, { RoleModel } from '../db/Role';
|
||||
import { PvpDefenseModel } from '../db/PvpDefense';
|
||||
|
||||
import { getWarJsons, getGamedata } from '../pubUtils/gamedata';
|
||||
import { decodeStr, resResult, setLocalHours } from '../pubUtils/util';
|
||||
import { WAR_JSON_ATTRIBUTE_TYPE } from '../consts/consts';
|
||||
import { decodeStr, resResult, setLocalHours, shouldRefresh } from '../pubUtils/util';
|
||||
import { WAR_JSON_ATTRIBUTE_TYPE, EXPEDITION_CONST } from '../consts/consts';
|
||||
|
||||
|
||||
// 匹配玩家
|
||||
@@ -95,8 +95,10 @@ export function decodeWarJsonAttribute(attribute) {
|
||||
}
|
||||
|
||||
// 远征累计点数获取
|
||||
export async function getPointRewardStatus(roleId: string) {
|
||||
let role = await RoleModel.findByRoleId(roleId);
|
||||
export async function getPointRewardStatus(roleId: string, role?: Role) {
|
||||
if(!role) {
|
||||
role = await RoleModel.findByRoleId(roleId);
|
||||
}
|
||||
let {expeditionPoint = 0} = role;
|
||||
let dicExpeditionPoint = getGamedata('dic_expedition_point');
|
||||
let pointRewards = {
|
||||
@@ -115,3 +117,22 @@ export async function getPointRewardStatus(roleId: string) {
|
||||
}
|
||||
return pointRewards
|
||||
}
|
||||
|
||||
export async function getResetRemainCnt(curTime: Date, roleId: string, role?: Role, ) {
|
||||
if(!role) {
|
||||
role = await RoleModel.findByRoleId(roleId);
|
||||
}
|
||||
|
||||
let { expeditionResetCnt, expeditionResetRefTime } = role;
|
||||
let needRefresh = !expeditionResetRefTime || shouldRefresh(expeditionResetRefTime, curTime, EXPEDITION_CONST.REFRESH_TIME);
|
||||
if(needRefresh) {
|
||||
expeditionResetCnt = 0; expeditionResetRefTime = curTime;
|
||||
}
|
||||
|
||||
let maxCnt = EXPEDITION_CONST.RESET_CNT;
|
||||
|
||||
return {
|
||||
resetCnt: maxCnt - expeditionResetCnt,
|
||||
needRefresh
|
||||
};
|
||||
}
|
||||
@@ -30,8 +30,8 @@ export async function roleLevelup(roleId: string, kingExp: number) {
|
||||
|
||||
export async function checkBattleHeroes(roleId: string, heroes: Array<number>) {
|
||||
let flag = true;
|
||||
for(let hid of heroes) {
|
||||
let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
||||
for(let seqId of heroes) {
|
||||
let hero = await HeroModel.findBySeqIdAndRole(seqId, roleId);
|
||||
if(!hero) flag = false;
|
||||
}
|
||||
return flag;
|
||||
|
||||
Reference in New Issue
Block a user