diff --git a/projects/mtg/bin/Res/test/_tests.txt b/projects/mtg/bin/Res/test/_tests.txt index 00cb00ed0..85c24b334 100644 --- a/projects/mtg/bin/Res/test/_tests.txt +++ b/projects/mtg/bin/Res/test/_tests.txt @@ -155,6 +155,7 @@ death_grasp.txt death_ward.txt deja_vu.txt dingus_egg.txt +divergent_growth.txt doomed_necromancer.txt double_strike_i145.txt double_strike2_i145.txt diff --git a/projects/mtg/bin/Res/test/divergent_growth.txt b/projects/mtg/bin/Res/test/divergent_growth.txt new file mode 100644 index 000000000..68630a432 --- /dev/null +++ b/projects/mtg/bin/Res/test/divergent_growth.txt @@ -0,0 +1,21 @@ +#Bug Divergent growth +#see http://code.google.com/p/wagic/issues/detail?id=243 +[INIT] +FIRSTMAIN +[PLAYER1] +hand:divergent growth +manapool:{G} +inplay:forest +[PLAYER2] +[DO] +divergent growth +forest +choice 2 +[ASSERT] +FIRSTMAIN +[PLAYER1] +graveyard:divergent growth +inplay:forest +manapool:{W} +[PLAYER2] +[END] \ No newline at end of file diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 1a081efdf..5d636612e 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -1366,7 +1366,30 @@ class APowerToughnessModifierUntilEndOfTurn: public ActivatedAbility{ }; +class GenericInstantAbility: public InstantAbility{ + public: + MTGAbility * ability; + GenericInstantAbility(int _id, MTGCardInstance * _source, Damageable * _target, MTGAbility * ability): InstantAbility(_id, _source, _target), ability(ability){ + } + int addToGame(){ + ability->forceDestroy = -1; + ability->addToGame(); + return InstantAbility::addToGame(); + } + + int destroy(){ + ability->forceDestroy = 0; + return InstantAbility::destroy(); + } + + GenericInstantAbility * clone() const{ + GenericInstantAbility * a = NEW GenericInstantAbility(*this); + a->isClone = 1; + return a; + } + +}; //Untap Blockers with simple Mana Mechanism @@ -1785,8 +1808,13 @@ class ALord:public ListMaintainerAbility{ if (d->type_as_damageable == DAMAGEABLE_MTGCARDINSTANCE){ a->source = (MTGCardInstance *)d; } - a->addToGame(); - abilities[d] = a; + if (oneShot){ + MTGAbility * wrapper = NEW GenericInstantAbility(1,source,d,a); + wrapper->addToGame(); + }else{ + a->addToGame(); + abilities[d] = a; + } } return 1; } diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index 796c107e4..b2e38806d 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -2247,7 +2247,6 @@ AManaProducer::AManaProducer(int id, MTGCardInstance * card, Targetable * t, Man AManaProducer::~AManaProducer(){ - if (isClone) return; LOG("==Destroying ManaProducer Object"); SAFE_DELETE(cost); SAFE_DELETE(output); @@ -2256,6 +2255,10 @@ AManaProducer::AManaProducer(int id, MTGCardInstance * card, Targetable * t, Man AManaProducer * AManaProducer::clone() const{ AManaProducer * a = NEW AManaProducer(*this); + a->cost = NEW ManaCost(); + a->output = NEW ManaCost(); + a->cost->copy(cost); + a->output->copy(output); a->isClone = 1; return a; } diff --git a/projects/mtg/src/ManaCost.cpp b/projects/mtg/src/ManaCost.cpp index f647d2c99..69dee2f70 100644 --- a/projects/mtg/src/ManaCost.cpp +++ b/projects/mtg/src/ManaCost.cpp @@ -153,6 +153,7 @@ void ManaCost::init(){ void ManaCost::copy(ManaCost * _manaCost){ + if (!_manaCost) return; for (unsigned int i = 0; i <= Constants::MTG_NB_COLORS; i++){ cost[i] = _manaCost->getCost(i); }