From 3e33e2b7560bbad8e9bbe063f6fd1c5b1bb9f33b Mon Sep 17 00:00:00 2001 From: "wagic.the.homebrew@gmail.com" Date: Mon, 4 Jan 2010 13:51:39 +0000 Subject: [PATCH] Erwan -fix issue 270 --- projects/mtg/bin/Res/test/_tests.txt | 1 + .../Res/test/{bugs => }/iron_will_i270.txt | 12 +++++- projects/mtg/include/MTGDefinitions.h | 2 +- projects/mtg/src/ActionLayer.cpp | 11 +----- projects/mtg/src/GameObserver.cpp | 39 ++++++++++++------- 5 files changed, 39 insertions(+), 26 deletions(-) rename projects/mtg/bin/Res/test/{bugs => }/iron_will_i270.txt (73%) diff --git a/projects/mtg/bin/Res/test/_tests.txt b/projects/mtg/bin/Res/test/_tests.txt index 4746f1001..89f651a1c 100644 --- a/projects/mtg/bin/Res/test/_tests.txt +++ b/projects/mtg/bin/Res/test/_tests.txt @@ -251,6 +251,7 @@ icatian_priest.txt imaginary_pet.txt immaculate_magistrate.txt instill_energy_i166.txt +iron_will_i270.txt jodahs_avenger.txt juggernaut.txt jump.txt diff --git a/projects/mtg/bin/Res/test/bugs/iron_will_i270.txt b/projects/mtg/bin/Res/test/iron_will_i270.txt similarity index 73% rename from projects/mtg/bin/Res/test/bugs/iron_will_i270.txt rename to projects/mtg/bin/Res/test/iron_will_i270.txt index ada30b941..6ef0b875e 100644 --- a/projects/mtg/bin/Res/test/bugs/iron_will_i270.txt +++ b/projects/mtg/bin/Res/test/iron_will_i270.txt @@ -10,11 +10,19 @@ firstmain [PLAYER1] inplay:Suntail Hawk hand:Iron Will -library:Plains +library:plains manapool:{W}{W} [PLAYER2] [DO] Iron Will choice 0 Suntail Hawk -human +[ASSERT] +firstmain +[PLAYER1] +inplay:Suntail Hawk +graveyard:iron will +library:plains +manapool:{W} +[PLAYER2] +[END] diff --git a/projects/mtg/include/MTGDefinitions.h b/projects/mtg/include/MTGDefinitions.h index 0e58529fb..32f904cda 100644 --- a/projects/mtg/include/MTGDefinitions.h +++ b/projects/mtg/include/MTGDefinitions.h @@ -111,7 +111,7 @@ class Constants RARITY_U = 'U', //Uncommons RARITY_C = 'C', //Commons RARITY_L = 'L', //Lands - RARITY_T = 'T', //Tokens, reserved for internal logic. + RARITY_T = 'T', //Tokens //Price for singles PRICE_1M = 3000, diff --git a/projects/mtg/src/ActionLayer.cpp b/projects/mtg/src/ActionLayer.cpp index 4f5951a05..7fe1c2302 100644 --- a/projects/mtg/src/ActionLayer.cpp +++ b/projects/mtg/src/ActionLayer.cpp @@ -104,10 +104,7 @@ void ActionLayer::Render (){ for (int i=0;igetActivity() > 0){ currentAction->Render(); - //return; - //} } } } @@ -119,11 +116,6 @@ void ActionLayer::setCurrentWaitingAction(ActionElement * ae){ } TargetChooser * ActionLayer::getCurrentTargetChooser(){ - /* for (int i=0;iwaitingForAnswer) return currentAction->tc; - } - return NULL;*/ if (currentWaitingAction && currentWaitingAction->waitingForAnswer) return currentWaitingAction->tc; return NULL; @@ -247,8 +239,7 @@ void ActionLayer::doReactTo(int menuIndex){ } void ActionLayer::ButtonPressed(int controllerid, int controlid){ - if (controlid == -1){ - }else{ + if (controlid != -1){ ActionElement * currentAction = (ActionElement *)mObjects[controlid]; currentAction->reactToTargetClick(menuObject); } diff --git a/projects/mtg/src/GameObserver.cpp b/projects/mtg/src/GameObserver.cpp index c762873d5..5f23d94cf 100644 --- a/projects/mtg/src/GameObserver.cpp +++ b/projects/mtg/src/GameObserver.cpp @@ -403,6 +403,17 @@ void GameObserver::cardClick (MTGCardInstance * card, Targetable * object){ } if (card){ + + /* Fix for Issue http://code.google.com/p/wagic/issues/detail?id=270 + put into play is hopefully the only ability causing that kind of trouble + If the same kind of issue occurs with other abilities, let's think of a cleaner solution + */ + if (targetChooser) { + MTGAbility * a = mLayers->actionLayer()->getAbility(MTGAbility::PUT_INTO_PLAY); + a->reactToClick(card); + return; + } + reaction = mLayers->actionLayer()->isReactingToClick(card); if (reaction == -1) mLayers->actionLayer()->reactToClick(card); }else{ @@ -410,23 +421,25 @@ void GameObserver::cardClick (MTGCardInstance * card, Targetable * object){ if (reaction == -1) mLayers->actionLayer()->reactToTargetClick(object); } - if (reaction != -1){ - if (!card) return; - //Current player's hand - if (currentPlayer->game->hand->hasCard(card) && currentGamePhase == Constants::MTG_PHASE_CLEANUP && currentPlayer->game->hand->nb_cards > 7){ - currentPlayer->game->putInGraveyard(card); - }else if (reaction){ - if (reaction == 1){ - mLayers->actionLayer()->reactToClick(card); - }else{ - mLayers->actionLayer()->setMenuObject(object); - } - }else if (card->isTapped() && card->controller() == currentPlayer){ - ConstraintResolver::untap(this, card); + if (reaction == -1) return; + + if (!card) return; + + //Current player's hand + if (currentPlayer->game->hand->hasCard(card) && currentGamePhase == Constants::MTG_PHASE_CLEANUP && currentPlayer->game->hand->nb_cards > 7){ + currentPlayer->game->putInGraveyard(card); + }else if (reaction){ + if (reaction == 1){ + mLayers->actionLayer()->reactToClick(card); + }else{ + mLayers->actionLayer()->setMenuObject(object); } + }else if (card->isTapped() && card->controller() == currentPlayer){ + ConstraintResolver::untap(this, card); } + }