Client engine factory needs to be free of configuration file (configuration provided by server). Separated specific start data from general game data. Sending client game object to GUI after creation. Client thread now manages player and game data.

This commit is contained in:
lotodore
2007-05-20 00:16:29 +00:00
parent e7b31f2d44
commit 4a53678291
25 changed files with 285 additions and 133 deletions
+11 -28
View File
@@ -32,7 +32,7 @@
using namespace std;
Session::Session(GuiInterface *g, ConfigFile *c)
: currentGameID(0), myNetClient(0), myNetServer(0), currentGame(0), myGui(g), myConfig(c)
: currentGameID(0), myNetClient(0), myNetServer(0), myGui(g), myConfig(c)
{
}
@@ -42,19 +42,18 @@ Session::~Session()
{
terminateNetworkClient();
terminateNetworkServer();
deleteGame();
delete myConfig;
myConfig = 0;
}
void Session::startLocalGame(const GameData &gameData) {
deleteGame();
myGui->initGui(gameData.guiSpeed);
void Session::startLocalGame(const GameData &gameData, const StartData &startData) {
currentGame.reset();
currentGameID++;
myGui->initGui(gameData.guiSpeed);
PlayerDataList playerDataList;
for(int i=0; i<gameData.numberOfPlayers; i++) {
@@ -78,7 +77,7 @@ void Session::startLocalGame(const GameData &gameData) {
// EngineFactory erstellen
boost::shared_ptr<EngineFactory> factory(new LocalEngineFactory(myConfig)); // LocalEngine erstellen
currentGame = new Game(myGui, factory, playerDataList, gameData, currentGameID);
currentGame.reset(new Game(myGui, factory, playerDataList, gameData, startData, currentGameID));
//// SPIEL-SCHLEIFE
currentGame->initHand();
@@ -86,34 +85,18 @@ void Session::startLocalGame(const GameData &gameData) {
// SPIEL-SCHLEIFE
}
void Session::startClientGame(const GameData &gameData, const PlayerDataList &playerDataList)
void Session::startClientGame(boost::shared_ptr<Game> game)
{
deleteGame();
myGui->initGui(gameData.guiSpeed);
currentGameID++;
// EngineFactory erstellen
boost::shared_ptr<EngineFactory> factory(new ClientEngineFactory(myConfig)); // LocalEngine erstellen
currentGame = new Game(myGui, factory, playerDataList, gameData, currentGameID);
//// SPIEL-SCHLEIFE
currentGame->initHand();
currentGame->startHand();
// SPIEL-SCHLEIFE
}
void Session::deleteGame() {
delete currentGame;
currentGame = 0;
// TODO: use server gui speed.
myGui->initGui(5);
currentGame = game;
}
Game *Session::getCurrentGame()
{
return currentGame;
return currentGame.get();
}
GuiInterface *Session::getGui()