任务:埋点30/70

This commit is contained in:
luying
2021-04-18 11:21:04 +08:00
parent bc07e1ea31
commit 9f4f346447
38 changed files with 1088 additions and 692 deletions

View File

@@ -0,0 +1,51 @@
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 { TaskParam } from '../domain/roleField/task';
import { HeroType } from '../db/Hero';
import { EquipType } from '../db/Equip';
import { getRoleOnlineInfo } from './redisService';
export async function checkTaskWithRoles(roleId: string, sid: string, taskType: number, roles: RoleType[]) {
for(let role of roles) {
await checkTaskWithRole(role.roleId, role.roleId == roleId? sid: null, taskType, role);
}
}
export async function checkTaskWithRole(roleId: string, sid: string, taskType: number, role: RoleType) {
let pushMessage = await taskUtil.checkTaskWithRole(roleId, taskType, role);
pushTaskUpdate(roleId, sid, pushMessage);
}
export async function checkTaskWithHero(roleId: string, sid: string, taskType: number, hero: HeroType, args?: number[]) {
let pushMessage = await taskUtil.checkTaskWithHero(roleId, taskType, hero, args);
pushTaskUpdate(roleId, sid, pushMessage);
}
export async function checkTaskWithEquip(roleId: string, sid: string, taskType: number, equip: EquipType, args?: number[]) {
let pushMessage = await taskUtil.checkTaskWithEquip(roleId, taskType, equip, args);
pushTaskUpdate(roleId, sid, pushMessage);
}
export async function checkTaskWithArgs(roleId: string, sid: string, taskType: number, args: number[]) {
let pushMessage = await taskUtil.checkTaskWithArgs(roleId, taskType, args);
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);
}
export async function pushTaskUpdate(roleId: string, sid: string, pushMessage: {type: number, id: number, count: number, received: boolean}[]) {
if(!sid) {
let onlineUser = await getRoleOnlineInfo(roleId);
sid = onlineUser.sid;
}
if(!!sid) {
let uids = [{uid: roleId, sid}];
pinus.app.get('channelService').pushMessageByUids('onTaskUpdate', resResult(STATUS.SUCCESS, pushMessage), uids);
}
}