From 0a0c541f07516905f12b789cdbbd2afa22bb576a Mon Sep 17 00:00:00 2001 From: Vittorio Alfieri Date: Mon, 15 May 2023 23:04:24 +0200 Subject: [PATCH] Now it's possible to use toughness target filtering even for planeswalkers and battles, added some new primitives from MOM set. --- .../bin/Res/sets/primitives/borderline.txt | 25 ++++++++++++++++- projects/mtg/src/CardDescriptor.cpp | 28 ++++++++++++++++--- 2 files changed, 48 insertions(+), 5 deletions(-) diff --git a/projects/mtg/bin/Res/sets/primitives/borderline.txt b/projects/mtg/bin/Res/sets/primitives/borderline.txt index 4589e8da1..d2a65e4f8 100644 --- a/projects/mtg/bin/Res/sets/primitives/borderline.txt +++ b/projects/mtg/bin/Res/sets/primitives/borderline.txt @@ -44180,7 +44180,7 @@ backside=Rooftop Saboteurs restriction=compare(isflipped)~equalto~0 anyzone={0}:doubleside(backside) auto=counter(0/0.4.Defense) -auto=ability$!name(Tap creature or artifact) name(Tap creature or artifact) target(*[creature;artifact]|opponentbattlefield) counter(0/0.1.Stun)!$ controller +auto=ability$!name(Tap creature or artifact) name(Tap creature or artifact) target(*[creature;artifact]|opponentbattlefield) transforms((,newability[tap],newability[counter(0/0.1.Stun)])) oneshot!$ controller auto=moveto(opponentbattlefield) auto=@counterremoved(0/0,1,Defense) from(this) restriction{compare(hascntdefense)~equalto~0}:name(Exile and transforms) name(Exile and transforms) moveto(ownerexile) and!( flip(backside) forcetype(Creature Moonfolk Ninja) )! asSorcery text=(As a Siege enters, choose an opponent to protect it. You and others can attack it. When it's defeated, exile it, then cast it transformed.) -- When Invasion of Kamigawa enters the battlefield, tap target artifact or creature an opponent controls and put a stun counter on it. (If a permanent with a stun counter would become untapped, remove one from it instead.) @@ -57050,6 +57050,19 @@ mana={1}{R} type=Instant [/card] [card] +name=Nahiri's Warcrafting +target=creature,planeswalker,battle +aicode=activate transforms((,newability[target(*[zpos<=3]|mylibrary) moveto(myexile) and!( transforms((,newability[canplayfromexile],newability[all(*[zpos<=3]|mylibrary) moveto(myreveal) and!( bottomoflibrary )!])) ueot )!])) oneshot +auto=if cantargetcard(*[toughness=1]|*) then name(Look top 4 cards) name(Look top 4 cards) reveal:4 optionone name(Exile a card) target(*|reveal) moveto(myexile) and!( transforms((,newability[canplayfromexile])) ueot )! optiononeend optiontwo name(Put on bottom) target(<1>*|reveal) bottomoflibrary and!( all(*|reveal) bottomoflibrary )! optiontwoend revealend +auto=if cantargetcard(*[toughness=2]|*) then name(Look top 3 cards) name(Look top 3 cards) reveal:3 optionone name(Exile a card) target(*|reveal) moveto(myexile) and!( transforms((,newability[canplayfromexile])) ueot )! optiononeend optiontwo name(Put on bottom) target(<1>*|reveal) bottomoflibrary and!( all(*|reveal) bottomoflibrary )! optiontwoend revealend +auto=if cantargetcard(*[toughness=3]|*) then name(Look top 2 cards) name(Look top 2 cards) reveal:2 optionone name(Exile a card) target(*|reveal) moveto(myexile) and!( transforms((,newability[canplayfromexile])) ueot )! optiononeend optiontwo name(Put on bottom) target(<1>*|reveal) bottomoflibrary and!( all(*|reveal) bottomoflibrary )! optiontwoend revealend +auto=if cantargetcard(*[toughness=4]|*) then name(Look top card) name(Look top card) reveal:1 optionone name(Exile a card) target(*|reveal) moveto(myexile) and!( transforms((,newability[canplayfromexile])) ueot )! optiononeend optiontwo name(Put on bottom) target(<1>*|reveal) bottomoflibrary and!( all(*|reveal) bottomoflibrary )! optiontwoend revealend +auto=damage:5 +text=Nahiri's Warcrafting deals 5 damage to target creature, planeswalker, or battle. Look at the top X cards of your library, where X is the excess damage dealt this way. You may exile one of those cards. Put the rest on the bottom of your library in a random order. You may play the exiled card this turn. +mana={1}{R}{R} +type=Sorcery +[/card] +[card] name=Naiad of Hidden Coves auto=aslongas opponentturnonly: (*|mycastingzone) changecost(colorless:-1) text=As long as it's not your turn, spells you cast cost {1} less to cast. @@ -74624,6 +74637,16 @@ power=1 toughness=1 [/card] [card] +name=Searing Barb +target=player,creature,planeswalker +auto=damage:2 +auto=if cantargetcard(*[creature]|*) then transforms((,newability[cantblock])) ueot +auto=name(Incubate 1) name(Incubate 1) activate castcard(noevent costx!:1:! named!:Incubator:!) +text=Searing Barb deals 2 damage to any target. If it's a creature, it can't block this turn. Incubate 1. (Create an Incubator token with a +1/+1 counter on it and "{2}: Transform this artifact." It transforms into a 0/0 Phyrexian artifact creature.) +mana={2}{R} +type=Sorcery +[/card] +[card] name=Searing Barrage target=creature auto=damage:5 diff --git a/projects/mtg/src/CardDescriptor.cpp b/projects/mtg/src/CardDescriptor.cpp index 8372eeab5..df8712e20 100644 --- a/projects/mtg/src/CardDescriptor.cpp +++ b/projects/mtg/src/CardDescriptor.cpp @@ -181,8 +181,18 @@ MTGCardInstance * CardDescriptor::match_or(MTGCardInstance * card) return NULL; if (powerComparisonMode && !valueInRange(powerComparisonMode, card->getPower(), power)) return NULL; - if (toughnessComparisonMode && !valueInRange(toughnessComparisonMode, card->getToughness(), toughness)) - return NULL; + if (toughnessComparisonMode){ // Toughness has different meaning for creatures, planeswalkers and battles + if(card->isCreature() && !valueInRange(toughnessComparisonMode, card->getToughness(), toughness)) + return NULL; + else if(card->counters && (card->hasType(Subtypes::TYPE_PLANESWALKER) || card->hasType(Subtypes::TYPE_BATTLE))){ + for(size_t i = 0; i < card->counters->counters.size(); ++i){ + if((card->counters->counters[i]->name == "loyalty" && card->hasType(Subtypes::TYPE_PLANESWALKER)) || (card->counters->counters[i]->name == "defense" && card->hasType(Subtypes::TYPE_BATTLE))){ + if(!valueInRange(toughnessComparisonMode, card->counters->counters[i]->nb, toughness)) + return NULL; + } + } + } + } if (manacostComparisonMode && !valueInRange(manacostComparisonMode, card->myconvertedcost, convertedManacost)) return NULL; if (zposComparisonMode && !valueInRange(zposComparisonMode, card->zpos, zposition)) @@ -229,8 +239,18 @@ MTGCardInstance * CardDescriptor::match_and(MTGCardInstance * card) match = NULL; if (powerComparisonMode && !valueInRange(powerComparisonMode, card->getPower(), power)) match = NULL; - if (toughnessComparisonMode && !valueInRange(toughnessComparisonMode, card->getToughness(), toughness)) - match = NULL; + if (toughnessComparisonMode){ // Toughness has different meaning for creatures, planeswalkers and battles + if(card->isCreature() && !valueInRange(toughnessComparisonMode, card->getToughness(), toughness)) + return NULL; + else if(card->counters && (card->hasType(Subtypes::TYPE_PLANESWALKER) || card->hasType(Subtypes::TYPE_BATTLE))){ + for(size_t i = 0; i < card->counters->counters.size(); ++i){ + if((card->counters->counters[i]->name == "loyalty" && card->hasType(Subtypes::TYPE_PLANESWALKER)) || (card->counters->counters[i]->name == "defense" && card->hasType(Subtypes::TYPE_BATTLE))){ + if(!valueInRange(toughnessComparisonMode, card->counters->counters[i]->nb, toughness)) + return NULL; + } + } + } + } if (manacostComparisonMode && !valueInRange(manacostComparisonMode, card->myconvertedcost, convertedManacost)) match = NULL; if (zposComparisonMode && !valueInRange(zposComparisonMode, card->zpos, zposition))