diff --git a/projects/mtg/bin/Res/graphics/unlocked.png b/projects/mtg/bin/Res/graphics/unlocked.png new file mode 100644 index 000000000..fd63f7625 Binary files /dev/null and b/projects/mtg/bin/Res/graphics/unlocked.png differ diff --git a/projects/mtg/bin/Res/sound/sfx/bonus.wav b/projects/mtg/bin/Res/sound/sfx/bonus.wav new file mode 100644 index 000000000..c9cde1832 Binary files /dev/null and b/projects/mtg/bin/Res/sound/sfx/bonus.wav differ diff --git a/projects/mtg/include/GameOptions.h b/projects/mtg/include/GameOptions.h index d7132e131..745042bc5 100644 --- a/projects/mtg/include/GameOptions.h +++ b/projects/mtg/include/GameOptions.h @@ -8,6 +8,9 @@ using std::string; #define OPTIONS_MUSICVOLUME "musicVolume" #define OPTIONS_SFXVOLUME "sfxVolume" +#define OPTIONS_DIFFICULTY_MODE_UNLOCKED "prx_handler" //huhu +#define OPTIONS_DIFFICULTY "difficulty" + // WALDORF - added #define OPTIONS_INTERRUPT_SECONDS "interruptSeconds" diff --git a/projects/mtg/include/GameStateDuel.h b/projects/mtg/include/GameStateDuel.h index cc564bf0e..cc14b0b21 100644 --- a/projects/mtg/include/GameStateDuel.h +++ b/projects/mtg/include/GameStateDuel.h @@ -29,7 +29,10 @@ class GameStateDuel: public GameState, public JGuiListener SimpleMenu * menu; JLBFont* mFont, *opponentMenuFont; int nbAIDecks; - + int unlocked; + JQuad * unlockedQuad; + JTexture * unlockedTex; + int isDifficultyUnlocked(); void loadPlayer(int playerId, int decknb = 0, int isAI = 0); public: GameStateDuel(GameApp* parent); diff --git a/projects/mtg/src/GameObserver.cpp b/projects/mtg/src/GameObserver.cpp index 3cedb76b3..c789a7ecf 100644 --- a/projects/mtg/src/GameObserver.cpp +++ b/projects/mtg/src/GameObserver.cpp @@ -151,6 +151,32 @@ void GameObserver::startGame(int shuffle, int draw){ } phaseRing->goToPhase(Constants::MTG_PHASE_FIRSTMAIN, players[0]); currentGamePhase = Constants::MTG_PHASE_FIRSTMAIN; + + //Difficult mode special stuff + if (!players[0]->isAI() && players[1]->isAI()){ + GameOptions * go = GameOptions::GetInstance(); + int difficulty = go->values[OPTIONS_DIFFICULTY].getIntValue(); + if (go->values[OPTIONS_DIFFICULTY_MODE_UNLOCKED].getIntValue() && difficulty) { + Player * p = players[1]; + for (int level=0; level < difficulty; level ++){ + MTGCardInstance * card = NULL; + MTGGameZone * z = p->game->library; + for (int j = 0; jnb_cards; j++){ + MTGCardInstance * _card = z->cards[j]; + if (_card->hasType("land")){ + card = _card; + j = z->nb_cards; + } + } + if (card){ + MTGCardInstance * copy = p->game->putInZone(card, p->game->library, p->game->stack); + Spell * spell = NEW Spell(copy); + spell->resolve(); + delete spell; + } + } + } + } } void GameObserver::addObserver(MTGAbility * observer){ diff --git a/projects/mtg/src/GameStateDuel.cpp b/projects/mtg/src/GameStateDuel.cpp index 73e683763..97b0730b6 100644 --- a/projects/mtg/src/GameStateDuel.cpp +++ b/projects/mtg/src/GameStateDuel.cpp @@ -1,5 +1,6 @@ #include "../include/config.h" #include "../include/GameStateDuel.h" +#include "../include/GameOptions.h" #include "../include/utils.h" #include "../include/AIPlayer.h" #include "../include/PlayerData.h" @@ -73,6 +74,9 @@ void GameStateDuel::Start() mFont->SetBase(0); opponentMenuFont = mFont; + unlocked = -1; + unlockedTex = NULL; + unlockedQuad = NULL; menu = NEW SimpleMenu(DUEL_MENU_GAME_MENU, this, mFont, SCREEN_WIDTH/2-100, 25); menu->Add(12,"Back to main menu"); @@ -171,6 +175,8 @@ void GameStateDuel::End() SAFE_DELETE(deck[i]); } + SAFE_DELETE(unlockedQuad); + SAFE_DELETE(unlockedTex); SAFE_DELETE(menu); SAFE_DELETE(opponentMenu); #ifdef TESTSUITE @@ -283,16 +289,24 @@ void GameStateDuel::Update(float dt) if (game->gameOver){ showMsg = (rand() % 5); if (!mPlayers[0]->isAI() && mPlayers[1]->isAI() && mPlayers[0]!= game->gameOver){ -#if defined (WIN32) || defined (LINUX) - char buf[4096]; - sprintf(buf, "%p - %p", mPlayers[0], game->gameOver); - OutputDebugString(buf); -#endif PlayerData * playerdata = NEW PlayerData(mParent->collection); playerdata->credits+= 500; playerdata->save(); delete playerdata; - } + if (unlocked == -1){ + unlocked = isDifficultyUnlocked(); + if (unlocked){ + unlockedTex = JRenderer::GetInstance()->LoadTexture("graphics/unlocked.png", TEX_TYPE_USE_VRAM); + unlockedQuad = NEW JQuad(unlockedTex, 2, 2, 396, 96); + GameOptions::GetInstance()->values[OPTIONS_DIFFICULTY_MODE_UNLOCKED] = GameOption(1); + GameOptions::GetInstance()->save(); + JSample * sample = SampleCache::GetInstance()->getSample("sound/sfx/bonus.wav"); + if (sample) JSoundSystem::GetInstance()->PlaySample(sample); + } + } + }else{ + unlocked = 0; + } mGamePhase = DUEL_STATE_END; #ifdef TESTSUITE if (mParent->players[1] == PLAYER_TYPE_TESTSUITE){ @@ -348,12 +362,15 @@ void GameStateDuel::Render() { case DUEL_STATE_END: { - JRenderer::GetInstance()->ClearScreen(ARGB(200,0,0,0)); + JRenderer * r = JRenderer::GetInstance(); + r->ClearScreen(ARGB(200,0,0,0)); char buffer[50]; + int unlocked = 0; int p0life = mPlayers[0]->life; if (!mPlayers[0]->isAI() && mPlayers[1]->isAI() ){ - if (game->gameOver !=mPlayers[0]){ + if (game->gameOver != mPlayers[0]){ sprintf (buffer, "Victory! Congratulations, You earn 500 credits"); + }else{ sprintf (buffer, "You have been defeated"); } @@ -365,7 +382,9 @@ void GameStateDuel::Render() sprintf(buffer, "Player %i wins (%i)", winner, p0life ); } mFont->DrawString(buffer, 10, 150); - + if (unlockedQuad){ + r->RenderQuad(unlockedQuad, 20, 20); + } if (showMsg == 1){ JLBFont * f = GameApp::CommonRes->GetJLBFont(Constants::MAIN_FONT); mFont->DrawString("Please support this project !" ,10,180); @@ -452,3 +471,27 @@ void GameStateDuel::ButtonPressed(int controllerId, int controlId) } } } + +int GameStateDuel::isDifficultyUnlocked(){ + if (GameOptions::GetInstance()->values[OPTIONS_DIFFICULTY_MODE_UNLOCKED].getIntValue()) return 0; + nbAIDecks = 0; + int found = 1; + int wins = 0; + DeckStats * stats = DeckStats::GetInstance(); + stats->load(mPlayers[0]); + while (found){ + found = 0; + char buffer[512]; + char aiSmallDeckName[512]; + sprintf(buffer, RESPATH"/ai/baka/deck%i.txt",nbAIDecks+1); + if(fileExists(buffer)){ + found = 1; + nbAIDecks++; + sprintf(aiSmallDeckName, "ai_baka_deck%i",nbAIDecks); + int percentVictories = stats->percentVictories(string(aiSmallDeckName)); + if (percentVictories >=67) wins++; + if (wins >= 12) return 1; + } + } + return 0; +} \ No newline at end of file diff --git a/projects/mtg/src/GameStateOptions.cpp b/projects/mtg/src/GameStateOptions.cpp index a6b46e51e..38362ddd2 100644 --- a/projects/mtg/src/GameStateOptions.cpp +++ b/projects/mtg/src/GameStateOptions.cpp @@ -28,7 +28,9 @@ void GameStateOptions::Start() optionsList->Add(NEW OptionItem(OPTIONS_SFXVOLUME, "SFX volume", 100, 10)); // WALDORF - added next line optionsList->Add(NEW OptionItem(OPTIONS_INTERRUPT_SECONDS, "Seconds to pause for an Interrupt", 20, 1)); - + if (GameOptions::GetInstance()->values[OPTIONS_DIFFICULTY_MODE_UNLOCKED].getIntValue()) { + optionsList->Add(NEW OptionItem(OPTIONS_DIFFICULTY, "difficulty", 3, 1)); + } JLBFont * mFont = GameApp::CommonRes->GetJLBFont("graphics/f3"); optionsMenu = NEW SimpleMenu(102, this,mFont, 50,170); optionsMenu->Add(1, "Save & Back to Main Menu");