fix infinite check bug
[rofl0r-oopoker.git] / player.h
bloba2eba19e0f9160e860263c3f752e089fdfa308a7
1 /*
2 OOPoker
4 Copyright (c) 2010 Lode Vandevenne
5 All rights reserved.
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/>.
23 #pragma once
25 #include <string>
27 #include "action.h"
28 #include "event.h"
30 class AI;
31 struct Info;
34 A Player is what joins the table and plays the game. Each player must have an AI,
35 which can be either a human or a bot.
37 For the rest, he has chips and a certain game status.
39 This class is used for running the Game, the AI's shouldn't use this class, they
40 get this information in the form of an Info struct instead.
42 struct Player
44 AI* ai; //the AI for the player
46 int stack; //chips in his stack
47 int wager; //how much chips this person currently has in the pot on the table (note: the "int stack" variable does NOT include these chips anymore, they're moved from stack to pot)
49 int buyInTotal; //for how much money did this player buy in (used if rebuys are allowed to calculate score at end)
51 Card holeCard1;
52 Card holeCard2;
54 bool folded;
55 bool showdown; //this player (has to or wants to) show their cards
57 std::string name;
59 Action lastAction; //used for filling it in the Info
61 Player(AI* ai, const std::string& name);
63 void setCards(Card card1, Card card2);
66 Rules about this name:
67 -must have at least one character
68 -max 12 characters, otherwise the ascii art is screwed up
69 -spaces and dots are allowed
70 -semicolons and commas are not allowed. This because semicolons are often used in logs and such, allowing parsers to know they're not part of a name.
72 std::string getName() const; //min 1 letter,
73 std::string getAIName() const;
75 Action doTurn(const Info& info);
76 void onEvent(const Event& event);
78 bool isAllIn() const;
79 bool isOut() const; //can't play anymore, has no more money
80 bool isFolded() const;
82 bool isHuman() const;
84 bool canDecide() const; //returns true if stack > 0 and not folded
88 std::string getRandomName();