fix infinite check bug
[rofl0r-oopoker.git] / game.h
blob1e51cff10f3b2ff255eefc2aca8b4baafb2d68b3
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 <vector>
27 #include "info.h"
30 //forward declarations
31 class Host;
32 class Table;
33 struct Player;
34 class Observer;
35 struct Event;
37 void makeInfo(Info& info, const Table& table, const Rules& rules, int playerViewPoint);
39 void dividePot(std::vector<int>& wins, const std::vector<int>& bet, const std::vector<int>& score, const std::vector<bool>& folded);
40 int getNumActivePlayers(const std::vector<Player>& players);
41 bool betsSettled(int lastRaiseIndex, int current, int prev_current, const std::vector<Player>& players);
43 class Game
45 private:
46 Host* host;
47 std::vector<Player> playersOut; //players who quit the table (remembered in order to give the win rankings at the end). Not used if rebuys are allowed, since players then stay.
49 std::vector<Player> players;
50 std::vector<Observer*> observers;
51 std::vector<Event> events;
53 size_t eventCounter;
54 int numDeals; //how much deals are done since the game started
56 Rules rules;
58 Info infoForPlayers; //this is to speed up the game a lot, by not recreating the Info object everytime
60 protected:
61 void settleBets(Table& table, Rules& rules);
62 void kickOutPlayers(Table& table);
63 void declareWinners(Table& table);
64 void sendEvents(Table& table);
65 const Info& getInfoForPlayers(Table& table, int viewPoint = -1); //rather heavy-weight function! Copies entire Info object.
67 public:
69 Game(Host* host); //The game class will NOT delete the host, you have to clean up this variable yourself if needed.
70 ~Game();
72 //The Game class will take care of deleting the AI's and observers in its desctructor.
73 void addPlayer(const Player& player);
74 void addObserver(Observer* observer);
75 void setRules(const Rules& rules);
77 void runTable(Table& table);
79 void doGame();