Fix scheduled tasks

This commit is contained in:
Anton Vakhrushev 2020-04-16 18:00:34 +03:00
parent c3428afabb
commit c341c7d794

View File

@ -39,7 +39,7 @@ export class Scheduler {
this.scheduleUniqTask(3600, SendOnAdventureTask.name); this.scheduleUniqTask(3600, SendOnAdventureTask.name);
this.scheduleUniqTask(1200, BalanceHeroResourcesTask.name); this.scheduleUniqTask(1200, BalanceHeroResourcesTask.name);
this.scheduleUniqTask(300, GrabVillageState.name); this.scheduleUniqTask(180, GrabVillageState.name);
while (true) { while (true) {
await this.doTaskProcessingStep(); await this.doTaskProcessingStep();
@ -54,7 +54,7 @@ export class Scheduler {
private scheduleUniqTask(seconds: number, name: string, args: Args = {}) { private scheduleUniqTask(seconds: number, name: string, args: Args = {}) {
const taskScheduler = () => { const taskScheduler = () => {
if (!this.taskQueue.hasNamed(name)) { if (!this.taskQueue.hasNamed(name)) {
this.taskQueue.push(name, args, timestamp() + 5 * 60); this.taskQueue.push(name, args, timestamp() + Math.min(seconds, 5 * 60));
} }
}; };
taskScheduler(); taskScheduler();