Today we created a game object so we could use the result of the functions we were testing with the other functions. We created some methods to get and set object properties and we added a displayGameObject menu item. And we are now using the gameObject with the set shooter function and it appears to be working properly. Here is the game Object:
let game = {
roundNumber: 0,
players: [0,1],
playersBanks: [20,20],
bet: 0,
currentShooter: undefined,
getBet: function() {
return this.bet;
},
setBet: function(amount) {
this.bet = amount;
return this.bet;
},
getPlayerBank: function(player) {
return this.playersBanks[player];
},
// Turn a number negative with: -Math.abs(num);
setPlayerBank: function(player, amount) {
return this.getPlayerBank[player] + amount; //amount can be negative for a losing bet
}
}
In the next part we will use the game object in each menu item and then we will start working on the game logic.
Please watch the video of today’s coding session and like and subscribe so you don’t miss any content from Dead Set on Success Coding.