4 Copyright (c) 2010 Lode Vandevenne
7 This file is part of OOPoker.
9 OOPoker is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
14 OOPoker is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with OOPoker. If not, see <http://www.gnu.org/licenses/>.
26 Action::Action(Command command
, int amount
)
39 bool isValidAllInAction(const Action
& action
, int stack
, int wager
, int highestWager
, int highestRaise
)
43 int callAmount
= highestWager
- wager
;
45 switch(action
.command
)
57 return callAmount
>= stack
;
61 return action
.amount
> 0 && action
.amount
== stack
; //must be exact. If higher, it's an invalid action.
64 default: return false;
68 bool isValidAction(const Action
& action
, int stack
, int wager
, int highestWager
, int highestRaise
)
70 int callAmount
= highestWager
- wager
;
72 switch(action
.command
)
80 return callAmount
== 0;
84 if(callAmount
== 0) return false; //you should use check in this case. Otherwise player statistics get messed up. So, disallowed!
85 return stack
> 0; //it's always valid for the rest, as long as your stack isn't empty. If call amount is bigger than your stack, you go all-in, it's still a valid call.
89 int raiseAmount
= action
.amount
- callAmount
;
90 return (action
.amount
<= stack
&& raiseAmount
>= highestRaise
)
91 || isValidAllInAction(action
, stack
, wager
, highestWager
, highestRaise
);