Skip to content

Commit

Permalink
added blind increases
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Dean committed May 18, 2020
1 parent d415480 commit 2c8b619
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 6 deletions.
11 changes: 6 additions & 5 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ io.sockets.on('connection', function( socket ) {
}
if( !nameExists ) {
// Creating the player object
players[socket.id] = new Player( socket, newScreenName, 1000 );
players[socket.id] = new Player( socket, newScreenName, 100000 );
callback( { 'success': true, screenName: newScreenName, totalChips: players[socket.id].chips } );
} else {
callback( { 'success': false, 'message': 'This name is taken' } );
Expand Down Expand Up @@ -408,7 +408,8 @@ function htmlEntities(str) {
return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
}

tables[0] = new Table( 0, 'Sample 10-handed Table', eventEmitter(0), 10, 2, 1, 200, 40, false );
tables[1] = new Table( 1, 'Sample 6-handed Table', eventEmitter(1), 6, 4, 2, 400, 80, false );
tables[2] = new Table( 2, 'Sample 2-handed Table', eventEmitter(2), 2, 8, 4, 800, 160, false );
tables[3] = new Table( 3, 'Sample 6-handed Private Table', eventEmitter(3), 6, 20, 10, 2000, 400, true );
tables[0] = new Table( 0, 'Sample 10-handed Table', eventEmitter(0), 10, 2, 1, 200, 40, false, false );
tables[1] = new Table( 1, 'Sample 6-handed Table', eventEmitter(1), 6, 4, 2, 400, 80, false, false );
tables[2] = new Table( 2, 'Sample 2-handed Table', eventEmitter(2), 2, 8, 4, 800, 160, false, false );
tables[3] = new Table( 3, 'Sample 6-handed Private Table', eventEmitter(3), 6, 20, 10, 2000, 400, true, false );
tables[4] = new Table( 4, '10-handed increasing blinds', eventEmitter(4), 10, 100, 50, 10000, 10000, false, true );
38 changes: 37 additions & 1 deletion poker_modules/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ var Deck = require('./deck'),
* @param int minBuyIn (the minimum amount of chips that one can bring to the table)
* @param bool privateTable (flag that shows whether the table will be shown in the lobby)
*/
var Table = function( id, name, eventEmitter, seatsCount, bigBlind, smallBlind, maxBuyIn, minBuyIn, privateTable ) {
var Table = function( id, name, eventEmitter, seatsCount, bigBlind, smallBlind, maxBuyIn, minBuyIn, privateTable, blindsIncrease ) {
// The table is not displayed in the lobby
this.privateTable = privateTable;
// The blinds increase
this.blindsIncrease = blindsIncrease;
// Increase blindsIncrease
this.increaseBlinds = false;
// The number of players who receive cards at the begining of each round
this.playersSittingInCount = 0;
// The number of players that currently hold cards in their hands
Expand Down Expand Up @@ -213,6 +217,19 @@ Table.prototype.initializeRound = function( changeDealer ) {
this.headsUp = this.playersSittingInCount === 2;
this.playersInHandCount = 0;

// If the blinds need to be increased then do so
console.log('blinds increase? ' + this.blindsIncrease);
console.log('increase blinds? ' + this.increaseBlinds);
console.log('small blind: ' + this.public.smallBlind);
console.log('big blind: ' + this.public.bigBlind);
if (this.increaseBlinds) {
this.public.smallBlind = 2 * this.public.smallBlind;
this.public.bigBlind = 2 * this.public.bigBlind;
this.increaseBlinds = false;
console.log('small blind: ' + this.public.smallBlind);
console.log('big blind: ' + this.public.bigBlind);
}

for( var i=0 ; i<this.public.seatsCount ; i++ ) {
// If a player is sitting on the current seat
if( this.seats[i] !== null && this.seats[i].public.sittingIn ) {
Expand Down Expand Up @@ -625,11 +642,30 @@ Table.prototype.playerSatIn = function( seat ) {

// If there are no players playing right now, try to initialize a game with the new player
if( !this.gameIsOn && this.playersSittingInCount > 1 ) {

// If table is set to increase blinds then at the start set a setInterval to do so
if (this.blindsIncrease) {
var self = this;
setInterval(function(){
self.setIncreaseBlinds();
}, 1*60*1000);
}
// Initialize the game
this.initializeRound( false );
}
};

Table.prototype.setIncreaseBlinds = function () {
this.increaseBlinds = true;
console.log('blinds increasing');
this.log({
message: 'Blinds increasing.',
action: '',
seat: '',
notification: ''
});
}

/**
* Changes the data of the table when a player leaves
* @param int seat
Expand Down

0 comments on commit 2c8b619

Please sign in to comment.