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;
12 const start = Date.now();
14 // +population*1.1 is where we take into account farms for bonus food production
15 let sql = `update cities set
16 credits = credits + population * 2,
36 special_attacker_trainer * 10 +
37 special_defender_trainer * 8 +
42 mining_facilities * 8 +
46 ) + solar_panels * 125,
50 (alloys + mining_facilities * 20),
54 (population + round(population * 0.08)),
61 db.raw(`update ticks set current_tick = ${nextTick}, last_tick_at = ${Date.now()}`)
68 console.log('Tick complete', Date.now() - start);