添加远征每日重置
This commit is contained in:
@@ -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
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user