1 import { Task } from './task';
2 import { db } from '../lib/db';
9 export const tick = new Task<Tick>('tick', async (task, job) => {
11 const nextTick = job.data.lastTick+1;
13 // +population*1.1 is where we take into account farms for bonus food production
14 let sql = `update cities set
15 credits = credits + population * 2,
35 special_attacker_trainer * 100 +
36 special_defender_trainer * 80 +
47 (alloys + mining_facilities * 20),
51 (population + round(population * 0.08)),
58 db.raw(`update ticks set current_tick = ${nextTick}, last_tick_at = ${Date.now()}`)
65 const now = new Date();
66 const nextTickAt = 60 - now.getMinutes();
67 console.log(`Tick scheduled for ${nextTickAt}min`);
72 }, { delay: 60000 * nextTickAt});