红点:修改推送方式

This commit is contained in:
luying
2021-05-31 13:29:58 +08:00
parent 44d9e80640
commit a8eebc200c
38 changed files with 805 additions and 605 deletions

View File

@@ -3,13 +3,56 @@ import { ExpeditionPointModel } from '../db/ExpeditionPoint';
import Role, { RoleModel, RoleType } from '../db/Role';
import { PvpDefenseModel } from '../db/PvpDefense';
import { shouldRefresh } from '../pubUtils/util';
import { EXPEDITION_CONST } from '../consts';
import { shouldRefresh, calculateSumCE } from '../pubUtils/util';
import { EXPEDITION_CONST, LINEUP_NUM, EXPEDITION_WAR_RECORD_STATUS } from '../consts';
import { ExpeditionWarRecordModel } from '../db/ExpeditionWarRecord';
import { HeroType } from '../db/Hero';
import { gameData } from '../pubUtils/data';
import { getPlayerAttribute, getRobotAttribute } from './pvpService';
import { getTimeFunD } from '../pubUtils/timeUtil';
import { ExpeditionRecordModel } from '../db/ExpeditionRecord';
/**
* 获取远征关卡列表
* @param roleId
* @param roleName
*/
export async function getExpeditionStatus(roleId: string, roleName: string) {
// 获取远征关卡状态
let expeditionRecord = await ExpeditionRecordModel.getCurRecord(roleId);
if (!expeditionRecord) { // 首次新建一条记录
// 我方战力
let myCe = await calculateSumCE(roleId, 1, { num: LINEUP_NUM });
expeditionRecord = await ExpeditionRecordModel.createRecord({
roleId, roleName, heroes: [], myCe
});
await findOrCreateEnemies(roleId, myCe, expeditionRecord.expeditionCode, 1, EXPEDITION_WAR_RECORD_STATUS.WAITING);
}
// 每一关的挑战状态
let { expeditionCode, heroes } = expeditionRecord;
let expeditionWarRecord = await ExpeditionWarRecordModel.getRecordByCode(expeditionCode);
let curLv = 0;
if (expeditionWarRecord.length > 0) {
curLv = expeditionWarRecord[expeditionWarRecord.length - 1].expeditionId;
}
// 重置次数
let role = await RoleModel.findByRoleId(roleId);
let curTime = new Date();
let { resetCnt } = await getResetRemainCnt(curTime, roleId, role);
// 点数,和宝箱领取状态
let pointRewards = await getPointRewardStatus(roleId, role);
return {
expeditionCode,
curLv,
expeditionWarRecord,
pointRewards,
heroes: heroes.map(cur => { return { "dataId": cur.seqId, "hp": cur.hp, "ap": cur.ap } }),
resetCnt
}
}
/**
* 根据存下的战力获取当前远征关卡的对手