Closed jaredlyon closed 5 years ago
Simple fix: the code was just out of order. Notice how statistics are recorded prior to the addition of the daily multiplier, causing $2.54 less to be tacked onto the statistics module.
bot.stats[msg.author.id].dailies.profit += 25.4;
bot.stats[msg.author.id].dailies.profit += 2.54 * bot.bank[msg.author.id].streak;
bot.bank[msg.author.id].streak += 1;
bot.bank[msg.author.id].balance += 25.4;
bot.bank[msg.author.id].balance += 2.54 * bot.bank[msg.author.id].streak;
bot.stats[msg.author.id].dailies.collected += 1;
bot.bank[msg.author.id].lastDaily = new Date();
The solution is to simply move the multiplier addition to the top of the write order:
bot.bank[msg.author.id].streak += 1;
bot.bank[msg.author.id].balance += 25.4;
bot.bank[msg.author.id].balance += 2.54 * bot.bank[msg.author.id].streak;
bot.stats[msg.author.id].dailies.collected += 1;
bot.stats[msg.author.id].dailies.profit += 25.4;
bot.stats[msg.author.id].dailies.profit += 2.54 * bot.bank[msg.author.id].streak;
bot.bank[msg.author.id].lastDaily = new Date();
When a user collects their daily allowance, the statistics module will fall behind by exactly $2.54: