红点:修改推送方式

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

@@ -1,14 +1,16 @@
import { HeroModel } from '../db/Hero';
import Role, { RoleModel } from '../db/Role'
import Role, { RoleModel, RoleType } from '../db/Role'
import { getLvByExp, getExpByLv, gameData } from '../pubUtils/data';
import { updateUserInfo } from './redisService';
import { switchOnFunc } from './funcSwitchService';
import { FUNC_OPT_TYPE, TASK_TYPE } from '../consts';
import { FUNC_OPT_TYPE, TASK_TYPE, WAR_TYPE } from '../consts';
import { BackendSession } from 'pinus';
import { REDIS_KEY } from '../consts';
import { Rank } from './rankService';
import { checkActivityTask, checkTask } from './taskService';
import { accomplishTask } from '../pubUtils/taskUtil';
import { RScriptRecordModel } from '../db/RScriptRecord';
export async function roleLevelup(roleId: string, kingExp: number, session: BackendSession) {
const serverId = session.get('serverId');
@@ -103,4 +105,51 @@ export async function updateWarStar(roleId: string, battleId: number, warType: n
result = await RoleModel.pushWarStar(roleId, battleId, warType, star);
}
return result
}
export async function getBattleListOfMain(role: RoleType) {
let types = [ WAR_TYPE.NORMAL, WAR_TYPE.VESTIGE, WAR_TYPE.MAIN_ELITE ];
let result = [];
for(let type of types) {
let list = await getBattleList(role, type);
result.push({ type, list });
}
return result
}
export async function getBattleList(role: RoleType, type: number) {
let { roleId, warStar } = role;
let scripts = await RScriptRecordModel.findbyRole(roleId, type);
let result = []; // 去重
for (let { battleId, scriptBefore = '', scriptAfter = '' } of scripts) {
result.push({
battleId,
status: 0,
star: 0,
scriptBefore,
scriptAfter
});
}
for (let { id, star, warType } of warStar) {
if (warType == type) {
let curResult = result.find(cur => cur.battleId == id);
if (curResult) {
curResult.status = 1;
curResult.star = star;
} else {
result.push({
battleId: id,
status: 1,
star,
scriptBefore: '',
scriptAfter: ''
});
}
}
}
result = result.sort((a, b) => { return a.battleId - b.battleId });
return result;
}