diff --git a/projects/mtg/bin/Res/test/Timely_Reinforcements.txt b/projects/mtg/bin/Res/test/Timely_Reinforcements.txt new file mode 100644 index 000000000..2e02785e0 --- /dev/null +++ b/projects/mtg/bin/Res/test/Timely_Reinforcements.txt @@ -0,0 +1,27 @@ +# Issue #962: https://code.google.com/p/wagic/issues/detail?id=962&start=100 +# Hexproof prevents creature from being counted +# +# Timely reinforcements: +# If you have less life than an opponent, you gain 6 life. If you control fewer creatures than an opponent, put three 1/1 white Soldier creature tokens onto the battlefield. +[INIT] +FIRSTMAIN +[PLAYER1] +manapool:{2}{W} +hand:timely reinforcements +life:19 +[PLAYER2] +# creature 1/1, hexproof +inplay:Invisible stalker +[DO] +timely reinforcements +[ASSERT] +FIRSTMAIN +[PLAYER1] +life:25 +# 3 tokens +inplay:*,*,* +graveyard:timely reinforcements +manapool:{0} +[PLAYER2] +inplay:Invisible stalker +[END] \ No newline at end of file diff --git a/projects/mtg/bin/Res/test/_tests.txt b/projects/mtg/bin/Res/test/_tests.txt index 143ff2ed0..97d7a55e5 100644 --- a/projects/mtg/bin/Res/test/_tests.txt +++ b/projects/mtg/bin/Res/test/_tests.txt @@ -638,6 +638,7 @@ thunder-thrash_elder.txt tidal_warrior_i646.txt tidal_warrior_i649.txt tidal_warrior_i652.txt +Timely_Reinforcements.txt titanic_ultimatum.txt torture.txt tranquil_domain.txt diff --git a/projects/mtg/include/TargetChooser.h b/projects/mtg/include/TargetChooser.h index 6949be306..97be56c8e 100644 --- a/projects/mtg/include/TargetChooser.h +++ b/projects/mtg/include/TargetChooser.h @@ -36,7 +36,6 @@ public: TARGETED_PLAYER = 4 }; bool other; - bool withoutProtections; TargetChooser(GameObserver *observer, MTGCardInstance * card = NULL, int _maxtargets = UNLITMITED_TARGETS, bool other = false, bool targetMin = false); Player * Owner; GameObserver *observer; @@ -48,7 +47,7 @@ public: bool validTargetsExist(int maxTarget = 1); int attemptsToFill; string belongsToAbility; - int countValidTargets(); + int countValidTargets(bool withoutProtections = false); virtual int setAllZones() { return 0; diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index 9626cd7a6..3e747f8d6 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -179,16 +179,16 @@ int AbilityFactory::parseCastRestrictions(MTGCardInstance * card, Player * playe rtc = comparasion[i].substr(foundType + 5, end - foundType - 5).c_str(); TargetChooserFactory tcf(observer); TargetChooser * ttc = tcf.createTargetChooser(rtc,card); - ttc->withoutProtections = true; mod = atoi(comparasion[i].substr(end+1).c_str()); + bool withoutProtections = true; if(i == 2) { - secondAmount = ttc->countValidTargets(); + secondAmount = ttc->countValidTargets(withoutProtections); secondAmount += mod; } else { - firstAmount = ttc->countValidTargets(); + firstAmount = ttc->countValidTargets(withoutProtections); firstAmount += mod; } diff --git a/projects/mtg/src/TargetChooser.cpp b/projects/mtg/src/TargetChooser.cpp index df9d73b31..7d7e75dce 100644 --- a/projects/mtg/src/TargetChooser.cpp +++ b/projects/mtg/src/TargetChooser.cpp @@ -919,7 +919,7 @@ bool TargetChooser::validTargetsExist(int maxTargets) return false; } -int TargetChooser::countValidTargets() +int TargetChooser::countValidTargets(bool withoutProtections) { int result = 0; @@ -943,7 +943,7 @@ int TargetChooser::countValidTargets() { for (int j = 0; j < z->nb_cards; j++) { - if (canTarget(z->cards[j])) result++; + if (canTarget(z->cards[j], withoutProtections)) result++; } } }