任务:埋点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

@@ -18,7 +18,7 @@ import { dicTowerTask } from "./dictionary/DicTowerTask";
import { dicWar, dicWarPvp } from "./dictionary/DicWar";
import { dicWarJson } from "./dictionary/DicWarJson";
import { dicXunbao } from "./dictionary/DicXunbao";
import { SPECIAL_ATTR } from "../consts/consts";
import { SPECIAL_ATTR } from "../consts";
import { dicFashions } from "./dictionary/DicFashions";
import { friendShips, friendShipHidAandIds } from "./dictionary/DicFriendShip";
import { maxFriendShipLv, dicFriendShipLevelMap } from "./dictionary/DicFriendShipLevel";
@@ -73,6 +73,7 @@ import { dicShop, dicShopItem } from "./dictionary/DicShop";
import { dicShopList } from "./dictionary/DicShopList";
import { dicRank } from "./dictionary/DicRank";
import { dicRankReward } from "./dictionary/DicRankReward";
import { dicTaskType, dicMainTask, dicDailyTask, dicAchievement } from "./dictionary/DicTask";
export const gameData = {
blurprtCompose: dicBlueprtCompose,
@@ -171,7 +172,11 @@ export const gameData = {
shopList: dicShopList,
dicMyHeroes: dicMyHeroes,
rank: dicRank,
generalRankReward: dicRankReward
generalRankReward: dicRankReward,
taskType: dicTaskType,
mainTask: dicMainTask,
dailyTask: dicDailyTask,
achievement: dicAchievement
};
// 在此提供一些原先在gamedata中提供的方法以便更方便获取gameData数据

View File

@@ -1,5 +1,5 @@
// 镇念塔表
import { decodeArrayListStr, readJsonFile } from '../util'
import { decodeArrayListStr, readJsonFile, parseNumberList } from '../util'
import { FILENAME } from '../../consts';
export interface DicSuit {
@@ -11,7 +11,7 @@ export interface DicSuit {
readonly totalCount: number;
// 套装效果
readonly effect: Array<{ count: number, seid: number }>;
readonly tireInfo: Map<number,number>;
readonly tireInfo: Array<number>;
}
const str = readJsonFile(FILENAME.DIC_SUIT);
@@ -21,7 +21,7 @@ export const dicSuit = new Map<number, DicSuit>();
arr.forEach(o => {
o.effect = parseSuitEffect(o.effect);
o.tireInfo = parseTireInfo(o.tireInfo);
o.tireInfo = parseNumberList(o.tireInfo);
dicSuit.set(o.id, o);
});
arr = undefined;
@@ -37,13 +37,4 @@ function parseSuitEffect(str: string) {
result.push({ count: parseInt(count), seid: parseFloat(seid) });
}
return result
}
function parseTireInfo(str: string) {
let result = new Map<number,number>();
let arrs = str.split('&');
for (let arr of arrs) {
result.set(parseInt(arr), 1);
}
return result;
}

View File

@@ -0,0 +1,132 @@
// 任务
import { RewardInter } from '../interface';
import { readJsonFile, parseNumberList, parseGoodStr } from '../util';
import { FILENAME, TASK_FUN_TYPE} from '../../consts';
const _ = require('lodash');
type KeysEnum<T> = { [P in keyof Required<T>]: true };
interface DicTaskBase {
// id
readonly id: number;
// 任务类型
readonly taskType: number;
// 类型下面的分组
readonly group: number;
// 任务参数
readonly taskParam: number[];
// 条件
readonly condition: number;
}
const DicTaskKeys: KeysEnum<DicTaskBase> = {
id: true,
taskType: true,
group: true,
taskParam: true,
condition: true
};
// 主线任务
export interface DicMainTask extends DicTaskBase {
// 奖励
readonly taskReward: RewardInter[];
// 任务阶段
readonly taskStage: number;
}
const DicMainTaskKeys: KeysEnum<DicMainTask> = {
id: true,
taskType: true,
group: true,
taskParam: true,
condition: true,
taskStage: true,
taskReward: true
};
// 每日任务
export interface DicDailyTask extends DicTaskBase {
// 奖励
readonly taskReward: RewardInter[];
// 活跃
readonly point: number;
// 经验基数
readonly exp: number;
}
const DicDailyTaskKeys: KeysEnum<DicDailyTask> = {
id: true,
taskType: true,
group: true,
taskParam: true,
condition: true,
taskReward: true,
point: true,
exp: true
};
// 成就
export interface DicAchievement extends DicTaskBase {
// 奖励
readonly taskReward: RewardInter[];
// 活跃
readonly point: number;
}
const DicAchievementKeys: KeysEnum<DicAchievement> = {
id: true,
taskType: true,
group: true,
taskParam: true,
condition: true,
taskReward: true,
point: true
};
export type DicTask = DicTaskBase & { type: number };
export const dicMainTask = new Map<number, DicMainTask>(); // 主线任务
export const dicDailyTask = new Map<number, DicDailyTask>(); // 每日任务
export const dicAchievement = new Map<number, DicAchievement>(); // 成就
export const dicTaskType = new Map<number, DicTask[]>();
const mainTask = readJsonFile(FILENAME.DIC_MAIN_TASK);
let arrMainTask = JSON.parse(mainTask);
arrMainTask.forEach(o => {
o.taskParam = parseNumberList(o.taskParam);
o.taskReward = parseGoodStr(o.taskReward);
dicMainTask.set(o.id, _.pick(o, Object.keys(DicMainTaskKeys)));
pushDicTaskType(o.taskType, TASK_FUN_TYPE.MAIN, o);
});
arrMainTask = undefined;
const dailyTask = readJsonFile(FILENAME.DIC_DAILY_TASK);
let arrDailyTask = JSON.parse(dailyTask);
arrDailyTask.forEach(o => {
o.taskParam = parseNumberList(o.taskParam);
o.taskReward = parseGoodStr(o.taskReward);
dicDailyTask.set(o.id, _.pick(o, Object.keys(DicDailyTaskKeys)));
pushDicTaskType(o.taskType, TASK_FUN_TYPE.DAILY, o);
});
arrDailyTask = undefined;
const achievement = readJsonFile(FILENAME.DIC_ACHIEVEMENT);
let arrAchievement = JSON.parse(achievement);
arrAchievement.forEach(o => {
o.taskParam = parseNumberList(o.taskParam);
o.taskReward = parseGoodStr(o.taskReward);
dicAchievement.set(o.id, _.pick(o, Object.keys(DicAchievementKeys)));
pushDicTaskType(o.taskType, TASK_FUN_TYPE.ACHIEVEMENT, o);
});
arrAchievement = undefined;
function pushDicTaskType(taskType: number, type: number, o: any) {
if(!dicTaskType.has(taskType)) {
dicTaskType.set(taskType, new Array<DicTask>());
}
let newObj = _.pick(o, Object.keys(DicTaskKeys));
newObj.type = type;
dicTaskType.get(taskType).push(newObj)
}

View File

@@ -5,7 +5,7 @@ import { ItemModel } from '../db/Item';
import { EquipModel, RandSe, Holes } from './../db/Equip';
import { BagInter, EquipInter } from './interface';
import { gameData } from './data';
import { RANDOM_SE_COUNT, FIX_ATTRIBUTES_RAN, ITID, CURRENCY_BY_TYPE, CURRENCY_TYPE, ROLE_SELECT, FIGURE_UNLOCK_CONDITION, CONSUME_TYPE, HERO_SYSTEM_TYPE } from '../consts';
import { RANDOM_SE_COUNT, FIX_ATTRIBUTES_RAN, ITID, CURRENCY_BY_TYPE, CURRENCY_TYPE, ROLE_SELECT, FIGURE_UNLOCK_CONDITION, CONSUME_TYPE, HERO_SYSTEM_TYPE, TASK_TYPE } from '../consts';
import { getRandValueByMinMax, getRandEelm } from './util';
import { findWhere } from 'underscore';
@@ -13,6 +13,7 @@ import { RoleModel, RoleType } from '../db/Role';
import { Figure } from '../domain/dbGeneral';
import { getBeforeDaySeconds, nowSeconds } from './timeUtil';
import { calPlayerCeAndSave, reCalAllHeroCe } from './playerCe';
import { checkTask, checkTaskWithHeroes, checkTaskWithEquip } from './taskUtil';
export async function addSkins(roleId: string, id: number) {
let skinInfo = gameData.fashion.get(id);
@@ -61,7 +62,11 @@ export async function addEquips(roleId: string, roleName: string, weapon: EquipI
}
const equip = await EquipModel.createEquip({roleId, roleName, id, name, quality, suitId, randRange, ePlaceId: type, randSe, holes, hid});
return equip
// 任务
let pushMessage = await checkTaskWithEquip(roleId, TASK_TYPE.EQUIP_SUIT, equip);
return { equipInfo: equip, pushMessage }
}
/**
@@ -217,8 +222,8 @@ function unlockSingleFigure(dbFigures: Figure[], id: number, unlockDirect = fals
}
export async function createHero(roleId: string, heroInfo: HeroUpdate) {
let { role, figureInfo, heroes, calHeroResults, calAllHeroResults } = await createHeroes(roleId, [heroInfo])
return { hero: heroes[0], role, figureInfo, calHeroResult: calHeroResults[0], calAllHeroResult: calAllHeroResults[0] }
let { role, figureInfo, heroes, calHeroResults, calAllHeroResults, taskPushMessage } = await createHeroes(roleId, [heroInfo])
return { hero: heroes[0], role, figureInfo, calHeroResult: calHeroResults[0], calAllHeroResult: calAllHeroResults[0], taskPushMessage }
}
export async function createHeroes(roleId: string, heroInfos: HeroUpdate[]) {
@@ -226,7 +231,7 @@ export async function createHeroes(roleId: string, heroInfos: HeroUpdate[]) {
let heroNum = 0;
let skinIds = new Array<number>();
let conditions = new Array<{type: number, paramHid?: number, paramFavourLv?: number, paramSkinId?: number }>();
let heroes = [], calHeroResults = [], calAllHeroResults = [];
let heroes = [], calHeroResults = [], calAllHeroResults = [];
for(let heroInfo of heroInfos) {
let curHero = await HeroModel.createHero(heroInfo); heroes.push(curHero);
@@ -243,5 +248,11 @@ export async function createHeroes(roleId: string, heroInfos: HeroUpdate[]) {
let figureInfo = await unlockFigure(roleId, conditions); // 解锁头像
let role = await RoleModel.incRoleInfo(roleId, { heroNum }, { heroNumUpdatedAt: nowSeconds() });
return { role, figureInfo, heroes, calHeroResults, calAllHeroResults }
// 任务
let m1 = await checkTask(roleId, TASK_TYPE.HERO_NUM, heroNum, true, {});
let m2 = await checkTaskWithHeroes(roleId, TASK_TYPE.HERO_QUALITY, heroes);
let m3 = await checkTaskWithHeroes(roleId, TASK_TYPE.HERO_QUALITY_STAR_UP, heroes);
let m4 = await checkTaskWithHeroes(roleId, TASK_TYPE.HERO_LV, heroes);
let taskPushMessage = m1.concat(m2, m3, m4);
return { role, figureInfo, heroes, calHeroResults, calAllHeroResults, taskPushMessage }
}

346
shared/pubUtils/taskUtil.ts Normal file
View File

@@ -0,0 +1,346 @@
import { gameData } from './data';
import { DicTask } from './dictionary/DicTask';
import { TASK_TYPE, ABI_STAGE } from '../consts';
import { UserTaskRecModel, UserTaskRecType } from '../db/UserTaskRec'
import { RoleType } from '../db/Role';
import { TaskParam } from '../domain/roleField/task';
import { getTodayZeroPoint } from './timeUtil';
import { HeroType } from '../db/Hero';
import { EquipType, EquipModel } from '../db/Equip';
export async function checkTaskWithRoles(taskType: number, roles: RoleType[]) {
let pushMessage = new Array<{type: number, id: number, count: number, received: boolean}>();
for(let role of roles) {
let singlePush = await checkTaskWithRole(role.roleId, taskType, role);
pushMessage.concat(singlePush);
}
return pushMessage
}
export async function checkTaskWithRole(roleId: string, taskType: number, role: RoleType) {
let pushMessage = new Array<{type: number, id: number, count: number, received: boolean}>();
if(taskType == TASK_TYPE.LOGIN_SUM)
{
let today = getTodayZeroPoint();
if(today > role.loginTime) {
pushMessage = await checkTask(roleId, taskType, 1, true, {});
}
}
else if (taskType == TASK_TYPE.LOGIN_SERIES)
{
let today = getTodayZeroPoint();
if(today > role.loginTime) {
if(today - role.loginTime > 24 * 60 * 60 ) {
pushMessage = await checkTask(roleId, taskType, 1, false, {});
} else {
pushMessage = await checkTask(roleId, taskType, 1, true, {});
}
}
}
else if (taskType == TASK_TYPE.FRIEND_NUM)
{
let { friendCnt } = role;
pushMessage = await checkTask(roleId, taskType, friendCnt, false, {});
}
return pushMessage
}
export async function checkTaskWithHeroes(roleId: string, taskType: number, heroes: HeroType[]) {
let pushMessage = new Array<{type: number, id: number, count: number, received: boolean}>();
for(let hero of heroes) {
let singlePush = await checkTaskWithHero(roleId, taskType, hero);
pushMessage.concat(singlePush);
}
return pushMessage
}
export async function checkTaskWithHero(roleId: string, taskType: number, hero: HeroType, args?: number[]) {
let pushMessage = new Array<{type: number, id: number, count: number, received: boolean}>();
if(taskType == TASK_TYPE.HERO_STAR_UP)
{
let dicHero = gameData.hero.get(hero.hid);
let starUp = hero.star - dicHero.initialStars;
if(hero.colorStar > 1) starUp += hero.colorStar - 1;
pushMessage = await checkTask(roleId, taskType, 1, true, { star: starUp })
}
else if(taskType == TASK_TYPE.HERO_QUALITY)
{
let dicHero = gameData.hero.get(hero.hid);
pushMessage = await checkTask(roleId, taskType, 1, true, { quality: dicHero.quality });
}
else if (taskType == TASK_TYPE.HERO_QUALITY_STAR_UP)
{
let dicHero = gameData.hero.get(hero.hid);
pushMessage = await checkTask(roleId, taskType, 1, true, { quality: dicHero.quality, star: hero.star });
}
else if (taskType == TASK_TYPE.HERO_LV)
{
pushMessage = await checkTask(roleId, taskType, 1, true, { lv: hero.lv });
}
else if (taskType == TASK_TYPE.HERO_TRAIN)
{
let dicHero = gameData.hero.get(hero.hid);
let initGrage = gameData.job.get(dicHero.jobid).grade;
let curGrade = gameData.job.get(hero.job).grade;
let count = (curGrade - initGrage) * (ABI_STAGE.END - ABI_STAGE.START) + (hero.jobStage - ABI_STAGE.START); // 训练次数
pushMessage = await checkTask(roleId, taskType, 1, true, { count });
}
else if (taskType == TASK_TYPE.HERO_QUALITY_UP)
{
let dicHero = gameData.hero.get(hero.hid);
if(hero.quality - dicHero.quality == 1) { // 每个武将升品算一次
pushMessage = await checkTask(roleId, taskType, 1, true, {});
}
}
else if (taskType == TASK_TYPE.HERO_STAGE_UP)
{
let dicHero = gameData.hero.get(hero.hid);
let initGrage = gameData.job.get(dicHero.jobid).grade;
let curGrade = gameData.job.get(hero.job).grade;
let count = curGrade - initGrage; // 进阶次数
pushMessage = await checkTask(roleId, taskType, 1, true, { count });
}
else if (taskType == TASK_TYPE.HERO_FAVOUR_LV)
{
pushMessage = await checkTask(roleId, taskType, 1, true, { favourLv: hero.favourLv })
}
else if (taskType == TASK_TYPE.EQUIP_BY_HERO)
{
// arg[0] 1穿上 -1脱下
let { ePlace } = hero;
let count = ePlace.filter(cur => cur.equip).length;
pushMessage = await checkTask(roleId, taskType, args[0], true, { count, isPutOn: args[0] });
}
else if (taskType == TASK_TYPE.EQUIP_STRENGTHEN)
{
// args: 依次为原先的装备的强化等级
let { ePlace } = hero;
let index = 0;
for(let { lv } of ePlace) {
let p = await checkTask(roleId, taskType, 1, true, { oldLv: args[index++], lv });
pushMessage = pushMessage.concat(p);
}
}
return pushMessage
}
export async function checkTaskWithEquip(roleId: string, taskType: number, equip: EquipType, args?: number[]) {
let pushMessage = new Array<{type: number, id: number, count: number, received: boolean}>();
if(taskType == TASK_TYPE.EQUIP_QUALITY)
{
// args[0] 1装上 -1脱下
let dicGood = gameData.goods.get(equip.id);
pushMessage = await checkTask(roleId, taskType, args[0], true, { quality: dicGood.quality })
}
else if (taskType == TASK_TYPE.EQUIP_JEWEL)
{
// args[0] 原来镶嵌了多少宝石
let { holes } = equip;
let jewelCount = holes.filter(cur => cur.jewel > 0).length;
if(jewelCount > 0 && args[0] <= 0) { // 原来没有,镶嵌上了
pushMessage = await checkTask(roleId, taskType, 1, true, {});
} else if (jewelCount <= 0 && args[0] > 0) { // 原来镶嵌着,现在没了
pushMessage = await checkTask(roleId, taskType, -1, true, {});
}
}
else if (taskType == TASK_TYPE.EQUIP_COMPOSE_SUIT)
{
let dicGood = gameData.goods.get(equip.id);
if(dicGood.suitId) {
pushMessage = await checkTask(roleId, taskType, 1, true, {});
}
}
else if (taskType == TASK_TYPE.EQUIP_SUIT)
{
let dicGood = gameData.goods.get(equip.id);
if(dicGood.suitId) {
let suit = gameData.suit.get(dicGood.suitId);
let equips = await EquipModel.getEquipsByIds(roleId, suit.tireInfo);
let everyEquip = new Map<number, number>();
for(let equip of equips) {
if(everyEquip.has(equip.id)) {
everyEquip.set(equip.id, everyEquip.get(equip.id) + 1);
} else {
everyEquip.set(equip.id, 1);
}
}
let minCount = 0, curCount = 0;
for(let id of suit.tireInfo) {
let count = everyEquip.get(id)||0;
if(minCount > count) minCount = count;
if(id == equip.id) curCount = count;
}
if(curCount == minCount) {
pushMessage = await checkTask(roleId, taskType, 1, true, {});
}
}
}
else if (taskType == TASK_TYPE.EQUIP_JEWEL_SUM)
{
// args[0] 原来镶嵌了多少宝石
let { holes } = equip;
let jewelCount = holes.filter(cur => cur.jewel > 0).length;
pushMessage = await checkTask(roleId, taskType, jewelCount - args[0], true, {});
}
return pushMessage
}
export async function checkTaskWithArgs(roleId: string, taskType: number, args: number[]) {
let pushMessage = new Array<{type: number, id: number, count: number, received: boolean}>();
if(taskType == TASK_TYPE.ROLE_SCHOOL_PUT_HERO)
{
let [ hid, preHid ] = args;
if(hid > 0 && preHid <= 0) { // 放置
pushMessage = await checkTask(roleId, taskType, 1, true, {});
} else if (hid <= 0 && preHid > 0) { // 卸下
pushMessage = await checkTask(roleId, taskType, -1, true, {});
}
}
else if (taskType == TASK_TYPE.EQUIP_JEWEL_STAGE)
{
// args 装上的, 卸下的
let [putOnJewel, putOffJewel] = args;
if(putOnJewel > 0) {
let dicGood = gameData.goods.get(putOnJewel);
let push = await checkTask(roleId, taskType, 1, true, { stage: dicGood.lvLimited });
pushMessage.concat(push);
}
if(putOffJewel > 0) {
let dicGood = gameData.goods.get(putOffJewel);
let push = await checkTask(roleId, taskType, -1, true, { stage: dicGood.lvLimited });
pushMessage.concat(push);
}
}
else if (taskType == TASK_TYPE.CHAT)
{
// args[0] 聊天type 1-系统 2-世界 3-军团 4-组队 5-私聊
pushMessage = await checkTask(roleId, taskType, 1, true, { chatType: args[0] })
}
return pushMessage
}
// 根据taskType判断有哪些任务需要check的
export async function checkTask(roleId: string, taskType: number, count: number, isInc: boolean, param: TaskParam) {
let tasks = gameData.taskType.get(taskType);
let pushMessage = new Array<{type: number, id: number, count: number, received: boolean}>();
let groups = new Map<number, { task0: DicTask, tasks: DicTask[] }>();
for(let dicTask of tasks) {
if(!groups.has(dicTask.group)) {
groups.set(dicTask.group, { task0: dicTask, tasks: new Array<DicTask>() });
}
groups.get(dicTask.group).tasks.push(dicTask);
}
for(let [ group, { task0, tasks } ] of groups) {
let rec = await checkTaskRec(roleId, group, task0, count, isInc, param);
if(rec) {
for(let dicTask of tasks) {
if(checkRecResult(rec, dicTask.condition)) {
pushMessage.push({ type: dicTask.type, id: dicTask.id, count: rec.count, received: rec.received });
}
}
}
}
return pushMessage;
}
// 检查各项任务是否达成,达成了就保存到数据库
export async function checkTaskRec(roleId: string, group: number, dicTask: DicTask, count: number, isInc: boolean, param: TaskParam ) {
let { type, taskParam, taskType } = dicTask;
let isMatch = false; // 条件是否满足
switch(taskType) {
case TASK_TYPE.LOGIN_SUM:
case TASK_TYPE.LOGIN_SERIES:
case TASK_TYPE.ROLE_LV:
case TASK_TYPE.GASHA:
case TASK_TYPE.HERO_NUM:
case TASK_TYPE.HERO_QUALITY_UP:
case TASK_TYPE.HERO_WAKE_UP:
case TASK_TYPE.HERO_TRAIN_SUM:
case TASK_TYPE.HERO_STAGE_UP:
case TASK_TYPE.ROLE_SCHOOL_UNLOCK:
case TASK_TYPE.ROLE_SCHOOL_PUT_HERO:
case TASK_TYPE.ROLE_TITLE:
case TASK_TYPE.ROLE_TERAPH_STRENGTHEN:
case TASK_TYPE.ROLE_SCROLL_ACTIVE:
case TASK_TYPE.EQUIP_SUM:
case TASK_TYPE.EQUIP_JEWEL:
case TASK_TYPE.EQUIP_COMPOSE_SUIT:
case TASK_TYPE.EQUIP_SUIT:
case TASK_TYPE.EQUIP_RESTRENGTHEN:
case TASK_TYPE.EQUIP_REFINE:
case TASK_TYPE.EQUIP_JEWEL_SUM:
case TASK_TYPE.FRIEND_NUM:
case TASK_TYPE.FRIEND_SEND_HEART:
isMatch = true;
break;
case TASK_TYPE.HERO_STAR_UP:
isMatch = taskParam[1] == param.star;
break;
case TASK_TYPE.HERO_QUALITY:
case TASK_TYPE.EQUIP_QUALITY:
isMatch = taskParam[1] == param.quality;
break;
case TASK_TYPE.HERO_QUALITY_STAR_UP:
isMatch = taskParam[1] == param.quality && taskParam[2] == param.star;
break;
case TASK_TYPE.HERO_LV:
isMatch = taskParam[1] == param.lv;
break;
case TASK_TYPE.HERO_TRAIN:
isMatch = taskParam[1] == param.count;
break;
case TASK_TYPE.HERO_FAVOUR_LV:
isMatch = taskParam[1] == param.favourLv;
break;
case TASK_TYPE.HERO_CONNECT:
isMatch = taskParam[1] == param.connectLv;
break;
case TASK_TYPE.EQUIP_BY_HERO:
if(param.isPutOn && param.count == taskParam[1]) { // 装上之后达到 +1
isMatch = true;
} else if (!param.isPutOn && param.count < taskParam[1]) { // 脱下后不能达到 -1
isMatch = true;
}
break;
case TASK_TYPE.EQUIP_STRENGTHEN:
isMatch = param.oldLv < taskParam[1] && param.lv >= taskParam[1];
break;
case TASK_TYPE.EQUIP_JEWEL_STAGE:
isMatch = param.stage == taskParam[1];
break;
case TASK_TYPE.CHAT:
isMatch = param.chatType == 0 || param.chatType == taskParam[0];
break;
}
console.log('****isMatch', isMatch, type, taskType, group, count)
if(isMatch) {
if(isInc) {
let rec = await UserTaskRecModel.incTaskRec(roleId, type, taskType, group, count);
return rec;
} else {
let rec = await UserTaskRecModel.setTaskRec(roleId, type, taskType, group, count);
return rec;
}
}
}
function checkRecResult(rec: UserTaskRecType, condition: number) {
if(!rec) return false;
if(rec.received) return false;
if(rec.count >= condition) {
return rec
} else {
return false
}
}

View File

@@ -1,4 +1,4 @@
import { TIME_FORMAT } from '../consts';
import { TIME_FORMAT, REFRESH_TIME } from '../consts';
const PER_SECOND = 1 * 1000;
const PER_DAY = 24 * 60 * 60;
@@ -13,7 +13,7 @@ export function nowSeconds() {
return Math.floor(Date.now() / PER_SECOND );
}
export function getTodayZeroPoint(hour = 0) {
export function getTodayZeroPoint(hour = REFRESH_TIME) {
var date = new Date();
date.setHours(hour);
date.setMinutes(0);