2005-02-24 09:06:24 +01:00
|
|
|
/*****************************************************************************
|
2008-01-08 14:52:32 +01:00
|
|
|
* Eliot
|
|
|
|
* Copyright (C) 2005-2007 Olivier Teulière
|
|
|
|
* Authors: Olivier Teulière <ipkiss @@ gmail.com>
|
2005-02-24 09:06:24 +01:00
|
|
|
*
|
|
|
|
* 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
|
2005-10-23 16:53:42 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
2005-02-24 09:06:24 +01:00
|
|
|
*****************************************************************************/
|
|
|
|
|
2009-11-29 17:01:31 +01:00
|
|
|
#ifndef GAME_FACTORY_H_
|
|
|
|
#define GAME_FACTORY_H_
|
2005-02-24 09:06:24 +01:00
|
|
|
|
2008-01-08 14:52:32 +01:00
|
|
|
#include <string>
|
2008-01-19 20:33:08 +01:00
|
|
|
#include <vector>
|
2011-01-30 00:47:20 +01:00
|
|
|
#include "logging.h"
|
2008-01-08 14:52:32 +01:00
|
|
|
|
|
|
|
using std::string;
|
2008-01-19 20:33:08 +01:00
|
|
|
using std::wstring;
|
|
|
|
using std::vector;
|
|
|
|
using std::pair;
|
2008-01-08 14:52:32 +01:00
|
|
|
|
|
|
|
class Dictionary;
|
2011-08-27 19:21:26 +02:00
|
|
|
class GameParams;
|
2008-01-08 14:52:32 +01:00
|
|
|
class Game;
|
2005-02-24 09:06:24 +01:00
|
|
|
|
|
|
|
|
2005-03-27 19:30:48 +02:00
|
|
|
/**
|
|
|
|
* This class is the entry point to create Game objects, either directly or
|
|
|
|
* using command-line parameters. It also offers a method to destroy Game
|
|
|
|
* objects.
|
|
|
|
* This class implements the Singleton pattern.
|
|
|
|
*/
|
2005-02-24 09:06:24 +01:00
|
|
|
class GameFactory
|
|
|
|
{
|
2011-01-30 00:47:20 +01:00
|
|
|
DEFINE_LOGGER();
|
2005-02-24 09:06:24 +01:00
|
|
|
public:
|
2005-03-03 23:14:41 +01:00
|
|
|
static GameFactory *Instance();
|
|
|
|
static void Destroy();
|
|
|
|
|
2011-08-28 18:44:34 +02:00
|
|
|
/// Create a game
|
|
|
|
Game *createGame(const GameParams &iParams);
|
|
|
|
|
|
|
|
/// Return the loaded game, or NULL if there was a problem
|
2008-01-08 14:52:32 +01:00
|
|
|
Game *load(const string &iFileName, const Dictionary &iDic);
|
2005-02-24 09:06:24 +01:00
|
|
|
|
2005-03-03 23:14:41 +01:00
|
|
|
Game *createFromCmdLine(int argc, char **argv);
|
|
|
|
|
2005-03-27 19:30:48 +02:00
|
|
|
/// Destroy a Game object, created by any of the createXXX methods above
|
2005-02-24 09:06:24 +01:00
|
|
|
void releaseGame(Game &iGame);
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2005-03-03 23:14:41 +01:00
|
|
|
GameFactory();
|
2008-01-08 14:52:32 +01:00
|
|
|
~GameFactory();
|
2005-02-24 09:06:24 +01:00
|
|
|
|
2005-03-03 23:14:41 +01:00
|
|
|
/// The unique instance of the class
|
2005-02-24 09:06:24 +01:00
|
|
|
static GameFactory *m_factory;
|
2005-03-03 23:14:41 +01:00
|
|
|
|
|
|
|
/// Initial dictionary (it could be changed later)
|
2008-01-08 14:52:32 +01:00
|
|
|
Dictionary *m_dic;
|
2005-03-03 23:14:41 +01:00
|
|
|
|
|
|
|
/** Parameters specified on the command-line */
|
|
|
|
//@{
|
|
|
|
|
|
|
|
/// Dictionary
|
|
|
|
string m_dicStr;
|
|
|
|
|
|
|
|
/// Game mode
|
|
|
|
string m_modeStr;
|
|
|
|
|
2005-03-29 00:07:22 +02:00
|
|
|
/// Variant of the game
|
|
|
|
bool m_joker;
|
|
|
|
|
2008-01-19 20:33:08 +01:00
|
|
|
typedef pair<bool, wstring> PlayerDesc;
|
|
|
|
vector<PlayerDesc> m_players;
|
|
|
|
|
2005-03-03 23:14:41 +01:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/// Print command-line usage
|
|
|
|
void printUsage(const string &iBinaryName) const;
|
|
|
|
|
|
|
|
/// Print version
|
|
|
|
void printVersion() const;
|
|
|
|
|
2005-02-24 09:06:24 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _GAME_FACTORY_H_
|
2006-01-01 20:49:35 +01:00
|
|
|
|