From f6199719fd1b9c807b88ac5cd1f05a83322c5ce4 Mon Sep 17 00:00:00 2001 From: Vittorio Alfieri Date: Sun, 24 Jan 2021 15:53:49 +0100 Subject: [PATCH] Fixed issues #1049 and #1050 opened by @ranger7271, improved imprint keywords, improved boast ability, added a new "hasability" keyword to check if a card has an ability or not. --- .../mtg/bin/Res/sets/primitives/borderline.txt | 9 ++++----- projects/mtg/include/AllAbilities.h | 1 + projects/mtg/include/MTGDefinitions.h | 3 ++- projects/mtg/src/AllAbilities.cpp | 15 +++++++++++++++ projects/mtg/src/MTGAbility.cpp | 7 +++++++ projects/mtg/src/MTGDefinitions.cpp | 3 ++- projects/mtg/src/TargetChooser.cpp | 10 ++++++++++ projects/mtg/src/WParsedInt.cpp | 15 +++++++++++++-- 8 files changed, 54 insertions(+), 9 deletions(-) diff --git a/projects/mtg/bin/Res/sets/primitives/borderline.txt b/projects/mtg/bin/Res/sets/primitives/borderline.txt index 8be760835..f7385de50 100644 --- a/projects/mtg/bin/Res/sets/primitives/borderline.txt +++ b/projects/mtg/bin/Res/sets/primitives/borderline.txt @@ -9625,7 +9625,7 @@ type=Land [card] name=Corsair Captain auto=token(Treasure Sur) -auto=all(other creature[pirate]|mybattlefield) 1/1 +auto=lord(other creature[pirate]|mybattlefield) 1/1 text=When Corsair Captain enters the battlefield, create a Treasure token. (It's an artifact with " {T}, Sacrifice this artifact: Add one mana of any color.") -- Other Pirates you control get +1/+1. mana={2}{U} type=Creature @@ -47601,7 +47601,8 @@ toughness=2 [card] name=Stormsurge Kraken abilities=opponentshroud -#wagic doesnt have commander zone +auto=aslongas(*[iscommander]|mybattlefield) 2/2 >0 +auto=@combat(blocked) source(this) restriction{type(*[iscommander]|myBattlefield)~morethan~0}:may name(Draw 2 cards) draw:2 controller text=Hexproof -- Lieutenant — As long as you control your commander, Stormsurge Kraken gets +2/+2 and has "Whenever Stormsurge Kraken becomes blocked, you may draw two cards." mana={3}{U}{U} type=Creature @@ -53445,9 +53446,7 @@ type=Instant [/card] [card] name=Vanquisher's Banner -auto=choseatype -auto=@movedTo(creature[chosentype]|mystack):draw:1 controller -auto=lord(creature[chosentype]|mybattlefield) 1/1 +auto=chooseatype all(this) transforms((,newability[lord(creature[chosentype]|mybattlefield) 1/1],newability[@movedTo(creature[chosentype]|mystack):draw:1 controller])) forever chooseend text=As Vanquisher's Banner enters the battlefield, choose a creature type. -- Creatures you control of the chosen type get +1/+1. -- Whenever you cast a creature spell of the chosen type, draw a card. mana={5} type=Artifact diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 46445b8db..c3e8ffaf9 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -1399,6 +1399,7 @@ public: class AAImprint: public ActivatedAbility { public: + MTGAbility * andAbility; AAImprint(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target = NULL, ManaCost * _cost = NULL); int resolve(); const string getMenuText(); diff --git a/projects/mtg/include/MTGDefinitions.h b/projects/mtg/include/MTGDefinitions.h index 5d4b1d9f2..882c6443b 100644 --- a/projects/mtg/include/MTGDefinitions.h +++ b/projects/mtg/include/MTGDefinitions.h @@ -301,7 +301,8 @@ class Constants FORETELL = 174, ANYTYPEOFMANAABILITY = 175, BOAST = 176, - NB_BASIC_ABILITIES = 177, + TWOBOAST = 177, + NB_BASIC_ABILITIES = 178, RARITY_S = 'S', //Special Rarity RARITY_M = 'M', //Mythics diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index 8a98aeeb1..b12737e1f 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -2048,6 +2048,7 @@ AAImprint::AAImprint(GameObserver* observer, int _id, MTGCardInstance * _source, ActivatedAbility(observer, _id, _source, _cost, 0) { target = _target; + andAbility = NULL; } int AAImprint::resolve() @@ -2083,6 +2084,20 @@ int AAImprint::resolve() source->imprintedNames.push_back(source->imprintedCards.back()->getName()); } } + if(andAbility) + { + MTGAbility * andAbilityClone = andAbility->clone(); + andAbilityClone->target = _target; + if(andAbility->oneShot) + { + andAbilityClone->resolve(); + SAFE_DELETE(andAbilityClone); + } + else + { + andAbilityClone->addToGame(); + } + } return 1; } return 0; diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index 1f48056cd..3cf73e604 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -3165,6 +3165,13 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG { MTGAbility * a = NEW AAImprint(observer, id, card, target); a->oneShot = 1; + //andability + if(storedAndAbility.size()) + { + string stored = storedAndAbility; + storedAndAbility.clear(); + ((AAImprint*)a)->andAbility = parseMagicLine(stored, id, spell, card); + } return a; } } diff --git a/projects/mtg/src/MTGDefinitions.cpp b/projects/mtg/src/MTGDefinitions.cpp index d61df18c0..3f2cc2709 100644 --- a/projects/mtg/src/MTGDefinitions.cpp +++ b/projects/mtg/src/MTGDefinitions.cpp @@ -207,7 +207,8 @@ const char* Constants::MTGBasicAbilities[] = { "cycling", //It has cycling ability "foretell", //It has foretell cost "anytypeofmanaability", //It allows to spend mana as it were of any color to activate abilities. - "boast" //It has boast ability + "boast", //It has boast ability + "twoboast" //It has boast twice ability (e.g. Birgi, God of Storytelling) }; map Constants::MTGBasicAbilitiesMap; diff --git a/projects/mtg/src/TargetChooser.cpp b/projects/mtg/src/TargetChooser.cpp index e93f55de1..317df0b69 100644 --- a/projects/mtg/src/TargetChooser.cpp +++ b/projects/mtg/src/TargetChooser.cpp @@ -953,6 +953,16 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta } } + if (attribute.find("evictname") != string::npos && card->imprintedCards.size()) + { + attributefound = 1; + cd->compareName = card->currentimprintName; + if (minus) + cd->nameComparisonMode = COMPARISON_UNEQUAL; + else + cd->nameComparisonMode = COMPARISON_EQUAL; + } + if (!attributefound) { //Abilities diff --git a/projects/mtg/src/WParsedInt.cpp b/projects/mtg/src/WParsedInt.cpp index 3856a41f3..916555fed 100644 --- a/projects/mtg/src/WParsedInt.cpp +++ b/projects/mtg/src/WParsedInt.cpp @@ -438,6 +438,14 @@ void WParsedInt::init(string s, Spell * spell, MTGCardInstance * card) { intValue = (s == "pnumofcommandcast")?card->controller()->numOfCommandCast:card->controller()->opponent()->numOfCommandCast; } + else if (s == "isflipped" || s == "iscopied") // Return 1 if card has been flipped -- Return 1 if card has copied another card + { + intValue = (s == "isflipped")?card->isFlipped:card->isACopier; + } + else if (s == "evictmc" || s == "hasevict") + { + if(card->imprintedCards.size() > 0) intValue = (s == "evictmc")?card->imprintedCards.back()->getManaCost()->getConvertedCost():card->imprintedCards.size(); + } else if (s == "evictpw" || s == "evictth") { if(card->imprintedCards.size() > 0) intValue = (s == "evictpw")?card->imprintedCards.back()->getPower():card->imprintedCards.back()->getToughness(); @@ -563,9 +571,12 @@ void WParsedInt::init(string s, Spell * spell, MTGCardInstance * card) { intValue = (target->foretellTurn < 0)?0:(target->getObserver()->turn-target->foretellTurn); // Check if you can use the foretell cost from exile (CurrentTurn > ForetellTurn). } - else if (s == "isflipped") // Return 1 if card has been flipped + else if (s.find("hasability") != string::npos) //Return 1 if card has the specified ability { - intValue = card->isFlipped; + intValue = 0; + for(size_t i = 0; i < Constants::NB_BASIC_ABILITIES; i++) + if(Constants::MTGBasicAbilities[i] == s.substr(10)) + intValue = card->basicAbilities[i]; } else if (s == "manacost") //Return the converted manacost {