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:
Psyyringe
2009-12-26 01:50:33 +00:00
parent ddb9ce251b
commit 5c3b3f1d03
22 changed files with 276 additions and 81 deletions

View File

@@ -121,6 +121,40 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
nbminuses++;
attribute=attribute.substr(1);
}
int comparisonMode = COMPARISON_NONE;
int comparisonCriterion = 0;
if (attribute.size() > 1){
size_t operatorPosition = attribute.find("=",1);
if (operatorPosition != string::npos){
comparisonCriterion = atoi(attribute.substr(operatorPosition+1,attribute.size()-operatorPosition-1).c_str());
switch (attribute[operatorPosition-1]){
case '<':
if (minus){
comparisonMode = COMPARISON_GREATER;
}else{
comparisonMode = COMPARISON_AT_MOST;
}
operatorPosition--;
break;
case '>':
if (minus){
comparisonMode = COMPARISON_LESS;
}else{
comparisonMode = COMPARISON_AT_LEAST;
}
operatorPosition--;
break;
default:
if (minus){
comparisonMode = COMPARISON_UNEQUAL;
}else{
comparisonMode = COMPARISON_EQUAL;
}
}
attribute = attribute.substr(0,operatorPosition);
}
}
//Attacker
if (attribute.find("attacking") != string::npos){
if (minus){
@@ -142,6 +176,18 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
}else{
cd->unsecureSetTapped(1);
}
//Power restrictions
}else if (attribute.find("power") != string::npos){
cd->setPower(comparisonCriterion);
cd->powerComparisonMode = comparisonMode;
//Toughness restrictions
}else if (attribute.find("toughness") != string::npos){
cd->setToughness(comparisonCriterion);
cd->toughnessComparisonMode = comparisonMode;
//Manacost restrictions
}else if (attribute.find("manacost") != string::npos){
cd->convertedManacost = comparisonCriterion;
cd->manacostComparisonMode = comparisonMode;
}else{
int attributefound = 0;
//Colors
@@ -474,8 +520,6 @@ DescriptorTargetChooser::~DescriptorTargetChooser(){
CreatureTargetChooser::CreatureTargetChooser( MTGCardInstance * card, int _maxtargets, bool other):TargetZoneChooser(card, _maxtargets, other){
int default_zones[] = {MTGGameZone::MY_BATTLEFIELD, MTGGameZone::OPPONENT_BATTLEFIELD};
init(default_zones,2);
maxpower= -1;
maxtoughness= -1;
}
CreatureTargetChooser::CreatureTargetChooser(int * _zones, int nbzones, MTGCardInstance * card, int _maxtargets, bool other):TargetZoneChooser(card, _maxtargets, other){
@@ -485,8 +529,6 @@ CreatureTargetChooser::CreatureTargetChooser(int * _zones, int nbzones, MTGCardI
}else{
init(_zones, nbzones);
}
maxpower = -1;
maxtoughness= -1;
}
@@ -494,8 +536,6 @@ bool CreatureTargetChooser::canTarget(Targetable * target){
if (!TargetZoneChooser::canTarget(target)) return false;
if (target->typeAsTarget() == TARGET_CARD){
MTGCardInstance * card = (MTGCardInstance *) target;
if (maxpower != -1 && card->power > maxpower) return false;
if (maxtoughness != -1 && card->toughness > maxtoughness) return false;
return card->isCreature();
}
return false;