活动:修复七天乐任务
This commit is contained in:
@@ -76,3 +76,47 @@ export abstract class ActivityBase {
|
||||
'今天第几天:', this.todayIndex, '回合:', this.roundIndex, '下次刷新:', this.nextRefreshTime, moment(this.nextRefreshTime).toDate())
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 存在内存内的活动
|
||||
*/
|
||||
export class ActivityInRemote {
|
||||
groupId: number; // 组Id
|
||||
activityId: number; // 活动Id
|
||||
beginTime: number; // 开启时间 timeType=3
|
||||
endTime: number; // 结束时间 timeType=3
|
||||
type: number; // 活动类型
|
||||
data: string; // 活动表中的数据
|
||||
|
||||
timeType: number; // 活动时间类型 ACTIVITY_TIME_TYPE 1.服务器开启时间 2.角色创建时间 3.指定开启时间(beginTime,endTime)
|
||||
days: number; // 活动持续天数 timeType=1、2
|
||||
delayDay: number; // 迟几天开启活动,0表示按照规定时间开启
|
||||
interval: number; // 周期性活动时间间隔,秒
|
||||
|
||||
constructor(activity?: ActivityModelType) {
|
||||
this.groupId = activity.groupId;
|
||||
this.activityId = activity.activityId;
|
||||
this.beginTime = activity.beginTime.getTime();
|
||||
this.endTime = activity.endTime.getTime();
|
||||
this.type = activity.type;
|
||||
this.data = activity.data;
|
||||
this.timeType = activity.timeType;
|
||||
this.days = activity.days;
|
||||
this.delayDay = activity.delayDay;
|
||||
this.interval = activity.interval;
|
||||
}
|
||||
}
|
||||
|
||||
export function transActivityInRemoteToModelType(activity: ActivityInRemote) {
|
||||
if(!activity) return null;
|
||||
return {
|
||||
...activity,
|
||||
beginTime: new Date(activity.beginTime),
|
||||
endTime: new Date(activity.endTime),
|
||||
_id: '',
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
createdBy: 0,
|
||||
updatedBy: 0
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,6 +100,7 @@ import { WishPoolReportModel } from '../db/WishPoolReport';
|
||||
import { pick } from "underscore";
|
||||
import { HeroShowParam } from '../domain/roleField/hero';
|
||||
import { saveCeChangeLog } from "./logUtil";
|
||||
import { ActivityInRemote } from "../domain/activityField/activityField";
|
||||
|
||||
// 储存在内存中的初始数据
|
||||
export function getInitRoleInfo() {
|
||||
@@ -318,7 +319,7 @@ export class CreateHeroes extends UpdateHeroes {
|
||||
this.resultHeroes = await HeroModel.insertHeroes(this.roleId, this.roleName, this.serverId, heroeInfos);
|
||||
}
|
||||
|
||||
public async clearTask(activitiesTypeMap: ActivityModelType[]) {
|
||||
public async clearTask(activitiesTypeMap: ActivityInRemote[]) {
|
||||
// 任务
|
||||
console.log('****** checkTask before', Date.now())
|
||||
let m1 = await checkTask(this.roleId, TASK_TYPE.HERO_NUM, this.heroNum, true, {});
|
||||
@@ -329,8 +330,8 @@ export class CreateHeroes extends UpdateHeroes {
|
||||
console.log('****** checkTask after', Date.now())
|
||||
//成长任务
|
||||
console.log('****** accomplishTask before', Date.now())
|
||||
let mm1 = await accomplishTask(this.serverId, this.roleId, TASK_TYPE.HERO_NUM, this.heroNum, null, activitiesTypeMap)
|
||||
let mm2 = await accomplishTask(this.serverId, this.roleId, TASK_TYPE.HERO_QUALITY, this.heroNum, { heroes: this.resultHeroes }, activitiesTypeMap)
|
||||
let mm1 = await accomplishTask(this.serverId, this.roleId, TASK_TYPE.HERO_NUM, this.heroNum, null, activitiesTypeMap)
|
||||
let mm2 = await accomplishTask(this.serverId, this.roleId, TASK_TYPE.HERO_QUALITY, this.heroNum, { heroes: this.resultHeroes }, activitiesTypeMap);
|
||||
console.log('****** accomplishTask after', Date.now())
|
||||
this.activityTaskPushMessage.push(...mm1, ...mm2);
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import moment = require("moment");
|
||||
import { GuildModel } from '../db/Guild';
|
||||
import { RefreshTaskData } from '../domain/activityField/refreshTaskField';
|
||||
import { ActivityRefreshTaskModel } from '../db/ActivityRefreshTask';
|
||||
import { ActivityInRemote, transActivityInRemoteToModelType } from '../domain/activityField/activityField';
|
||||
|
||||
|
||||
|
||||
@@ -487,7 +488,7 @@ function checkRecResult(rec: UserTaskRecType, id: number) {
|
||||
* @param {number} parma 参数
|
||||
*
|
||||
*/
|
||||
export async function accomplishTask(serverId: number, roleId: string, taskType: TASK_TYPE, count: number, parma?: any, activities?: ActivityModelType[]) {
|
||||
export async function accomplishTask(serverId: number, roleId: string, taskType: TASK_TYPE, count: number, parma?: any, activities?: ActivityInRemote[]) {
|
||||
// console.log('accomplishTask', roleId, taskType, count, JSON.stringify(parma))
|
||||
let pushMessage = [];
|
||||
let { activityGroupId } = await ServerlistModel.findByServerId(serverId);
|
||||
@@ -495,9 +496,9 @@ export async function accomplishTask(serverId: number, roleId: string, taskType:
|
||||
if(activities) {
|
||||
let result: ActivityModelType[] = [];
|
||||
for(let activity of activities) {
|
||||
if(activity.beginTime <= new Date() && activity.endTime >= new Date()) {
|
||||
if(activity.beginTime <= Date.now() && activity.endTime >= Date.now()) {
|
||||
if(activityGroupId.includes(activity.groupId) && types.includes(activity.type)) {
|
||||
result.push(activity);
|
||||
result.push( transActivityInRemoteToModelType(activity));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -519,7 +520,7 @@ export async function accomplishTask(serverId: number, roleId: string, taskType:
|
||||
let growthActivity = playerData.growth;
|
||||
let growthTaskArray = growthActivity.findTaskByType(taskType);
|
||||
for (let task of growthTaskArray) {
|
||||
let taskRecord = await ActivityGrowthModel.findDataByCellIndex(serverId, activity.activityId, roleId, task.dayIndex, task.cellIndex, task.taskType)
|
||||
let taskRecord = await ActivityGrowthModel.findDataByCellIndex(serverId, activity.activityId, roleId, task.dayIndex, task.cellIndex, task.taskType);
|
||||
let recordData = taskRecord && taskRecord.data ? JSON.parse(taskRecord.data) : null;
|
||||
let { addCount, record } = isComplete(roleId, task.taskType, task.taskParam, count, activity.activityId, parma, recordData);
|
||||
if (addCount) {
|
||||
|
||||
Reference in New Issue
Block a user