Hand Generator
by wrxsti85
HTML
<script src="//diy-code.com/hand-eval.js"></script>
JavaScript
var p = function() {
this.players = [];
this.newPlayer = function(name) {
this.players.push({
name: name,
hand: [],
button: null,
eval: null,
handName: null,
handDesc: null
});
};
this.getIndex = function(name){
return this.players.map(function(e){ return e.name }).indexOf(name);
};
};
var d = function() {
var deck = {};
this.burn = [];
this.flop = [];
this.turn = [];
this.river = [];
this.reset = function() {
deck = {
h: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 'J', 'Q', 'K', 'A'],
d: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 'J', 'Q', 'K', 'A'],
s: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 'J', 'Q', 'K', 'A'],
c: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 'J', 'Q', 'K', 'A']
};
this.burn = [];
this.flop = [];
this.turn = [];
this.river = [];
};
this.card = function() {
var keys = Object.keys(deck);
var face = keys[keys.length * Math.random() << 0];
var valIndex = deck[face].length * Math.random() << 0;
var value = deck[face][valIndex];
deck[face].splice(valIndex, 1);
return {
face: face,
value: value
};
};
this.deal = function(handSize) {
var dealer = game.getDealer();
while (handSize > 0) {
var pCount = player.players.length;
while (pCount > 0) {
player.players[pCount - 1].hand.push(this.card());
pCount--;
}
handSize--;
}
};
this.burnCard = function() {
this.burn.push(this.card());
};
this.flopCard = function() {
this.burnCard();
this.flop.push(this.card());
this.flop.push(this.card());
this.flop.push(this.card());
};
this.turnCard = function() {
this.burnCard();
this.turn.push(this.card());
...