Skip to content

Instantly share code, notes, and snippets.

@NoelDavies
Created September 15, 2019 17:07
Show Gist options
  • Save NoelDavies/32d4ebfd784ae871ee14d9f7f7724222 to your computer and use it in GitHub Desktop.
Save NoelDavies/32d4ebfd784ae871ee14d9f7f7724222 to your computer and use it in GitHub Desktop.
Refactor example - just to see what youthink
balanceAdjustmentTimer()
{
this.balanceAdjustmentCounter++;
if ( this.balanceAdjustmentCounter <= config.balanceCheckInterval ) return;
this.balanceAdjustmentCounter = 0;
this.playerBalances.map((currentBalance, username) => {
let currentBalance = this.getBalance(username)
if (currentBalance >= config.minimumBalance * 100) return currentBalance
var newBalance = currentBalance + config.balanceCheckAdjustment * 100;
if ( newBalance <= config.minimumBalance * 100 ) return newBalance
return config.minimumBalance * 100;
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment