diff --git a/projects/mtg/bin/Res/test/_tests.txt b/projects/mtg/bin/Res/test/_tests.txt index 5e2363d05..59e29c5b8 100644 --- a/projects/mtg/bin/Res/test/_tests.txt +++ b/projects/mtg/bin/Res/test/_tests.txt @@ -232,6 +232,7 @@ scourge_of_kher_ridges2.txt sedge_sliver.txt seedcradle_witch.txt seismic_assault.txt +seismic_spike_i191.txt selesnya_guildmage.txt siege_gang_commander.txt shepherd_of_rot.txt diff --git a/projects/mtg/bin/Res/test/bugs/seismic_spike_i191.txt b/projects/mtg/bin/Res/test/seismic_spike_i191.txt similarity index 100% rename from projects/mtg/bin/Res/test/bugs/seismic_spike_i191.txt rename to projects/mtg/bin/Res/test/seismic_spike_i191.txt diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 3204b590e..aedf4c0b4 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -454,28 +454,7 @@ public: }; -class ActivatedAbilityTP:public ActivatedAbility{ -public: - int who; - ActivatedAbilityTP(int id, MTGCardInstance * card, Targetable * _target = NULL, ManaCost * cost=NULL, int doTap = 0, int who = TargetChooser::UNSET):ActivatedAbility(id,card,cost,0,doTap),who(who){ - if (_target) target = _target; - } - Targetable * getTarget(){ - switch(who){ - case TargetChooser::TARGET_CONTROLLER: - if (target) return ((MTGCardInstance *)target)->controller(); - return NULL; - case TargetChooser::CONTROLLER: - return source->controller(); - case TargetChooser::OPPONENT: - return source->controller()->opponent(); - default: - return target; - } - return NULL; - } -}; //Drawer, allows to draw a card for a cost: diff --git a/projects/mtg/include/MTGAbility.h b/projects/mtg/include/MTGAbility.h index 62f81e19a..79bdb2b0e 100644 --- a/projects/mtg/include/MTGAbility.h +++ b/projects/mtg/include/MTGAbility.h @@ -8,7 +8,6 @@ class GameObserver; class Spell; class Damageable; class PlayGuiObject; -class TargetChooser; class ManaCost; class MTGGameZone; class Player; @@ -20,6 +19,7 @@ class WEvent; #include #include #include "../include/Damage.h" +#include "../include/TargetChooser.h" using std::string; using std::map; @@ -217,7 +217,14 @@ class AbilityFactory{ }; -class AManaProducer: public MTGAbility{ +class ActivatedAbilityTP:public ActivatedAbility{ +public: + int who; + ActivatedAbilityTP(int id, MTGCardInstance * card, Targetable * _target = NULL, ManaCost * cost=NULL, int doTap = 0, int who = TargetChooser::UNSET); + Targetable * getTarget(); +}; + +class AManaProducer: public ActivatedAbilityTP{ protected: @@ -227,7 +234,7 @@ class AManaProducer: public MTGAbility{ public: ManaCost * output; int tap; - AManaProducer(int id, MTGCardInstance * card, ManaCost * _output, ManaCost * _cost = NULL, int doTap = 1 ); + AManaProducer(int id, MTGCardInstance * card, Targetable * t, ManaCost * _output, ManaCost * _cost = NULL, int doTap = 1, int who = TargetChooser::UNSET ); int isReactingToClick(MTGCardInstance * _card, ManaCost * mana = NULL); int resolve(); int reactToClick(MTGCardInstance * _card); diff --git a/projects/mtg/include/MTGCard.h b/projects/mtg/include/MTGCard.h index 3aecc062d..049d33366 100644 --- a/projects/mtg/include/MTGCard.h +++ b/projects/mtg/include/MTGCard.h @@ -2,7 +2,6 @@ #define _MTGCARD_H_ #define MTGCARD_NAME_SIZE 30 -#define MTGCARD_TEXT_SIZE 300 #define MTG_IMAGE_WIDTH 200 #define MTG_IMAGE_HEIGHT 285 diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index 5983db98f..0ea75894a 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -661,7 +661,9 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG found = s.find("add"); if (found != string::npos){ ManaCost * output = ManaCost::parseManaCost(s.substr(found)); - MTGAbility * a = NEW AManaProducer(id, target, output); + Targetable * t = NULL; + if (spell) t = spell->getNextPlayerTarget(); + MTGAbility * a = NEW AManaProducer(id, card, t, output, NULL, 1, who); a->oneShot = 1; return a; } @@ -1077,7 +1079,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){ case 1124: //Mana Vault { int output[] = {Constants::MTG_COLOR_ARTIFACT, 3}; - game->addObserver(NEW AManaProducer(_id,card,NEW ManaCost(output,1))); + game->addObserver(NEW AManaProducer(_id,card,card,NEW ManaCost(output,1))); int cost[] = {Constants::MTG_COLOR_ARTIFACT, 4}; game->addObserver(NEW AUntapManaBlocker(_id+1, card, NEW ManaCost(cost,1))); game->addObserver(NEW ARegularLifeModifierAura(_id+2, card, card, Constants::MTG_PHASE_DRAW, -1, 1)); @@ -2180,15 +2182,9 @@ GenericTriggeredAbility* GenericTriggeredAbility::clone() const{ //That means the player has to choose one. although that is perfect for cards such as birds of paradise or badlands, other solutions need to be provided for abilities that add mana (ex: mana flare) */ -/* - Currently the mana is added to the pool AFTER the animation - This is VERY BAD, since we don't have any control on the duration of the animation. This can lead to bugs with - the AI, who is expecting to have the mana in its manapool right after clicking the land card !!! - The sum of "dt" has to be 0.25 for the mana to be in the manapool currently -*/ -AManaProducer::AManaProducer(int id, MTGCardInstance * card, ManaCost * _output, ManaCost * _cost , int doTap):MTGAbility(id, card), tap(doTap){ +AManaProducer::AManaProducer(int id, MTGCardInstance * card, Targetable * t, ManaCost * _output, ManaCost * _cost , int doTap, int who):ActivatedAbilityTP(id, card,t,_cost,doTap,who){ LOG("==Creating ManaProducer Object"); aType = MTGAbility::MANA_PRODUCER; @@ -2212,9 +2208,18 @@ AManaProducer::AManaProducer(int id, MTGCardInstance * card, ManaCost * _output, } int AManaProducer::resolve(){ - controller = source->controller(); - controller->getManaPool()->add(output,source); - return 1; + Targetable * _target = getTarget(); + Player * player; + if (_target){ + if (_target->typeAsTarget() == TARGET_CARD){ + player = ((MTGCardInstance *)_target)->controller(); + }else{ + player = (Player *) _target; + } + player->getManaPool()->add(output,source); + return 1; + } + return 0; } int AManaProducer::reactToClick(MTGCardInstance * _card){ @@ -2291,3 +2296,22 @@ AManaProducer::AManaProducer(int id, MTGCardInstance * card, ManaCost * _output, } + + ActivatedAbilityTP::ActivatedAbilityTP(int id, MTGCardInstance * card, Targetable * _target, ManaCost * cost, int doTap, int who):ActivatedAbility(id,card,cost,0,doTap),who(who){ + if (_target) target = _target; + } + + Targetable * ActivatedAbilityTP::getTarget(){ + switch(who){ + case TargetChooser::TARGET_CONTROLLER: + if (target) return ((MTGCardInstance *)target)->controller(); + return NULL; + case TargetChooser::CONTROLLER: + return source->controller(); + case TargetChooser::OPPONENT: + return source->controller()->opponent(); + default: + return target; + } + return NULL; + }