From 2e928383647af7fbfda223261d2d47f9b51668a5 Mon Sep 17 00:00:00 2001 From: zethfoxster Date: Sat, 9 Jul 2016 11:38:25 -0400 Subject: [PATCH 1/7] fixed an issue with dredge, where dredge is offered even though theres only one dredger on cards that draw multiple. --- projects/mtg/src/MTGRules.cpp | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/projects/mtg/src/MTGRules.cpp b/projects/mtg/src/MTGRules.cpp index 1af7ac8bc..5da180505 100644 --- a/projects/mtg/src/MTGRules.cpp +++ b/projects/mtg/src/MTGRules.cpp @@ -2775,8 +2775,12 @@ WEvent * MTGDredgeRule::replace(WEvent * event) if (e->player == p) { int Dredgers = 0; + vectormenusOfferedWithDredge; for(int draw = 0;draw < e->nb_cards;draw++) { + tcb = tf.createTargetChooser("dredgeable", card); + int toDredge = tcb->countValidTargets(); + SAFE_DELETE(tcb); vectorselection; //look for other draw replacement effects list::iterator it; @@ -2800,17 +2804,16 @@ WEvent * MTGDredgeRule::replace(WEvent * event) } } + int Choices = int(selection.size()); //there is a memleak here that i have no idea what causes it. got it reduced to just 4 bytes but its still bothering me. - if (Dredgers < e->nb_cards) + if (int(menusOfferedWithDredge.size()) < toDredge) { tcb = tf.createTargetChooser("dredgeable", card); tcb->targetter = NULL; - dredgeAbility = NEW dredgeCard(game, game->mLayers->actionLayer()->getMaxId(), card, NULL); dredgeAbility->oneShot = true; dredgeAbility->canBeInterrupted = false; - targetAbility = NEW GenericTargetAbility(game, "Dredge A Card", "", game->mLayers->actionLayer()->getMaxId(), card, tcb->clone(), dredgeAbility->clone()); - SAFE_DELETE(tcb); + targetAbility = NEW GenericTargetAbility(game, "Dredge A Card", "", game->mLayers->actionLayer()->getMaxId(), card, tcb, dredgeAbility->clone()); SAFE_DELETE(dredgeAbility); targetAbility->oneShot = true; targetAbility->canBeInterrupted = false; @@ -2820,18 +2823,21 @@ WEvent * MTGDredgeRule::replace(WEvent * event) MTGAbility * setDredge = targetAbilityAdder->clone(); SAFE_DELETE(targetAbilityAdder); setDredge->oneShot = true; - selection.push_back(setDredge); - targetAbility1 = NEW AADrawer(game, this->GetId(), card, card, NULL, "1", TargetChooser::CONTROLLER, true); - targetAbility1->canBeInterrupted = false; - selection.push_back(targetAbility1); - MTGAbility * menuChoice = NEW MenuAbility(game, this->GetId(), card, card, true, selection, card->controller(), "Dredge or Draw"); - - menuChoice->addToGame(); - } + targetAbility1 = NEW AADrawer(game, this->GetId(), card, card, NULL, "1", TargetChooser::CONTROLLER, true); + targetAbility1->canBeInterrupted = false; + selection.push_back(targetAbility1); + MTGAbility * menuChoice = NEW MenuAbility(game, this->GetId(), card, card, true, selection, card->controller(), "Dredge or Draw"); + menusOfferedWithDredge.push_back(menuChoice); } - + + while (menusOfferedWithDredge.size()) + { + menusOfferedWithDredge[0]->addToGame(); + menusOfferedWithDredge.erase(menusOfferedWithDredge.begin()); + } + SAFE_DELETE(event); return event; } From a8cbdafe6ebe76ac68ebb806159e17e38e4e3061 Mon Sep 17 00:00:00 2001 From: zethfoxster Date: Sat, 9 Jul 2016 13:12:58 -0400 Subject: [PATCH 2/7] unused variables. --- projects/mtg/src/MTGRules.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/projects/mtg/src/MTGRules.cpp b/projects/mtg/src/MTGRules.cpp index 5da180505..2cab2b17f 100644 --- a/projects/mtg/src/MTGRules.cpp +++ b/projects/mtg/src/MTGRules.cpp @@ -2774,7 +2774,6 @@ WEvent * MTGDredgeRule::replace(WEvent * event) Player * p = game->players[i]; if (e->player == p) { - int Dredgers = 0; vectormenusOfferedWithDredge; for(int draw = 0;draw < e->nb_cards;draw++) { @@ -2804,7 +2803,6 @@ WEvent * MTGDredgeRule::replace(WEvent * event) } } - int Choices = int(selection.size()); //there is a memleak here that i have no idea what causes it. got it reduced to just 4 bytes but its still bothering me. if (int(menusOfferedWithDredge.size()) < toDredge) { From d247c53136c42e24e950b0e843111c8420306178 Mon Sep 17 00:00:00 2001 From: zethfoxster Date: Sat, 9 Jul 2016 17:55:08 -0400 Subject: [PATCH 3/7] edge case fix, the issue arises from castcard but I'm fixing it at a higher level since init to zone should always have a valid "player 1" in its first constructor. --- projects/mtg/bin/Res/player/premade/deck1.txt | 18 +++--------------- projects/mtg/bin/Res/sets/primitives/mtg.txt | 15 +++++---------- projects/mtg/bin/Res/test/_tests.txt | 1 + projects/mtg/src/MTGGameZones.cpp | 6 +++++- 4 files changed, 14 insertions(+), 26 deletions(-) diff --git a/projects/mtg/bin/Res/player/premade/deck1.txt b/projects/mtg/bin/Res/player/premade/deck1.txt index ef32db48a..9d374e7ad 100644 --- a/projects/mtg/bin/Res/player/premade/deck1.txt +++ b/projects/mtg/bin/Res/player/premade/deck1.txt @@ -1,19 +1,7 @@ #NAME:Premade G/R #DESC:A Red/Green deck with simple mechanics to get you started. We recommend you create your own decks to get the full Wagic experience! -Forest (10E) *11 -Mountain (10E) *12 - -Aggressive Urge (10E) *4 -Wall of Wood (10E) *4 -Llanowar Elves (10E) *4 -Mirri, Cat Warrior (10E) -Scion of the Wild (10E) *4 -Primal Rage (10E) *2 - -Lightning Elemental (10E) *4 -Shock (10E) *4 -Firebreathing (10E) *2 -Raging Goblin (10E) *4 -Anaba Bodyguard (10E) *4 +arbor elf *25 +Arbiter of Knollridge *13 +Arbor Colossus *13 diff --git a/projects/mtg/bin/Res/sets/primitives/mtg.txt b/projects/mtg/bin/Res/sets/primitives/mtg.txt index 508697533..ab02f2be9 100644 --- a/projects/mtg/bin/Res/sets/primitives/mtg.txt +++ b/projects/mtg/bin/Res/sets/primitives/mtg.txt @@ -4288,20 +4288,15 @@ toughness=5 [/card] [card] name=Arbor Colossus -abilities=reach -auto=this(cantargetcard(*[-monstrous]) {3}{G}{G}{G}:becomes(monstrous) forever && counter(1/1,3) && transforms((,newAbility[destroy target(creature[flying]|opponentbattlefield)])) forever -text=Reach -- {3}{G}{G}{G}: Monstrosity 3. (If this creature isn't monstrous, put three +1/+1 counters on it and it becomes monstrous.) -- When Arbor Colossus becomes monstrous, destroy target creature with flying an opponent controls -mana={2}{G}{G}{G} -type=Creature -subtype=Giant -power=6 -toughness=6 +auto=draw:2 +type=instant [/card] [card] name=Arbor Elf -auto={t}:untap target(forest) +autohand={0}:name(Control Magic) activate castcard(normal named!:Control Magic:!) text={T}: Untap target Forest. -mana={G} +mana={g} +dredge=dredge(2) type=Creature subtype=Elf Druid power=1 diff --git a/projects/mtg/bin/Res/test/_tests.txt b/projects/mtg/bin/Res/test/_tests.txt index dc83fac83..b8cfe6b9c 100644 --- a/projects/mtg/bin/Res/test/_tests.txt +++ b/projects/mtg/bin/Res/test/_tests.txt @@ -1,3 +1,4 @@ +savor the moment.txt ######################## #Internal tests ######################## diff --git a/projects/mtg/src/MTGGameZones.cpp b/projects/mtg/src/MTGGameZones.cpp index 8e995dd69..5e664c3f8 100644 --- a/projects/mtg/src/MTGGameZones.cpp +++ b/projects/mtg/src/MTGGameZones.cpp @@ -980,7 +980,11 @@ void MTGInPlay::untapAll() MTGGameZone * MTGGameZone::intToZone(int zoneId, Player * p, Player * p2) { - + if (p2 != p && p2 && (p != p2->opponent())) + { + p = p2->opponent(); + //these cases are generally handled this is a edge case fix. + } switch (zoneId) { case MY_GRAVEYARD: From 78e4407c717fca08a8d4da2cb0027ef821dd4240 Mon Sep 17 00:00:00 2001 From: zethfox Date: Sat, 9 Jul 2016 18:21:52 -0400 Subject: [PATCH 4/7] Revert "edge case fix, the issue arises from castcard but I'm fixing it at a higher level since init to zone should always have a valid "player 1" in its first constructor." This reverts commit d247c53136c42e24e950b0e843111c8420306178. --- projects/mtg/bin/Res/player/premade/deck1.txt | 18 +++++++++++++++--- projects/mtg/bin/Res/sets/primitives/mtg.txt | 15 ++++++++++----- projects/mtg/bin/Res/test/_tests.txt | 1 - projects/mtg/src/MTGGameZones.cpp | 6 +----- 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/projects/mtg/bin/Res/player/premade/deck1.txt b/projects/mtg/bin/Res/player/premade/deck1.txt index 9d374e7ad..ef32db48a 100644 --- a/projects/mtg/bin/Res/player/premade/deck1.txt +++ b/projects/mtg/bin/Res/player/premade/deck1.txt @@ -1,7 +1,19 @@ #NAME:Premade G/R #DESC:A Red/Green deck with simple mechanics to get you started. We recommend you create your own decks to get the full Wagic experience! -arbor elf *25 +Forest (10E) *11 +Mountain (10E) *12 + +Aggressive Urge (10E) *4 +Wall of Wood (10E) *4 +Llanowar Elves (10E) *4 +Mirri, Cat Warrior (10E) +Scion of the Wild (10E) *4 +Primal Rage (10E) *2 + +Lightning Elemental (10E) *4 +Shock (10E) *4 +Firebreathing (10E) *2 +Raging Goblin (10E) *4 +Anaba Bodyguard (10E) *4 -Arbiter of Knollridge *13 -Arbor Colossus *13 diff --git a/projects/mtg/bin/Res/sets/primitives/mtg.txt b/projects/mtg/bin/Res/sets/primitives/mtg.txt index ab02f2be9..508697533 100644 --- a/projects/mtg/bin/Res/sets/primitives/mtg.txt +++ b/projects/mtg/bin/Res/sets/primitives/mtg.txt @@ -4288,15 +4288,20 @@ toughness=5 [/card] [card] name=Arbor Colossus -auto=draw:2 -type=instant +abilities=reach +auto=this(cantargetcard(*[-monstrous]) {3}{G}{G}{G}:becomes(monstrous) forever && counter(1/1,3) && transforms((,newAbility[destroy target(creature[flying]|opponentbattlefield)])) forever +text=Reach -- {3}{G}{G}{G}: Monstrosity 3. (If this creature isn't monstrous, put three +1/+1 counters on it and it becomes monstrous.) -- When Arbor Colossus becomes monstrous, destroy target creature with flying an opponent controls +mana={2}{G}{G}{G} +type=Creature +subtype=Giant +power=6 +toughness=6 [/card] [card] name=Arbor Elf -autohand={0}:name(Control Magic) activate castcard(normal named!:Control Magic:!) +auto={t}:untap target(forest) text={T}: Untap target Forest. -mana={g} -dredge=dredge(2) +mana={G} type=Creature subtype=Elf Druid power=1 diff --git a/projects/mtg/bin/Res/test/_tests.txt b/projects/mtg/bin/Res/test/_tests.txt index b8cfe6b9c..dc83fac83 100644 --- a/projects/mtg/bin/Res/test/_tests.txt +++ b/projects/mtg/bin/Res/test/_tests.txt @@ -1,4 +1,3 @@ -savor the moment.txt ######################## #Internal tests ######################## diff --git a/projects/mtg/src/MTGGameZones.cpp b/projects/mtg/src/MTGGameZones.cpp index 5e664c3f8..8e995dd69 100644 --- a/projects/mtg/src/MTGGameZones.cpp +++ b/projects/mtg/src/MTGGameZones.cpp @@ -980,11 +980,7 @@ void MTGInPlay::untapAll() MTGGameZone * MTGGameZone::intToZone(int zoneId, Player * p, Player * p2) { - if (p2 != p && p2 && (p != p2->opponent())) - { - p = p2->opponent(); - //these cases are generally handled this is a edge case fix. - } + switch (zoneId) { case MY_GRAVEYARD: From fdde5b7fe90b78b027046ec2639f77914f125d53 Mon Sep 17 00:00:00 2001 From: zethfoxster Date: Sat, 9 Jul 2016 18:57:01 -0400 Subject: [PATCH 5/7] ok round 3 --- projects/mtg/src/MTGGameZones.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/projects/mtg/src/MTGGameZones.cpp b/projects/mtg/src/MTGGameZones.cpp index 8e995dd69..5e664c3f8 100644 --- a/projects/mtg/src/MTGGameZones.cpp +++ b/projects/mtg/src/MTGGameZones.cpp @@ -980,7 +980,11 @@ void MTGInPlay::untapAll() MTGGameZone * MTGGameZone::intToZone(int zoneId, Player * p, Player * p2) { - + if (p2 != p && p2 && (p != p2->opponent())) + { + p = p2->opponent(); + //these cases are generally handled this is a edge case fix. + } switch (zoneId) { case MY_GRAVEYARD: From c4581a8889a324a3860dbf7932c4494a91dde393 Mon Sep 17 00:00:00 2001 From: zethfoxster Date: Sat, 9 Jul 2016 20:20:55 -0400 Subject: [PATCH 6/7] added imprintedcard as a usable name for castcard --- projects/mtg/src/AllAbilities.cpp | 7 +++++++ projects/mtg/src/MTGAbility.cpp | 9 ++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index 6b84b1c13..af883cebe 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -7189,6 +7189,13 @@ void AACastCard::Update(float dt) return; if(cardNamed.size() && !theNamedCard) { + if (cardNamed.find("imprintedcard") != string::npos) + { + if (source && source->currentimprintName.size()) + { + cardNamed = source->currentimprintName; + } + } theNamedCard = makeCard(); } if(putinplay) diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index 49eeab63a..dbd525a22 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -2503,9 +2503,12 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG found = s.find("imprint"); if (found != string::npos) { - MTGAbility * a = NEW AAImprint(observer, id, card, target); - a->oneShot = 1; - return a; + if (s.find("imprintedcard") == string::npos) + { + MTGAbility * a = NEW AAImprint(observer, id, card, target); + a->oneShot = 1; + return a; + } } //phaseout From 8b70f5a1149110a91ca2d3171216f541a07986f1 Mon Sep 17 00:00:00 2001 From: zethfoxster Date: Sat, 9 Jul 2016 20:21:40 -0400 Subject: [PATCH 7/7] added isochron and spell binder --- projects/mtg/bin/Res/sets/primitives/mtg.txt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/projects/mtg/bin/Res/sets/primitives/mtg.txt b/projects/mtg/bin/Res/sets/primitives/mtg.txt index 508697533..2a7fee682 100644 --- a/projects/mtg/bin/Res/sets/primitives/mtg.txt +++ b/projects/mtg/bin/Res/sets/primitives/mtg.txt @@ -54596,6 +54596,14 @@ power=4 toughness=8 [/card] [card] +name=Isochron Scepter +auto=may imprint notatarget(instant[manacost<=2]|myhand) +auto={2}{t}:activate castcard(copied noevent named!:imprintedcard:!) +text=Imprint — When Isochron Scepter enters the battlefield, you may exile an instant card with converted mana cost 2 or less from your hand. -- {2}, {T}: You may copy the exiled card. If you do, you may cast the copy without paying its mana cost. +mana={2} +type=Artifact +[/card] +[card] name=Isolated Chapel auto=aslongas(plains,swamp|myBattlefield) tap(noevent) <1 oneshot auto={T}:Add{W} @@ -102430,6 +102438,16 @@ power=2 toughness=2 [/card] [card] +name=Spellbinder +auto={4}:equip +auto=may imprint notatarget(instant|myhand) +auto=@combatdamaged(player) from(mytgt):activate castcard(copied noevent named!:imprintedcard:!) +text=Imprint — When Spellbinder enters the battlefield, you may exile an instant card from your hand. -- Whenever equipped creature deals combat damage to a player, you may copy the exiled card. If you do, you may cast the copy without paying its mana cost. -- Equip {4} +mana={3} +type=Artifact +subtype=Equipment +[/card] +[card] name=Spell Blast target=*[manacost=prex]|stack auto=fizzle