任务:埋点48/71

This commit is contained in:
luying
2021-04-19 13:17:17 +08:00
parent 9f4f346447
commit 4bd4513ae6
11 changed files with 186 additions and 37 deletions
+4 -1
View File
@@ -1,7 +1,7 @@
import { HeroModel } from './../db/Hero';
import { HangUpRecordModel } from './../db/HangUpRecord';
import { pinus } from 'pinus';
import { HANG_UP_CONSTS, TOWER_TASK_CONST, REDIS_KEY } from './../consts';
import { HANG_UP_CONSTS, TOWER_TASK_CONST, REDIS_KEY, TASK_TYPE } from './../consts';
import { BattleRecordModel } from './../db/BattleRecord';
import { TowerRecordModel } from './../db/TowerRecord';
import { RoleModel } from './../db/Role';
@@ -12,6 +12,7 @@ import { HangUpSpdUpRecModel } from '../db/HangUpSpdUpRec';
import { TowerTaskRecModel } from '../db/TowerTaskRec';
import { cloneDeep } from 'lodash';
import { Rank } from './rankService';
import { checkTask } from './taskService';
export async function checkTowerWar(roleId: string, battleId: number, heroes: Array<number>) {
const battleIdStr = `${battleId}`;
@@ -91,6 +92,8 @@ export async function towerBattleEnd(sid: string, roleId: string, serverId: numb
await startHangUp(roleId, roleName);
pinus.app.get('channelService').pushMessageByUids('hangUpEnable', resResult(STATUS.SUCCESS, {enable: true}), [{uid: roleId, sid}]);
}
// 任务
await checkTask(roleId, sid, TASK_TYPE.BATTLE_TOWER_LV, role.towerLv, false, {});
}
return {
status: 0,
@@ -56,17 +56,19 @@ export async function roleLevelup(roleId: string, kingExp: number, session: Back
}
export async function checkBattleHeroes(roleId: string, heroes: Array<number>) {
export async function checkBattleHeroes(roleId: string, seqIds: Array<number>) {
let heroes: number[] = [];
let flag = true;
if(heroes.length <= 0) flag = false;
if(seqIds.length <= 0) flag = false;
const findHeroes = await HeroModel.findBySeqIdRange(heroes, roleId);
if(findHeroes.length != heroes.length) flag = false;
for(let seqId of heroes) {
const findHeroes = await HeroModel.findBySeqIdRange(seqIds, roleId);
if(findHeroes.length != seqIds.length) flag = false;
for(let seqId of seqIds) {
let hero = findHeroes.find(cur => cur.seqId == seqId);
if(!hero) flag = false;
heroes.push(hero.hid);
}
return flag;
return { isOK: flag, heroes };
}
export async function checkBattleHeroesByHid(roleId: string, heroes: Array<number>) {
+23 -1
View File
@@ -2,11 +2,12 @@ import * as taskUtil from '../pubUtils/taskUtil';
import { RoleType } from '../db/Role';
import { pinus } from 'pinus';
import { resResult } from '../pubUtils/util';
import { STATUS } from '../consts';
import { STATUS, TASK_TYPE } from '../consts';
import { TaskParam } from '../domain/roleField/task';
import { HeroType } from '../db/Hero';
import { EquipType } from '../db/Equip';
import { getRoleOnlineInfo } from './redisService';
import { TASK } from '../pubUtils/dicParam';
export async function checkTaskWithRoles(roleId: string, sid: string, taskType: number, roles: RoleType[]) {
for(let role of roles) {
@@ -34,6 +35,11 @@ export async function checkTaskWithArgs(roleId: string, sid: string, taskType: n
pushTaskUpdate(roleId, sid, pushMessage);
}
export async function checkTaskWithWar(roleId: string, sid: string, taskType: number, warId: number, heroes: number[], count: number, star: number) {
let pushMessage = await taskUtil.checkTaskWithWar(roleId, taskType, warId, heroes, count, star);
pushTaskUpdate(roleId, sid, pushMessage);
}
export async function checkTask(roleId: string, sid: string, taskType: number, count: number, isInc: boolean, param: TaskParam) {
let pushMessage = await taskUtil.checkTask(roleId, taskType, count, isInc, param);
pushTaskUpdate(roleId, sid, pushMessage);
@@ -48,4 +54,20 @@ export async function pushTaskUpdate(roleId: string, sid: string, pushMessage: {
let uids = [{uid: roleId, sid}];
pinus.app.get('channelService').pushMessageByUids('onTaskUpdate', resResult(STATUS.SUCCESS, pushMessage), uids);
}
}
/**
* battle.normalBattleHandler.battleEnd 中会触发的任务,因为有点多提出来了
*/
export async function checkTaskInBattleEnd(roleId: string, sid: string, battleId: number, heroes: number[], star: number) {
await checkTaskWithWar(roleId, sid, TASK_TYPE.BATTLE_WITH_HERO, battleId, heroes, 1, star);
await checkTaskWithWar(roleId, sid, TASK_TYPE.BATTLE_MAIN, battleId, heroes, 1, star);
await checkTaskWithWar(roleId, sid, TASK_TYPE.BATTLE_DAILY_STAR, battleId, heroes, 1, star);
await checkTaskWithWar(roleId, sid, TASK_TYPE.BATTLE_DAILY, battleId, heroes, 1, star);
await checkTaskWithWar(roleId, sid, TASK_TYPE.BATTLE_DUNGEON, battleId, heroes, 1, star);
await checkTaskWithWar(roleId, sid, TASK_TYPE.BATTLE_DUNGEON_WAR, battleId, heroes, 1, star);
await checkTaskWithWar(roleId, sid, TASK_TYPE.BATTLE_TOWER, battleId, heroes, 1, star);
await checkTaskWithWar(roleId, sid, TASK_TYPE.BATTLE_VESTIGE, battleId, heroes, 1, star);
}