From e9e3459f834dfd8be0d3c772b3638505c938dd25 Mon Sep 17 00:00:00 2001 From: Anton Vakhrushev Date: Sat, 25 Apr 2020 22:54:36 +0300 Subject: [PATCH] Fix postpone error --- src/Action/SendResourcesAction.ts | 4 ++++ src/Scheduler.ts | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Action/SendResourcesAction.ts b/src/Action/SendResourcesAction.ts index f57b305..a1ba4f1 100644 --- a/src/Action/SendResourcesAction.ts +++ b/src/Action/SendResourcesAction.ts @@ -32,6 +32,10 @@ export class SendResourcesAction extends ActionController { console.log('To transfer res', readyToTransfer); console.log('Remaining res', remainingResources); + if (!remainingResources.empty() && readyToTransfer.amount() < 100) { + throw new TryLaterError(aroundMinutes(10), 'Not minimal amount'); + } + if (!remainingResources.empty()) { console.log('Schedule next', remainingResources); this.scheduler.scheduleTask( diff --git a/src/Scheduler.ts b/src/Scheduler.ts index a7f2867..8d58c77 100644 --- a/src/Scheduler.ts +++ b/src/Scheduler.ts @@ -88,8 +88,8 @@ export class Scheduler { const villageId = task.args.villageId; const modifyTime = t => withTime(t, timestamp() + seconds); - const buildPred = t => sameVillage(villageId, t.args) && isBuildingTask(task.name); - const trainPred = t => sameVillage(villageId, t.args) && isTrainTroopTask(task.name); + const buildPred = t => sameVillage(villageId, t.args) && isBuildingTask(t.name); + const trainPred = t => sameVillage(villageId, t.args) && isTrainTroopTask(t.name); if (isBuildingTask(task.name) && villageId) { this.taskQueue.modify(buildPred, modifyTime);