任务:修复共斗任务达成

This commit is contained in:
luying
2021-04-25 18:10:40 +08:00
parent 5e43bcfe83
commit cbc58f8a7a
7 changed files with 43 additions and 38 deletions

View File

@@ -4,9 +4,9 @@ import { prop } from '@typegoose/typegoose';
import { UserGachaType } from '../../db/UserGacha';
import { getAfterDateByDay } from '../../pubUtils/timeUtil';
import { DicGacha } from '../../pubUtils/dictionary/DicGacha';
import { getFloorStatus } from '../../services/gachaService';
import { GACHA_OCCUPY_HID } from '../../consts';
import { gameData } from '../../pubUtils/data';
import { getFloorStatus } from '../../pubUtils/util';
// 抽卡数据

View File

@@ -310,7 +310,7 @@ export async function checkTask(roleId: string, taskType: number, count: number,
let rec = await checkTaskRec(roleId, type, group, task0, count, isInc, param, funcs);
if (rec) {
for (let dicTask of tasks) {
if (checkRecResult(rec, dicTask.id, dicTask.condition)) {
if (checkRecResult(rec, dicTask.id)) {
let received = rec.received || [];
pushMessage.push({ type: dicTask.type, id: dicTask.id, count: rec.count, received: received.includes(dicTask.id) });
}
@@ -458,7 +458,7 @@ function checkHero(taskParam: number[], index: number, heroes: number[]) {
return heroes.indexOf(hid) != -1;
}
function checkRecResult(rec: UserTaskRecType, id: number, condition: number) {
function checkRecResult(rec: UserTaskRecType, id: number) {
if (!rec) return false;
if (rec.received && rec.received.includes(id)) return false; // 已领取,不再推送

View File

@@ -4,10 +4,11 @@ import { HeroModel, HeroType } from '../db/Hero';
import fs = require('fs');
import path = require('path');
import { HERO_CE_RATIO, ABI_STAGE } from '../consts';
import { HERO_CE_RATIO, ABI_STAGE, GACHA_TO_FLOOR } from '../consts';
import { findIndex } from 'underscore';
import { getWeekDate } from './timeUtil';
import { Floor } from '../domain/activityField/gachaField';
const randomName = require("chinese-random-name");
const moment = require('moment');
const crypto = require('crypto');
@@ -640,4 +641,24 @@ export function splitString(dataString: string, key: string) {
numberArray.push(Number(num));
}
return numberArray;
}
/**
* @description 获取抽卡保底状态
* @param gachaId 招募类型
* @param floor 玩家保底
*/
export function getFloorStatus(gachaId: number, floor: Floor[]) {
let floorMap = new Map<number, number>();
for(let { id, count } of floor) {
floorMap.set(id, count);
}
let dicFloorType = GACHA_TO_FLOOR.get(gachaId);
return dicFloorType.map(id => {
return {
id,
count: floorMap.get(id)||0
}
});
}