Amended the freeze code
This commit is contained in:
@@ -2,6 +2,8 @@ It's Freezing In Here!
|
||||
---
|
||||
_19 June 2019_
|
||||
|
||||
Edit: Actually, I realize freezing the tick rate for EVERYONE is unfair if you're under 100 gold - you'll never be able to train a unit. As such, I've amended the algorithm to only affect those with gold equal to or higher than 100.
|
||||
|
||||
I've frozen the gold tick due to the recent surge in the gold supply. This is a temporary measure, as I'm hoping it'll drop to a more reasonable level as players do their thing.
|
||||
|
||||
I'm hoping to pull another all nighter tonight, simply because I do my best work at night. I'm also planning on releasing "content updates" every Sunday my time to keep everyone entertained. I'll try to add _something_ new gameplay-wise every week.
|
||||
|
||||
+9
-11
@@ -479,8 +479,7 @@ const runGoldTick = (connection) => {
|
||||
|
||||
//determine the correct tick rate based on the current gold average
|
||||
let tickRate = (() => {
|
||||
//TMP: freeze the tick rate
|
||||
return null;
|
||||
return -60; //TMP: semi-freeze the tick rate
|
||||
if (results[0].goldAverage < 120) return 5;
|
||||
if (results[0].goldAverage < 130) return 15;
|
||||
if (results[0].goldAverage < 140) return 30;
|
||||
@@ -491,15 +490,14 @@ const runGoldTick = (connection) => {
|
||||
if (oldTickRate !== tickRate) {
|
||||
if (goldTickJob) goldTickJob.stop();
|
||||
|
||||
//TMP: freeze the tickRate
|
||||
if (tickRate === null) {
|
||||
log('Tick rate frozen');
|
||||
oldTickRate = tickRate;
|
||||
return;
|
||||
}
|
||||
|
||||
goldTickJob = new CronJob(`0 */${tickRate} * * * *`, () => {
|
||||
let query = 'UPDATE profiles SET gold = gold + recruits;';
|
||||
//NOTE: negative tickRate means restrict the tick to people with gold < 100
|
||||
goldTickJob = new CronJob(`0 */${tickRate > 0 ? tickRate : -tickRate} * * * *`, () => {
|
||||
let query;
|
||||
if (tickRate > 0) {
|
||||
query = 'UPDATE profiles SET gold = gold + recruits;';
|
||||
} else {
|
||||
query = 'UPDATE profiles SET gold = gold + recruits WHERE gold < 100;';
|
||||
}
|
||||
connection.query(query, (err) => {
|
||||
if (err) throw err;
|
||||
|
||||
|
||||
@@ -18,15 +18,14 @@ const statisticsRequest = (connection) => (req, res) => {
|
||||
//determine the correct tick rate based on the current gold average
|
||||
//NOTE: copy/pasted
|
||||
let tickRate = (() => {
|
||||
//TMP: freeze the tick rate
|
||||
return null;
|
||||
return -60; //TMP: semi-freeze the tick rate
|
||||
if (results[0].goldAverage < 120) return 5;
|
||||
if (results[0].goldAverage < 130) return 15;
|
||||
if (results[0].goldAverage < 140) return 30;
|
||||
return 60; //slow it way down
|
||||
})();
|
||||
|
||||
let nextTick = tickRate ? tickRate - (new Date()).getMinutes() % tickRate : null;
|
||||
let nextTick = Math.abs(tickRate) - (new Date()).getMinutes() % Math.abs(tickRate);
|
||||
|
||||
let query = 'SELECT COUNT(*) AS activity FROM accounts WHERE lastActivityTime >= DATE_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 DAY);';
|
||||
connection.query(query, (err, results) => {
|
||||
@@ -51,8 +50,8 @@ const statisticsRequest = (connection) => (req, res) => {
|
||||
'Scientist Total': scientistTotal,
|
||||
'Spy Total': { string: '[Classified]', color: 'red' },
|
||||
'Gold Average': `${round(goldAverage)}`,
|
||||
'Gold Tick Rate': tickRate ? `${tickRate} minutes` : { string: 'Frozen', color: 'red' },
|
||||
'Gold Next Tick': nextTick ? `${nextTick} minute${nextTick === 1 ? '' : 's'} from now` : { string: 'Frozen', color: 'red' }
|
||||
'Gold Tick Rate': tickRate > 0 ? `${tickRate} minutes` : { string: `${Math.abs(tickRate)} minutes (restricted to gold < 100)`, color: 'yellow' },
|
||||
'Gold Next Tick': `${nextTick} minute${nextTick === 1 ? '' : 's'} from now`
|
||||
});
|
||||
res.end();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user