#include <game.h>
Inheritance diagram for Game:
It offers the common attributes (Board, Bag, etc...) as well as useful "helper" methods to factorize some code.
Definition at line 51 of file game.h.
Public Types | |
enum | GameMode { kTRAINING, kFREEGAME, kDUPLICATE } |
Game mode: each one of these modes is implemented in an inherited class. More... | |
enum | GameVariant { kNONE, kJOKER } |
Game variant: it slightly modifies the rules of the game. More... | |
enum | game_file_format { FILE_FORMAT_STANDARD, FILE_FORMAT_ADVANCED } |
Eliot file formats. More... | |
enum | set_rack_mode { RACK_ALL, RACK_NEW, RACK_MANUAL } |
Public Member Functions | |
Game (const Dictionary &iDic) | |
virtual | ~Game () |
virtual GameMode | getMode () const =0 |
virtual string | getModeAsString () const =0 |
void | setVariant (GameVariant iVariant) |
Accessors for the variant of the game. | |
GameVariant | getVariant () const |
const Dictionary & | getDic () const |
Dictionary associated with the game. | |
void | setDic (const Dictionary &iDic) |
const Board & | getBoard () const |
const Bag & | getBag () const |
const Player & | getPlayer (int iNum) const |
const Turn & | getTurn (int iNum) const |
const Player & | getCurrentPlayer () const |
void | save (ostream &out, game_file_format format=FILE_FORMAT_STANDARD) const |
Save a game to a File Standard format is used for training games so that it is compatible with previous versions of Eliot. | |
int | back (int) |
int | setRack (int player, set_rack_mode mode, bool check, const string &str) |
string | getPlayerRack (int, PlayedRack::display_mode mode=PlayedRack::RACK_SIMPLE) const |
const History & | getHistory () const |
Methods to access already played words. | |
int | getNPlayers () const |
Methods to access players. | |
int | getNHumanPlayers () const |
virtual void | addHumanPlayer () |
virtual void | addAIPlayer () |
int | currPlayer () const |
virtual int | start ()=0 |
Game handling. | |
virtual int | play (const string &iCoord, const string &iWord)=0 |
virtual int | endTurn ()=0 |
Static Public Member Functions | |
static Game * | load (FILE *fin, const Dictionary &iDic) |
Saved games handling. | |
Static Public Attributes | |
static const int | RACK_SIZE = 7 |
Protected Member Functions | |
int | helperPlayRound (const Round &iRound) |
int | helperSetRackRandom (int p, bool iCheck, set_rack_mode mode) |
int | helperSetRackManual (int p, bool iCheck, const string &iLetters) |
void | prevPlayer () |
void | nextPlayer () |
bool | rackInBag (const Rack &iRack, const Bag &iBag) const |
void | realBag (Bag &iBag) const |
int | checkPlayedWord (const string &iCoord, const string &iWord, Round &oRound) |
void | gameSaveFormat_14 (ostream &out) const |
Training games ares saved using the initial Eliot format. | |
void | gameSaveFormat_15 (ostream &out) const |
Advanced game file format output. | |
Static Protected Member Functions | |
static Game * | gameLoadFormat_14 (FILE *fin, const Dictionary &iDic) |
load games from File using the first format. | |
static Game * | gameLoadFormat_15 (FILE *fin, const Dictionary &iDic) |
load games from File using advanced format (since Eliot 1.5) This format is used for Duplicate, Freegame, . | |
Protected Attributes | |
vector< Player * > | m_players |
All the players, indexed by their ID. | |
int | m_currPlayer |
ID of the "current" player. | |
GameVariant | m_variant |
Variant. | |
const Dictionary * | m_dic |
Dictionary currently associated to the game. | |
Bag | m_bag |
Bag. | |
Board | m_board |
Board. | |
History | m_history |
History of the game. | |
int | m_points |
bool | m_finished |
|
Eliot file formats.
|
|
Game mode: each one of these modes is implemented in an inherited class.
|
|
Game variant: it slightly modifies the rules of the game.
|
|
|
|
Definition at line 40 of file game.cpp. References kNONE, m_currPlayer, m_finished, m_points, and m_variant. |
|
Definition at line 50 of file game.cpp. References getNPlayers(), and m_players. |
|
Reimplemented in Training. Definition at line 474 of file game.cpp. References getNPlayers(), and m_players. Referenced by GameFactory::createFromCmdLine(), gameLoadFormat_15(), and main_loop(). |
|
Reimplemented in Training. Definition at line 467 of file game.cpp. References getNPlayers(), and m_players. Referenced by GameFactory::createFromCmdLine(), gameLoadFormat_15(), main_loop(), and Training::start(). |
|
Definition at line 152 of file game.cpp. References Player::addPoints(), debug, Round::getPoints(), History::getPreviousTurn(), Turn::getRound(), History::getSize(), Round::getTile(), Round::getWordLen(), Round::isJoker(), Round::isPlayedFromRack(), Tile::Joker(), m_bag, m_board, m_currPlayer, m_dic, m_history, m_players, m_points, prevPlayer(), History::removeLastTurn(), Player::removeLastTurn(), Board::removeRound(), Bag::replaceTile(), and Round::toString(). Referenced by loop_training(). |
|
Definition at line 520 of file game.cpp. References Round::accessCoord(), ASSERT, Dic_search_word(), Round::getCoord(), getNPlayers(), Round::init(), Coord::isValid(), m_dic, and Coord::setFromString(). Referenced by Training::play(), FreeGame::play(), and Duplicate::play(). |
|
Definition at line 164 of file game.h. References m_currPlayer. Referenced by display_data(), getCurrentPlayer(), loop_freegame(), and GameIO::printPlayedRack(). |
|
|
|
load games from File using the first format. This format is used for Training games Definition at line 97 of file game_io.cpp. References GameFactory::createTraining(), debug, GameFactory::Instance(), play(), RACK_MANUAL, and start(). Referenced by load(). |
|
load games from File using advanced format (since Eliot 1.5) This format is used for Duplicate, Freegame, . .. Definition at line 173 of file game_io.cpp. References addAIPlayer(), addHumanPlayer(), PlayedRack::addNew(), PlayedRack::addOld(), Round::addRightFromBoard(), Round::addRightFromRack(), GameFactory::createDuplicate(), GameFactory::createFreeGame(), GameFactory::createTraining(), getMode(), getNPlayers(), Board::getTile(), GameFactory::Instance(), Tile::Joker(), kTRAINING, m_bag, m_board, m_players, Round::setBonus(), Round::setPoints(), Bag::takeTile(), and Coord::VERTICAL. Referenced by load(). |
|
Training games ares saved using the initial Eliot format.
Definition at line 408 of file game_io.cpp. References Coord::COORD_MODE_LONG, getCurrentPlayer(), Turn::getPlayedRack(), History::getSize(), History::getTurn(), IDENT_STRING, m_history, PlayedRack::RACK_EXTRA, and PlayedRack::toString(). Referenced by save(). |
|
Advanced game file format output.
Definition at line 443 of file game_io.cpp. References getModeAsString(), getNPlayers(), Turn::getRound(), History::getSize(), History::getTurn(), Round::getWord(), IDENT_FORMAT_15, IDENT_STRING, m_history, and m_players. Referenced by save(). |
|
Definition at line 90 of file game.h. References m_bag. Referenced by GameIO::printNonPlayed(), and BagFrame::Refresh(). |
|
Definition at line 89 of file game.h. References m_board. Referenced by GameIO::printBoard(), GameIO::printBoardJoker(), GameIO::printBoardMultipliers(), and GameIO::printBoardMultipliers2(). |
|
Definition at line 93 of file game.h. References currPlayer(), and getPlayer(). Referenced by gameSaveFormat_14(), helperPlayRound(), GfxResult::Refresh(), and Plus1Frame::refresh(). |
|
Dictionary associated with the game. The dictionary can be changed during a game without problem Definition at line 86 of file game.h. References m_dic. Referenced by loop_duplicate(), loop_freegame(), loop_training(), RaccFrame::refresh(), BenjFrame::refresh(), Plus1Frame::refresh(), and AuxFrameList::Refresh(). |
|
Methods to access already played words. The int parameter should be 0 <= int < getNTurns() Definition at line 153 of file game.h. References m_history. Referenced by GamePrintout::DrawPage(), and GameFrame::Refresh(). |
|
Implemented in Duplicate, FreeGame, and Training. Referenced by gameLoadFormat_15(), main_loop(), realBag(), RaccFrame::refresh(), BenjFrame::refresh(), and save(). |
|
Implemented in Duplicate, FreeGame, and Training. Referenced by gameSaveFormat_15(). |
|
Definition at line 458 of file game.cpp. References getNPlayers(), getPlayer(), and Player::isHuman(). Referenced by Duplicate::nextHumanPlayer(), and Duplicate::prevHumanPlayer(). |
|
Methods to access players. The int parameter should be 0 <= int < getNPlayers() Definition at line 159 of file game.h. References m_players. Referenced by addAIPlayer(), addHumanPlayer(), checkPlayedWord(), Duplicate::endTurn(), gameLoadFormat_15(), gameSaveFormat_15(), getNHumanPlayers(), helperSetRackRandom(), nextPlayer(), prevPlayer(), GameIO::printAllPoints(), GameIO::printAllRacks(), realBag(), Duplicate::setPlayer(), Training::start(), FreeGame::start(), and ~Game(). |
|
Definition at line 59 of file game.cpp. References ASSERT, and m_players. Referenced by getCurrentPlayer(), getNHumanPlayers(), getPlayerRack(), helperPlayRound(), helperSetRackManual(), helperSetRackRandom(), GameIO::printAllPoints(), GameIO::printPoints(), realBag(), and GameFrame::Refresh(). |
|
Definition at line 452 of file game.cpp. References Player::getCurrentRack(), getPlayer(), and PlayedRack::toString(). Referenced by GameIO::printAllRacks(), and GameIO::printPlayedRack(). |
|
|
|
Definition at line 80 of file game.h. References m_variant. |
|
Definition at line 67 of file game.cpp. References PlayedRack::getAllTiles(), getCurrentPlayer(), Player::getCurrentRack(), Player::getLastRack(), getPlayer(), Round::getPoints(), History::getSize(), Round::getTile(), Round::getWordLen(), Round::isJoker(), Round::isPlayedFromRack(), kJOKER, m_currPlayer, m_history, m_points, m_variant, History::playRound(), realBag(), Bag::replaceTile(), History::setCurrentRack(), and Tile::toChar(). Referenced by Training::play(), FreeGame::play(), and Training::playResult(). |
|
Definition at line 389 of file game.cpp. References PlayedRack::addOld(), Player::getCurrentRack(), getPlayer(), and PlayedRack::reset(). |
|
Definition at line 249 of file game.cpp. References ASSERT, Player::getCurrentRack(), PlayedRack::getNewTiles(), getNPlayers(), getPlayer(), PlayedRack::nOld(), RACK_NEW, realBag(), Bag::replaceTile(), and PlayedRack::resetNew(). Referenced by Training::setRackRandom(), FreeGame::setRackRandom(), and Duplicate::setRackRandom(). |
|
Saved games handling. load() returns the loaded game, or NULL if there was a problem load() might need some more work to be robust enough to handle "hand written" files Definition at line 52 of file game_io.cpp. References debug, gameLoadFormat_14(), gameLoadFormat_15(), IDENT_FORMAT_15, and IDENT_STRING. Referenced by main_loop(). |
|
Definition at line 491 of file game.cpp. References ASSERT, getNPlayers(), and m_currPlayer. Referenced by FreeGame::endTurn(), and Duplicate::nextHumanPlayer(). |
|
Implemented in Duplicate, FreeGame, and Training. Referenced by gameLoadFormat_14(). |
|
Definition at line 480 of file game.cpp. References ASSERT, getNPlayers(), and m_currPlayer. Referenced by back(), and Duplicate::prevHumanPlayer(). |
|
Definition at line 236 of file game.cpp. References Tile::getAllTiles(), Bag::in(), and Rack::in(). |
|
Definition at line 203 of file game.cpp. References PlayedRack::getAllTiles(), Player::getCurrentRack(), getMode(), getNPlayers(), getPlayer(), kFREEGAME, m_bag, and Bag::takeTile(). Referenced by helperPlayRound(), and helperSetRackRandom(). |
|
Save a game to a File Standard format is used for training games so that it is compatible with previous versions of Eliot. Saving can be forced to advanced format for training games by setting the last parameter to FILE_FORMAT_ADVANCED Definition at line 395 of file game_io.cpp. References FILE_FORMAT_STANDARD, gameSaveFormat_14(), gameSaveFormat_15(), getMode(), and kTRAINING. Referenced by display_data(), loop_duplicate(), loop_freegame(), loop_training(), and GameFrame::Refresh(). |
|
Definition at line 87 of file game.h. References m_dic. |
|
|
|
Accessors for the variant of the game. The variant can be changed during a game without any problem (though it seems rather useless...) Definition at line 79 of file game.h. References m_variant. Referenced by GameFactory::createFromCmdLine(). |
|
Game handling.
Implemented in Duplicate, FreeGame, and Training. Referenced by gameLoadFormat_14(), main(), and MainFrame::OnMenuGameNew(). |
|
Bag.
Definition at line 189 of file game.h. Referenced by back(), gameLoadFormat_15(), getBag(), and realBag(). |
|
Definition at line 192 of file game.h. Referenced by back(), gameLoadFormat_15(), getBoard(), Training::removeTestPlay(), Training::search(), and Training::testPlay(). |
|
ID of the "current" player.
Definition at line 177 of file game.h. Referenced by back(), currPlayer(), FreeGame::endTurn(), Duplicate::endTurn(), Game(), helperPlayRound(), Duplicate::nextHumanPlayer(), nextPlayer(), Training::play(), FreeGame::play(), Duplicate::play(), Training::playResult(), Duplicate::prevHumanPlayer(), prevPlayer(), Training::search(), Duplicate::setPlayer(), Training::setRack(), Training::setRackManual(), Training::start(), and FreeGame::start(). |
|
Dictionary currently associated to the game.
Definition at line 186 of file game.h. Referenced by back(), checkPlayedWord(), getDic(), Training::search(), and setDic(). |
|
Definition at line 202 of file game.h. Referenced by Game(), and FreeGame::pass(). |
|
History of the game. The vector is indexed by the number of turns in the game Definition at line 198 of file game.h. Referenced by back(), gameSaveFormat_14(), gameSaveFormat_15(), getHistory(), helperPlayRound(), Training::play(), FreeGame::play(), Training::playResult(), and Training::search(). |
|
All the players, indexed by their ID.
Definition at line 175 of file game.h. Referenced by addAIPlayer(), addHumanPlayer(), back(), FreeGame::endTurn(), Duplicate::endTurn(), gameLoadFormat_15(), gameSaveFormat_15(), getNPlayers(), getPlayer(), Duplicate::nextHumanPlayer(), Training::play(), FreeGame::play(), Training::playResult(), Duplicate::prevHumanPlayer(), Training::search(), Duplicate::setPlayer(), FreeGame::start(), and ~Game(). |
|
Definition at line 200 of file game.h. Referenced by back(), Game(), and helperPlayRound(). |
|
Variant.
Definition at line 183 of file game.h. Referenced by Game(), getVariant(), helperPlayRound(), and setVariant(). |
|
|