- reworked completly the JNetwork, JSocket interface (had to ifdef out the PSP socket code)
- added 2 menus to wait for connection and wait for deck selection - tested compilation on Qt Linux, Qt Windows and PSP - deactivated everywhere (NETWORK_SUPPORT to activate).
This commit is contained in:
@@ -8,8 +8,8 @@
|
||||
|
||||
MTGAbility * AIMomirPlayer::momirAbility = NULL;
|
||||
|
||||
AIMomirPlayer::AIMomirPlayer(MTGDeck * deck, string file, string fileSmall, string avatarFile) :
|
||||
AIPlayerBaka(deck, file, fileSmall, avatarFile)
|
||||
AIMomirPlayer::AIMomirPlayer(string file, string fileSmall, string avatarFile, MTGDeck * deck) :
|
||||
AIPlayerBaka(file, fileSmall, avatarFile, deck)
|
||||
{
|
||||
momirAbility = NULL;
|
||||
agressivity = 100;
|
||||
|
||||
@@ -38,8 +38,8 @@ int AIAction::Act()
|
||||
return 0;
|
||||
}
|
||||
|
||||
AIPlayer::AIPlayer(MTGDeck * deck, string file, string fileSmall) :
|
||||
Player(deck, file, fileSmall)
|
||||
AIPlayer::AIPlayer(string file, string fileSmall, MTGDeck * deck) :
|
||||
Player(file, fileSmall, deck)
|
||||
{
|
||||
nextCardToPlay = NULL;
|
||||
stats = NULL;
|
||||
@@ -1189,10 +1189,8 @@ AIPlayer * AIPlayerFactory::createAIPlayer(MTGAllCards * collection, Player * op
|
||||
if ( meta->getVictoryPercentage() >= 65)
|
||||
deckSetting = HARD;
|
||||
}
|
||||
MTGDeck * tempDeck = NEW MTGDeck(deckFile, collection,0, deckSetting);
|
||||
AIPlayerBaka * baka = NEW AIPlayerBaka(tempDeck, deckFile, deckFileSmall, avatarFile);
|
||||
AIPlayerBaka * baka = NEW AIPlayerBaka(deckFile, deckFileSmall, avatarFile);
|
||||
baka->deckId = deckid;
|
||||
SAFE_DELETE(tempDeck);
|
||||
return baka;
|
||||
}
|
||||
|
||||
@@ -1272,8 +1270,8 @@ MTGCardInstance * AIPlayerBaka::FindCardToPlay(ManaCost * pMana, const char * ty
|
||||
return nextCardToPlay;
|
||||
}
|
||||
|
||||
AIPlayerBaka::AIPlayerBaka(MTGDeck * deck, string file, string fileSmall, string avatarFile) :
|
||||
AIPlayer(deck, file, fileSmall)
|
||||
AIPlayerBaka::AIPlayerBaka(string file, string fileSmall, string avatarFile, MTGDeck * deck) :
|
||||
AIPlayer(file, fileSmall, deck)
|
||||
{
|
||||
mAvatarTex = WResourceManager::Instance()->RetrieveTexture(avatarFile, RETRIEVE_LOCK, TEXTURE_SUB_AVATAR);
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ void DuelLayers::CheckUserInput(int isAI)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (JGE::GetInstance()->GetLeftClickCoordinates(x, y))
|
||||
if ((!isAI) && JGE::GetInstance()->GetLeftClickCoordinates(x, y))
|
||||
{
|
||||
if (avatars->CheckUserInput(x, y))
|
||||
{
|
||||
|
||||
@@ -44,6 +44,9 @@ GameState::GameState(GameApp* parent) :
|
||||
|
||||
GameApp::GameApp() :
|
||||
JApp()
|
||||
#ifdef NETWORK_SUPPORT
|
||||
,mpNetwork(NULL)
|
||||
#endif //NETWORK_SUPPORT
|
||||
{
|
||||
#ifdef DEBUG
|
||||
nbUpdates = 0;
|
||||
|
||||
@@ -20,6 +20,10 @@
|
||||
#include "TestSuiteAI.h"
|
||||
#endif
|
||||
|
||||
#ifdef NETWORK_SUPPORT
|
||||
#include "NetworkPlayer.h"
|
||||
#endif
|
||||
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
#include <time.h>
|
||||
#endif
|
||||
@@ -41,6 +45,9 @@ enum ENUM_DUEL_STATE
|
||||
DUEL_STATE_PLAY,
|
||||
DUEL_STATE_BACK_TO_MAIN_MENU,
|
||||
DUEL_STATE_MENU,
|
||||
#ifdef NETWORK_SUPPORT
|
||||
DUEL_STATE_OPPONENT_WAIT,
|
||||
#endif //NETWORK_SUPPORT
|
||||
DUEL_STATE_ERROR
|
||||
};
|
||||
|
||||
@@ -77,6 +84,10 @@ GameState(parent)
|
||||
credits = NULL;
|
||||
rules = NULL;
|
||||
|
||||
#ifdef NETWORK_SUPPORT
|
||||
RegisterNetworkPlayers();
|
||||
#endif //NETWORK_SUPPORT
|
||||
|
||||
}
|
||||
|
||||
GameStateDuel::~GameStateDuel()
|
||||
@@ -156,22 +167,34 @@ void GameStateDuel::Start()
|
||||
}
|
||||
}
|
||||
|
||||
void GameStateDuel::loadPlayer(int playerId, int decknb, int isAI)
|
||||
void GameStateDuel::loadPlayer(int playerId, int decknb, bool isAI, bool isNetwork)
|
||||
{
|
||||
if (decknb)
|
||||
{
|
||||
if (!isAI)
|
||||
{ //Human Player
|
||||
char deckFile[255];
|
||||
if (premadeDeck)
|
||||
sprintf(deckFile, JGE_GET_RES("player/premade/deck%i.txt").c_str(), decknb);
|
||||
if(playerId == 0)
|
||||
{
|
||||
char deckFile[255];
|
||||
if (premadeDeck)
|
||||
sprintf(deckFile, JGE_GET_RES("player/premade/deck%i.txt").c_str(), decknb);
|
||||
else
|
||||
sprintf(deckFile, "%s/deck%i.txt", options.profileFile().c_str(), decknb);
|
||||
char deckFileSmall[255];
|
||||
sprintf(deckFileSmall, "player_deck%i", decknb);
|
||||
mPlayers[playerId] = NEW HumanPlayer(deckFile, deckFileSmall);
|
||||
#ifdef NETWORK_SUPPORT
|
||||
if(isNetwork)
|
||||
{
|
||||
ProxyPlayer* mProxy;
|
||||
mProxy = NEW ProxyPlayer(mPlayers[playerId], mParent->mpNetwork);
|
||||
}
|
||||
}
|
||||
else
|
||||
sprintf(deckFile, "%s/deck%i.txt", options.profileFile().c_str(), decknb);
|
||||
char deckFileSmall[255];
|
||||
sprintf(deckFileSmall, "player_deck%i", decknb);
|
||||
MTGDeck * tempDeck = NEW MTGDeck(deckFile, MTGCollection());
|
||||
mPlayers[playerId] = NEW HumanPlayer(tempDeck, deckFile, deckFileSmall);
|
||||
SAFE_DELETE( tempDeck );
|
||||
{ //Remote player
|
||||
mPlayers[playerId] = NEW RemotePlayer(mParent->mpNetwork);
|
||||
#endif //NETWORK_SUPPORT
|
||||
}
|
||||
}
|
||||
else
|
||||
{ //AI Player, chooses deck
|
||||
@@ -471,6 +494,29 @@ void GameStateDuel::Update(float dt)
|
||||
mGamePhase = DUEL_STATE_MENU;
|
||||
}
|
||||
break;
|
||||
#ifdef NETWORK_SUPPORT
|
||||
case DUEL_STATE_OPPONENT_WAIT:
|
||||
{
|
||||
if(mPlayers[1] && mPlayers[1]->game)
|
||||
{ // Player loaded
|
||||
menu->Close();
|
||||
SAFE_DELETE(menu);
|
||||
mGamePhase = DUEL_STATE_PLAY;
|
||||
} else if(menu == NULL)
|
||||
{
|
||||
loadPlayer(1, 42/* 0 not good*/, false, true);
|
||||
menu = NEW SimpleMenu(DUEL_STATE_OPPONENT_WAIT, this, Fonts::MENU_FONT, 150, 60);
|
||||
if (menu)
|
||||
{
|
||||
menu->Add(MENUITEM_MAIN_MENU, "Back to main menu");
|
||||
}
|
||||
} else
|
||||
{
|
||||
menu->Update(dt);
|
||||
}
|
||||
}
|
||||
break;
|
||||
#endif //NETWORK_SUPPORT
|
||||
case DUEL_STATE_MENU:
|
||||
menu->Update(dt);
|
||||
break;
|
||||
@@ -565,7 +611,11 @@ void GameStateDuel::Render()
|
||||
case DUEL_STATE_CHOOSE_DECK2_TO_PLAY:
|
||||
case DUEL_STATE_DECK1_DETAILED_INFO:
|
||||
case DUEL_STATE_DECK2_DETAILED_INFO:
|
||||
if (mParent->gameType != GAME_TYPE_CLASSIC)
|
||||
if (mParent->gameType != GAME_TYPE_CLASSIC
|
||||
#ifdef NETWORK_SUPPORT
|
||||
&& mParent->gameType != GAME_TYPE_SLAVE
|
||||
#endif //NETWORK_SUPPORT
|
||||
)
|
||||
mFont->DrawString(_("LOADING DECKS").c_str(), 0, SCREEN_HEIGHT / 2);
|
||||
else
|
||||
{
|
||||
@@ -582,6 +632,11 @@ void GameStateDuel::Render()
|
||||
mFont->DrawString(_("NO DECK AVAILABLE,").c_str(), 0, SCREEN_HEIGHT / 2);
|
||||
mFont->DrawString(_("PRESS CIRCLE TO GO TO THE DECK EDITOR!").c_str(), 0, SCREEN_HEIGHT / 2 + 20);
|
||||
break;
|
||||
#ifdef NETWORK_SUPPORT
|
||||
case DUEL_STATE_OPPONENT_WAIT:
|
||||
if (menu) menu->Render();
|
||||
break;
|
||||
#endif //NETWORK_SUPPORT
|
||||
case DUEL_STATE_MENU:
|
||||
case DUEL_STATE_CANCEL:
|
||||
case DUEL_STATE_BACK_TO_MAIN_MENU:
|
||||
@@ -742,9 +797,22 @@ void GameStateDuel::ButtonPressed(int controllerId, int controlId)
|
||||
vector<DeckMetaData *> * playerDeck = deckManager->getPlayerDeckOrderList();
|
||||
if (!premadeDeck && controlId > 0)
|
||||
deckNumber = playerDeck->at(controlId - 1)->getDeckId();
|
||||
loadPlayer(0, deckNumber);
|
||||
loadPlayer(0, deckNumber, false
|
||||
#ifdef NETWORK_SUPPORT
|
||||
,(mParent->players[1] == PLAYER_TYPE_REMOTE)
|
||||
#endif //NETWORK_SUPPORT
|
||||
);
|
||||
deckmenu->Close();
|
||||
mGamePhase = DUEL_STATE_CHOOSE_DECK1_TO_2;
|
||||
#ifdef NETWORK_SUPPORT
|
||||
if(mParent->players[1] == PLAYER_TYPE_REMOTE)
|
||||
{ // no need to choose an opponent deck in network mode
|
||||
mGamePhase = DUEL_STATE_OPPONENT_WAIT;
|
||||
}
|
||||
else
|
||||
#endif //NETWORK_SUPPORT
|
||||
{
|
||||
mGamePhase = DUEL_STATE_CHOOSE_DECK1_TO_2;
|
||||
}
|
||||
playerDeck = NULL;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -39,7 +39,10 @@ enum ENUM_MENU_STATE_MAJOR
|
||||
MENU_STATE_MAJOR_FIRST_TIME = 0x05,
|
||||
MENU_STATE_MAJOR_DUEL = 0x06,
|
||||
MENU_STATE_MAJOR_LANG = 0x07,
|
||||
|
||||
#ifdef NETWORK_SUPPORT
|
||||
MENU_STATE_NETWORK_DEFINE = 0x08,
|
||||
MENU_STATE_NETWORK_WAIT = 0x09,
|
||||
#endif //NETWORK_SUPPORT
|
||||
MENU_STATE_MAJOR = 0xFF
|
||||
};
|
||||
|
||||
@@ -61,8 +64,9 @@ enum
|
||||
MENUITEM_EXIT,
|
||||
SUBMENUITEM_1PLAYER,
|
||||
#ifdef NETWORK_SUPPORT
|
||||
SUBMENUITEM_2PLAYER_SERVER,
|
||||
SUBMENUITEM_2PLAYER_CLIENT,
|
||||
SUBMENUITEM_2PLAYERS,
|
||||
SUBMENUITEM_HOST_GAME,
|
||||
SUBMENUITEM_JOIN_GAME,
|
||||
#endif //NETWORK_SUPPORT
|
||||
SUBMENUITEM_DEMO,
|
||||
SUBMENUITEM_TESTSUITE,
|
||||
@@ -535,6 +539,44 @@ void GameStateMenu::Update(float dt)
|
||||
if (mEngine->GetButtonState(JGE_BTN_NEXT)) //Hook for GameStateAward state
|
||||
mParent->DoTransition(TRANSITION_FADE, GAME_STATE_AWARDS); //TODO: A slide transition would be nice.
|
||||
break;
|
||||
#ifdef NETWORK_SUPPORT
|
||||
case MENU_STATE_NETWORK_DEFINE:
|
||||
currentState = MENU_STATE_MAJOR_SUBMENU;
|
||||
subMenuController = NEW SimpleMenu(MENU_FIRST_DUEL_SUBMENU, this, Fonts::MENU_FONT, 150, 60);
|
||||
if (subMenuController)
|
||||
{
|
||||
subMenuController->Add(SUBMENUITEM_HOST_GAME, "Host a game");
|
||||
subMenuController->Add(SUBMENUITEM_JOIN_GAME, "Join a game");
|
||||
subMenuController->Add(SUBMENUITEM_CANCEL, "Cancel");
|
||||
}
|
||||
break;
|
||||
case MENU_STATE_NETWORK_WAIT:
|
||||
if(MENU_STATE_MINOR_NONE == (currentState & MENU_STATE_MINOR))
|
||||
{
|
||||
if(mParent->mpNetwork->isConnected())
|
||||
{
|
||||
if(subMenuController) subMenuController->Close();
|
||||
currentState = MENU_STATE_MAJOR_DUEL | MENU_STATE_MINOR_SUBMENU_CLOSING;
|
||||
}
|
||||
else if(!subMenuController)
|
||||
{
|
||||
// currentState = MENU_STATE_MAJOR_SUBMENU;
|
||||
subMenuController = NEW SimpleMenu(MENU_FIRST_DUEL_SUBMENU, this, Fonts::MENU_FONT, 150, 60);
|
||||
if (subMenuController)
|
||||
{
|
||||
subMenuController->Add(SUBMENUITEM_CANCEL, "Cancel connection");
|
||||
}
|
||||
}
|
||||
else{
|
||||
if (subMenuController)
|
||||
subMenuController->Update(dt);
|
||||
ensureMGuiController();
|
||||
mGuiController->Update(dt);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
#endif //NETWORK_SUPPORT
|
||||
case MENU_STATE_MAJOR_SUBMENU:
|
||||
if (subMenuController)
|
||||
subMenuController->Update(dt);
|
||||
@@ -751,8 +793,7 @@ void GameStateMenu::ButtonPressed(int controllerId, int controlId)
|
||||
// TODO Put 2 players mode back
|
||||
// This requires to fix the hand (to accept 2 players) OR to implement network game
|
||||
#ifdef NETWORK_SUPPORT
|
||||
subMenuController->Add(SUBMENUITEM_2PLAYER_SERVER, "2 Players - server");
|
||||
subMenuController->Add(SUBMENUITEM_2PLAYER_CLIENT, "2 Players - client");
|
||||
subMenuController->Add(SUBMENUITEM_2PLAYERS, "2 Players");
|
||||
#endif //NETWORK_SUPPORT
|
||||
subMenuController->Add(SUBMENUITEM_DEMO, "Demo");
|
||||
subMenuController->Add(SUBMENUITEM_CANCEL, "Cancel");
|
||||
@@ -781,22 +822,39 @@ void GameStateMenu::ButtonPressed(int controllerId, int controlId)
|
||||
currentState = MENU_STATE_MAJOR_DUEL | MENU_STATE_MINOR_SUBMENU_CLOSING;
|
||||
break;
|
||||
#ifdef NETWORK_SUPPORT
|
||||
case SUBMENUITEM_2PLAYER_SERVER:
|
||||
case SUBMENUITEM_2PLAYERS:
|
||||
mParent->players[0] = PLAYER_TYPE_HUMAN;
|
||||
mParent->players[1] = PLAYER_TYPE_HUMAN;
|
||||
this->hasChosenGameType = true;
|
||||
mParent->gameType = GAME_TYPE_CLASSIC;
|
||||
mParent->players[1] = PLAYER_TYPE_REMOTE;
|
||||
subMenuController->Close();
|
||||
currentState = MENU_STATE_MAJOR_DUEL | MENU_STATE_MINOR_SUBMENU_CLOSING;
|
||||
currentState = MENU_STATE_NETWORK_DEFINE | MENU_STATE_MINOR_SUBMENU_CLOSING;
|
||||
break;
|
||||
case SUBMENUITEM_2PLAYER_CLIENT:
|
||||
mParent->players[0] = PLAYER_TYPE_HUMAN;
|
||||
mParent->players[1] = PLAYER_TYPE_HUMAN;
|
||||
this->hasChosenGameType = true;
|
||||
mParent->gameType = GAME_TYPE_CLASSIC;
|
||||
case SUBMENUITEM_HOST_GAME:
|
||||
{
|
||||
if(!mParent->mpNetwork)
|
||||
{
|
||||
mParent->mpNetwork = new JNetwork();
|
||||
}
|
||||
mParent->mpNetwork->connect();
|
||||
subMenuController->Close();
|
||||
currentState = MENU_STATE_MAJOR_DUEL | MENU_STATE_MINOR_SUBMENU_CLOSING;
|
||||
currentState = MENU_STATE_NETWORK_WAIT | MENU_STATE_MINOR_SUBMENU_CLOSING;
|
||||
break;
|
||||
}
|
||||
case SUBMENUITEM_JOIN_GAME:
|
||||
{
|
||||
if(!mParent->mpNetwork)
|
||||
{
|
||||
mParent->mpNetwork = new JNetwork();
|
||||
}
|
||||
// FIXME needs to be able to specify the server ip
|
||||
mParent->mpNetwork->connect("127.0.0.1");
|
||||
// we let the server choose the game mode
|
||||
mParent->gameType = GAME_TYPE_SLAVE;
|
||||
hasChosenGameType = true;
|
||||
subMenuController->Close();
|
||||
// currentState = MENU_STATE_MAJOR_DUEL | MENU_STATE_MINOR_SUBMENU_CLOSING;
|
||||
currentState = MENU_STATE_NETWORK_WAIT;
|
||||
break;
|
||||
}
|
||||
#endif //NETWORK_SUPPORT
|
||||
case SUBMENUITEM_DEMO:
|
||||
mParent->players[0] = PLAYER_TYPE_CPU;
|
||||
@@ -810,6 +868,12 @@ void GameStateMenu::ButtonPressed(int controllerId, int controlId)
|
||||
{
|
||||
subMenuController->Close();
|
||||
}
|
||||
#ifdef NETWORK_SUPPORT
|
||||
if(mParent->mpNetwork)
|
||||
{
|
||||
SAFE_DELETE(mParent->mpNetwork);
|
||||
}
|
||||
#endif //NETWORK_SUPPORT
|
||||
currentState = MENU_STATE_MAJOR_MAINMENU | MENU_STATE_MINOR_SUBMENU_CLOSING;
|
||||
break;
|
||||
|
||||
|
||||
@@ -974,11 +974,10 @@ ostream& operator<<(ostream& out, const MTGGameZone& z)
|
||||
}
|
||||
ostream& operator<<(ostream& out, const MTGPlayerCards& z)
|
||||
{
|
||||
out << z.library->nb_cards << endl;
|
||||
out << z.library->nb_cards << " ";
|
||||
for (int i = 0; i < z.library->nb_cards; i++)
|
||||
out << z.library->cards[i]->getMTGId() << " ";
|
||||
|
||||
out << endl;
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
#include "NetworkPlayer.h"
|
||||
#include <sstream>
|
||||
|
||||
RemotePlayer* RemotePlayer::mInstance = NULL;
|
||||
ProxyPlayer* ProxyPlayer::mInstance = NULL;
|
||||
|
||||
void RegisterNetworkPlayers()
|
||||
{
|
||||
// JNetwork::registerCommand("GetPlayer", ProxyPlayer::Serialize, RemotePlayer::Deserialize);
|
||||
}
|
||||
|
||||
|
||||
RemotePlayer::RemotePlayer(JNetwork* pxNetwork)
|
||||
: Player("remote", "", NULL), mpNetwork(pxNetwork)
|
||||
{
|
||||
mInstance = this;
|
||||
mpNetwork->sendCommand("GetPlayer");
|
||||
}
|
||||
|
||||
void RemotePlayer::Deserialize(istream& in, ostream& out)
|
||||
{
|
||||
// istringstream ss(mInstance->mpNetwork->receiveString());
|
||||
in >> *mInstance;
|
||||
}
|
||||
|
||||
|
||||
ProxyPlayer::ProxyPlayer(Player* pxPlayer, JNetwork* pxNetwork)
|
||||
: mpPlayer(pxPlayer), mpNetwork(pxNetwork)
|
||||
{
|
||||
mInstance = this;
|
||||
JNetwork::registerCommand("GetPlayer", ProxyPlayer::Serialize, RemotePlayer::Deserialize);
|
||||
|
||||
// ostringstream ss;
|
||||
// ss << "Player : " << *mpPlayer;
|
||||
// mpNetwork->send(ss.str());
|
||||
}
|
||||
|
||||
void ProxyPlayer::Serialize(istream& in, ostream& out)
|
||||
{
|
||||
out << *(mInstance->mpPlayer);
|
||||
}
|
||||
@@ -5,9 +5,16 @@
|
||||
#include "DeckStats.h"
|
||||
#include "ManaCost.h"
|
||||
|
||||
Player::Player(MTGDeck * deck, string file, string fileSmall) :
|
||||
Player::Player(string file, string fileSmall, MTGDeck * deck) :
|
||||
Damageable(20)
|
||||
{
|
||||
bool deleteDeckPlease = false;
|
||||
if(deck == NULL && file != "testsuite" && file != "remote")
|
||||
{
|
||||
deck = NEW MTGDeck(file.c_str(), MTGCollection());
|
||||
deleteDeckPlease = true;
|
||||
}
|
||||
|
||||
game = NULL;
|
||||
deckFile = file;
|
||||
deckFileSmall = fileSmall;
|
||||
@@ -25,6 +32,10 @@ Damageable(20)
|
||||
game->setOwner(this);
|
||||
deckName = deck->meta_name;
|
||||
}
|
||||
if(deleteDeckPlease)
|
||||
{
|
||||
SAFE_DELETE(deck);
|
||||
}
|
||||
}
|
||||
|
||||
/*Method to call at the end of a game, before all objects involved in the game are destroyed */
|
||||
@@ -87,8 +98,8 @@ Player * Player::opponent()
|
||||
return this == game->players[0] ? game->players[1] : game->players[0];
|
||||
}
|
||||
|
||||
HumanPlayer::HumanPlayer(MTGDeck * deck, string file, string fileSmall) :
|
||||
Player(deck, file, fileSmall)
|
||||
HumanPlayer::HumanPlayer(string file, string fileSmall, MTGDeck * deck) :
|
||||
Player(file, fileSmall, deck)
|
||||
{
|
||||
loadAvatar("avatar.jpg");
|
||||
playMode = MODE_HUMAN;
|
||||
@@ -203,6 +214,7 @@ istream& operator>>(istream& in, Player& p)
|
||||
}
|
||||
|
||||
in >> *(p.game);
|
||||
p.game->setOwner(&p);
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
@@ -191,7 +191,11 @@ void Rules::addExtraRules()
|
||||
if (p->playMode != Player::MODE_TEST_SUITE && g->mRules->gamemode != GAME_TYPE_MOMIR && g->mRules->gamemode
|
||||
!= GAME_TYPE_RANDOM1 && g->mRules->gamemode != GAME_TYPE_RANDOM2 && g->mRules->gamemode
|
||||
!= GAME_TYPE_STORY &&
|
||||
g->mRules->gamemode != GAME_TYPE_DEMO && (!g->players[0] == PLAYER_TYPE_CPU && !g->players[1] == PLAYER_TYPE_CPU))//keep this out of mimor and other game modes.
|
||||
g->mRules->gamemode != GAME_TYPE_DEMO && (!g->players[0] == PLAYER_TYPE_CPU && !g->players[1] == PLAYER_TYPE_CPU)
|
||||
#ifdef NETWORK_SUPPORT
|
||||
&& !g->players[1] == PLAYER_TYPE_REMOTE
|
||||
#endif //NETWORK_SUPPORT
|
||||
)//keep this out of mimor and other game modes.
|
||||
{
|
||||
difficultyRating = DeckManager::getDifficultyRating(g->players[0], g->players[1]);
|
||||
}
|
||||
@@ -273,9 +277,9 @@ Player * Rules::loadPlayerMomir(int isAI)
|
||||
|
||||
Player *player = NULL;
|
||||
if (!isAI) // Human Player
|
||||
player = NEW HumanPlayer(tempDeck, options.profileFile("momir.txt", "", true).c_str(), deckFileSmall);
|
||||
player = NEW HumanPlayer(options.profileFile("momir.txt", "", true).c_str(), deckFileSmall, tempDeck);
|
||||
else
|
||||
player = NEW AIMomirPlayer(tempDeck, options.profileFile("momir.txt", "", true).c_str(), deckFileSmall, empty);
|
||||
player = NEW AIMomirPlayer(options.profileFile("momir.txt", "", true).c_str(), deckFileSmall, empty, tempDeck);
|
||||
|
||||
delete tempDeck;
|
||||
return player;
|
||||
@@ -308,9 +312,9 @@ Player * Rules::loadPlayerRandom(int isAI, int mode)
|
||||
|
||||
Player *player = NULL;
|
||||
if (!isAI) // Human Player
|
||||
player = NEW HumanPlayer(tempDeck, deckFile, deckFileSmall);
|
||||
player = NEW HumanPlayer(deckFile, deckFileSmall, tempDeck);
|
||||
else
|
||||
player = NEW AIPlayerBaka(tempDeck, deckFile, deckFileSmall, "");
|
||||
player = NEW AIPlayerBaka(deckFile, deckFileSmall, "", tempDeck);
|
||||
|
||||
delete tempDeck;
|
||||
return player;
|
||||
|
||||
@@ -305,16 +305,12 @@ void StoryDuel::init()
|
||||
sprintf(folder, JGE_GET_RES(CAMPAIGNS_FOLDER"%s/%s").c_str(), mParent->folder.c_str(), pageId.c_str());
|
||||
|
||||
sprintf(deckFile, "%s/deck.txt", folder);
|
||||
MTGDeck * tempDeck = NEW MTGDeck(deckFile, MTGCollection());
|
||||
sprintf(deckFileSmall, "campaign_%s", mParent->folder.c_str());
|
||||
players[0] = NEW HumanPlayer(tempDeck, deckFile, deckFileSmall);
|
||||
SAFE_DELETE(tempDeck);
|
||||
players[0] = NEW HumanPlayer(deckFile, deckFileSmall);
|
||||
|
||||
sprintf(deckFile, "%s/opponent_deck.txt", folder);
|
||||
tempDeck = NEW MTGDeck(deckFile, MTGCollection());
|
||||
sprintf(deckFileSmall, "campaign_ennemy_%s_%s", mParent->folder.c_str(), pageId.c_str());
|
||||
players[1] = NEW AIPlayerBaka(tempDeck, deckFile, deckFileSmall, "baka.jpg");
|
||||
SAFE_DELETE(tempDeck);
|
||||
players[1] = NEW AIPlayerBaka(deckFile, deckFileSmall, "baka.jpg");
|
||||
|
||||
string rulesFile = folder;
|
||||
rulesFile.append("/rules.txt");
|
||||
|
||||
@@ -16,7 +16,7 @@ using std::string;
|
||||
// NULL is sent in place of a MTGDeck since there is no way to create a MTGDeck without a proper deck file.
|
||||
// TestSuiteAI will be responsible for managing its own deck state.
|
||||
TestSuiteAI::TestSuiteAI(TestSuite * _suite, int playerId) :
|
||||
AIPlayerBaka(NULL, "testsuite", "testsuite", "baka.jpg")
|
||||
AIPlayerBaka("testsuite", "testsuite", "baka.jpg", NULL)
|
||||
{
|
||||
this->game = _suite->buildDeck(playerId);
|
||||
game->setOwner(this);
|
||||
|
||||
Reference in New Issue
Block a user