Psyringe - added quantifiable target restrictions. Whenever you use square brackets [] to specify attributes of a target, you can use the operators <=, >= and = to specify quantities for power, toughness, and/or converted manacost. See added cards for examples.
Limitations: - Operators for "greater than", "less than", "unequal" have not been implemented, but if a card actually needs them, you can use a preceding minus sign to negate a comparison. Example: -power=3 means "power not equal to 3", -toughness<=3 means "toughness>3". - You can't use spaces when specifying such restrictions. Write "power<=3" instead of "power <= 3" - You now need to use a space before the "<" and ">" commands that count the matches for lord(), foreach(), all() and aslongas(). So far we always did use spaces in front of them without actually needing to, now we need to. - manacost restrictions don't take "X" costs into account. Example: Mistmeadow Skulkin (FUT) has protection from manacost>=3. Blaze has a converted manacost of 1, but when you cast it with an X of 2, then it actually has a converted manacost of 3 while on the stack, and Mistmeadow Skulkin would be protected from it, but currently it isn't. Please review the code, I'll add a few remarks/questions of my own.
This commit is contained in:
@@ -3,9 +3,14 @@
|
||||
#include "../include/Subtypes.h"
|
||||
#include "../include/Counters.h"
|
||||
|
||||
|
||||
CardDescriptor::CardDescriptor(): MTGCardInstance(){
|
||||
init();
|
||||
mode = CD_AND;
|
||||
powerComparisonMode = COMPARISON_NONE;
|
||||
toughnessComparisonMode = COMPARISON_NONE;
|
||||
manacostComparisonMode = COMPARISON_NONE;
|
||||
convertedManacost = -1;
|
||||
}
|
||||
|
||||
int CardDescriptor::init(){
|
||||
@@ -29,6 +34,26 @@ void CardDescriptor::setNegativeSubtype( string value){
|
||||
addType(-id);
|
||||
}
|
||||
|
||||
// Very generic function to compare a value to a criterion.
|
||||
// Should be easily transferable to a more generic class if desired.
|
||||
bool CardDescriptor::valueInRange(int comparisonMode, int value, int criterion){
|
||||
switch (comparisonMode){
|
||||
case COMPARISON_AT_MOST:
|
||||
return (value <= criterion);
|
||||
case COMPARISON_AT_LEAST:
|
||||
return (value >= criterion);
|
||||
case COMPARISON_EQUAL:
|
||||
return (value == criterion);
|
||||
case COMPARISON_GREATER:
|
||||
return (value > criterion);
|
||||
case COMPARISON_LESS:
|
||||
return (value < criterion);
|
||||
case COMPARISON_UNEQUAL:
|
||||
return (value != criterion);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
MTGCardInstance * CardDescriptor::match_or(MTGCardInstance * card){
|
||||
int found = 1;
|
||||
for (int i = 0; i< nb_types; i++){
|
||||
@@ -65,6 +90,12 @@ MTGCardInstance * CardDescriptor::match_or(MTGCardInstance * card){
|
||||
}
|
||||
}
|
||||
if (!found) return NULL;
|
||||
|
||||
// Quantified restrictions are always AND-ed:
|
||||
if (powerComparisonMode && !valueInRange(powerComparisonMode, card->getPower(), power) ) return NULL;
|
||||
if (toughnessComparisonMode && !valueInRange(toughnessComparisonMode, card->getToughness(), toughness) ) return NULL;
|
||||
if (manacostComparisonMode && !valueInRange(manacostComparisonMode, card->getManaCost()->getConvertedCost(), convertedManacost) ) return NULL;
|
||||
|
||||
return card;
|
||||
}
|
||||
|
||||
@@ -86,6 +117,11 @@ 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 (manacostComparisonMode && !valueInRange(manacostComparisonMode, card->getManaCost()->getConvertedCost(), convertedManacost) ) match = NULL;
|
||||
|
||||
return match;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user