swap tick from delayed job to repeatable
[browser-rts.git] / src / tasks / tick.ts
index 0f4c3ebea5b1494cad4c89f660624dd8e847d979..345f5af7e81f8e79ca6383bba3e5454416ba7f32 100644 (file)
@@ -9,6 +9,7 @@ type Tick = {
 export const tick = new Task<Tick>('tick', async (task, job) => {
 
        const nextTick = job.data.lastTick+1;
+  const start = Date.now();
 
        // +population*1.1 is where we take into account farms for bonus food production
        let sql = `update cities set 
@@ -64,14 +65,6 @@ export const tick = new Task<Tick>('tick', async (task, job) => {
                console.log(e);
        }
        finally {
-               const now = new Date();
-               const nextTickAt = 60 - now.getMinutes();
-               console.log(`Tick scheduled for ${nextTickAt}min`);
-
-               task.trigger({
-                       lastTickAt: +now,
-                       lastTick: nextTick
-               }, { delay: 60000 * nextTickAt});
+    console.log('Tick complete', Date.now() - start);
        }
-
 });