-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgamestate.js
47 lines (35 loc) · 1.04 KB
/
gamestate.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
var Rates = require('./rates');
var GameState = function(game_state_data) {
this.data = JSON.parse(game_state_data);
};
GameState.prototype = {
getOurPlayer: function() {
return this.data.players[this.data.in_action];
},
getHand: function() {
return this.getOurPlayer().hole_cards;
},
rateHand: function() {
var hand = this.getHand();
return Rates.rateTwoCards(hand);
},
getHoldValue: function() {
return this.data.current_buy_in - this.getOurPlayer().bet;
},
getMinimumRaise: function() {
return this.data.current_buy_in - this.getOurPlayer().bet + this.data.minimum_raise;
},
isPreFlopState: function() {
return this.data.community_cards.length === 0;
},
isFlop: function() {
return this.data.community_cards.length === 3;
},
isTurn: function() {
return this.data.community_cards.length === 4;
},
isRiver: function() {
return this.data.community_cards.length === 5;
}
};
module.exports = GameState;