任务:埋点48/71

This commit is contained in:
luying
2021-04-18 15:09:56 +08:00
parent 9f4f346447
commit 4bd4513ae6
11 changed files with 186 additions and 37 deletions

View File

@@ -1,6 +1,6 @@
import { gameData } from './data';
import { DicTask } from './dictionary/DicTask';
import { TASK_TYPE, ABI_STAGE } from '../consts';
import { TASK_TYPE, ABI_STAGE, WAR_TYPE } from '../consts';
import { UserTaskRecModel, UserTaskRecType } from '../db/UserTaskRec'
import { RoleType } from '../db/Role';
import { TaskParam } from '../domain/roleField/task';
@@ -32,7 +32,7 @@ export async function checkTaskWithRole(roleId: string, taskType: number, role:
let today = getTodayZeroPoint();
if(today > role.loginTime) {
if(today - role.loginTime > 24 * 60 * 60 ) {
pushMessage = await checkTask(roleId, taskType, 1, false, {});
pushMessage = await checkTask(roleId, taskType, 0, false, {});
} else {
pushMessage = await checkTask(roleId, taskType, 1, true, {});
}
@@ -226,6 +226,63 @@ export async function checkTaskWithArgs(roleId: string, taskType: number, args:
return pushMessage
}
export async function checkTaskWithWar(roleId: string, taskType: number, warId: number, heroes: number[], count: number, star: number) {
let dicWar = gameData.war.get(warId);
let pushMessage = new Array<{type: number, id: number, count: number, received: boolean}>();
if(taskType == TASK_TYPE.BATTLE_WITH_HERO)
{
pushMessage = await checkTask(roleId, taskType, count, true, { warId, heroes });
}
else if (taskType == TASK_TYPE.BATTLE_MAIN)
{
if(dicWar.warType == WAR_TYPE.NORMAL) {
pushMessage = await checkTask(roleId, taskType, count, true, { warId });
}
}
else if (taskType == TASK_TYPE.BATTLE_MAIN_SWEEP)
{
if(dicWar.warType == WAR_TYPE.NORMAL) {
pushMessage = await checkTask(roleId, taskType, count, true, {});
}
}
else if (taskType == TASK_TYPE.BATTLE_DAILY_STAR)
{
if(dicWar.warType == WAR_TYPE.DAILY) {
pushMessage = await checkTask(roleId, taskType, count, true, { warId, star });
}
}
else if (taskType == TASK_TYPE.BATTLE_DAILY)
{
if(dicWar.warType == WAR_TYPE.DAILY) {
pushMessage = await checkTask(roleId, taskType, count, true, { dailyType: dicWar.dailyType })
}
}
else if (taskType == TASK_TYPE.BATTLE_DUNGEON)
{
if(dicWar.warType == WAR_TYPE.MYSTERY||dicWar.warType == WAR_TYPE.MYSTERY_ELITE) {
pushMessage = await checkTask(roleId, taskType, count, true, {});
}
}
else if (taskType == TASK_TYPE.BATTLE_DUNGEON_WAR)
{
if(dicWar.warType == WAR_TYPE.MYSTERY||dicWar.warType == WAR_TYPE.MYSTERY_ELITE) {
pushMessage = await checkTask(roleId, taskType, count, true, { warId });
}
}
else if (taskType == TASK_TYPE.BATTLE_TOWER)
{
if(dicWar.warType == WAR_TYPE.TOWER) {
pushMessage = await checkTask(roleId, taskType, count, true, {});
}
}
else if (taskType == TASK_TYPE.BATTLE_VESTIGE) {
if(dicWar.warType == WAR_TYPE.VESTIGE) {
pushMessage = await checkTask(roleId, taskType, count, true, {});
}
}
return pushMessage
}
// 根据taskType判断有哪些任务需要check的
export async function checkTask(roleId: string, taskType: number, count: number, isInc: boolean, param: TaskParam) {
let tasks = gameData.taskType.get(taskType);
@@ -279,6 +336,11 @@ export async function checkTaskRec(roleId: string, group: number, dicTask: DicTa
case TASK_TYPE.EQUIP_JEWEL_SUM:
case TASK_TYPE.FRIEND_NUM:
case TASK_TYPE.FRIEND_SEND_HEART:
case TASK_TYPE.BATTLE_MAIN_SWEEP:
case TASK_TYPE.BATTLE_DUNGEON:
case TASK_TYPE.BATTLE_TOWER_LV:
case TASK_TYPE.BATTLE_TOWER:
case TASK_TYPE.BATTLE_VESTIGE:
isMatch = true;
break;
case TASK_TYPE.HERO_STAR_UP:
@@ -317,9 +379,24 @@ export async function checkTaskRec(roleId: string, group: number, dicTask: DicTa
isMatch = param.stage == taskParam[1];
break;
case TASK_TYPE.CHAT:
isMatch = param.chatType == 0 || param.chatType == taskParam[0];
isMatch = taskParam[0] == 0 || param.chatType == taskParam[0];
break;
case TASK_TYPE.BATTLE_WITH_HERO:
isMatch = checkWarId(taskParam, 2, param.warId) && checkHero(taskParam, 0, param.heroes);
break;
case TASK_TYPE.BATTLE_MAIN:
case TASK_TYPE.BATTLE_DUNGEON_WAR:
isMatch = checkWarId(taskParam, 0, param.warId);
break;
case TASK_TYPE.BATTLE_EVENT:
isMatch = taskParam[0] == 0 || param.eventType == taskParam[0];
break;
case TASK_TYPE.BATTLE_DAILY_STAR:
isMatch = (taskParam[0] == 0 || param.star == taskParam[0]) && checkWarId(taskParam, 2, param.warId);
break;
case TASK_TYPE.BATTLE_DAILY:
isMatch = taskParam[0] == 0 || param.dailyType == taskParam[0];
break;
}
console.log('****isMatch', isMatch, type, taskType, group, count)
@@ -334,6 +411,24 @@ export async function checkTaskRec(roleId: string, group: number, dicTask: DicTa
}
}
/**
* 检查关卡id是否在条件中
* @param taskParam 条件number[] 填法 warcount&warid&... 有多少warid就warcount填几
* @param index warcount在第几位0开始
* @param warId 关卡id
*/
function checkWarId(taskParam: number[], index: number, warId: number) {
let warCount = taskParam[index];
if(!warCount) return false;
let warIdList = taskParam.slice(index + 1, index + 1 + warCount);
return warIdList.indexOf(warId) != -1;
}
function checkHero(taskParam: number[], index: number, heroes: number[]) {
let hid = taskParam[index];
return heroes.indexOf(hid) != -1;
}
function checkRecResult(rec: UserTaskRecType, condition: number) {
if(!rec) return false;
if(rec.received) return false;