[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Eliot-dev] Changes to eliot/game/game.h [antoine-1]
From: |
eliot-dev |
Subject: |
[Eliot-dev] Changes to eliot/game/game.h [antoine-1] |
Date: |
Sun, 23 Oct 2005 13:16:32 -0400 |
Index: eliot/game/game.h
diff -u /dev/null eliot/game/game.h:1.17.2.1
--- /dev/null Sun Oct 23 17:16:32 2005
+++ eliot/game/game.h Sun Oct 23 17:16:24 2005
@@ -0,0 +1,142 @@
+/*****************************************************************************
+ * Copyright (C) 1999-2005 Eliot
+ * Authors: Antoine Fraboulet <address@hidden>
+ * Olivier Teuliere <address@hidden>
+ *
+<<<<<<< game.h
+=======
+ * $Id: game.h,v 1.17.2.1 2005/10/23 17:16:24 afrab Exp $
+ *
+>>>>>>> 1.17
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *****************************************************************************/
+
+/* $Id: game.h,v 1.17.2.1 2005/10/23 17:16:24 afrab Exp $ */
+
+#ifndef _GAME_H_
+#define _GAME_H_
+
+#include <string>
+#include <vector>
+#include <iostream>
+#include "dic.h"
+#include "bag.h"
+#include "board.h"
+#include "history.h"
+#include "player.h"
+
+/**
+ * Parent class of all the Game types.
+ * It offers the common attributes (Board, Bag, etc...)
+ */
+class Game
+{
+public:
+ Game(const Dictionary iDic);
+ virtual ~Game();
+
+ /// Game modes: each one of these modes is implemented in an inherited
class
+ enum GameMode
+ {
+ kTRAINING,
+ kFREEGAME,
+ kDUPLICATE
+ };
+ virtual GameMode getMode() const = 0;
+ virtual std::string getModeAsString() const = 0;
+
+ /// Game variants: it slightly modifies the rules of the game
+ enum GameVariant
+ {
+ kNONE, // Normal game rules
+ kJOKER // Joker game
+ };
+ void setVariant(GameVariant iVariant) { m_variant = iVariant; }
+ GameVariant getVariant() const { return m_variant; }
+
+ /**
+ * Dictionary associated with the game.
+ * The dictionary can be changed during a game without problem
+ */
+ const Dictionary getDic() const { return m_dic; }
+ void setDic(const Dictionary iDic) { m_dic = iDic; }
+
+ const History& getHistory() const { return m_history; }
+ const Board& getBoard() const { return m_board; }
+ const Bag& getBag() const { return m_bag; }
+
+ /**
+ * Saved games handling.
+ * load() returns the loaded game, or NULL if there was a problem
+ */
+ static Game* load(FILE *fin, const Dictionary iDic);
+ void save(std::ostream &out) const;
+
+ // Game handling
+ virtual int start() { return 0; }
+ virtual int play(int player, const std::string iCoord, const std::string
iWord);
+ virtual int play(int player, const Coord &iCoord, const std::string
&iWord);
+ virtual int play(int player, Round& round) = 0;
+ virtual int back() = 0;
+ virtual int back(int n);
+ virtual int stop() { return 0; }
+
+ /// Testing things
+ int checkPlayedWord(const Coord& iCoord, const std::string &iWord, Round
&oRound);
+ int checkPlayedWord(Round& iRound);
+
+ /// Setting racks
+ virtual int setRack(int player, PlayedRack::set_rack_mode mode, bool
check, std::string rack = std::string(""));
+
+ /// Players
+ const int getNPlayers() const { return m_players.size(); }
+ const int getCurrentPlayerNum() const { return m_currplayer; }
+ const Player& getCurrentPlayer() const { return
*m_players[m_currplayer]; }
+ const Player& getPlayer(int idx) const;
+ virtual void addHumanPlayer();
+ virtual void addAIPlayer();
+
+protected:
+ /// Game turn history
+ History m_history;
+
+ /// Players
+ std::vector < Player* > m_players;
+ unsigned int m_currplayer;
+
+ /// Variant
+ GameVariant m_variant;
+
+ /// Dictionary currently associated to the game
+ Dictionary m_dic;
+
+ /// Bag
+ Bag m_bag;
+
+ /// Board
+ Board m_board;
+
+ /* ****************************************************** */
+ /* Load/Save functions for 1.4 and 1.5 format */
+ /* ****************************************************** */
+ static Game* gameLoadFormat_14(FILE *fin, const Dictionary iDic);
+ static Game* gameLoadFormat_15(FILE *fin, const Dictionary iDic);
+
+ void Game::gameSaveFormat_14(std::ostream &out) const;
+ void Game::gameSaveFormat_15(std::ostream &out) const;
+
+};
+
+#endif /* _GAME_H_ */
- [Eliot-dev] Changes to eliot/game/game.h [antoine-1],
eliot-dev <=