Fixed some primitives, added new primitives from MAT set, improved filter for multicolored cards, added new keywords for handling multicolored cards.

This commit is contained in:
Vittorio Alfieri
2023-05-24 15:15:52 +02:00
parent 675705a6e5
commit 09f4c408cd
6 changed files with 292 additions and 32 deletions

File diff suppressed because one or more lines are too long

View File

@@ -45,6 +45,8 @@ class CardDescriptor: public MTGCardInstance
int convertedManacost; // might fit better into MTGCardInstance?
int zposComparisonMode;
int zposition;
int numofColorsComparisonMode;
int numofColors;
int hasKickerCost;
int hasConvokeCost;
int hasFlashbackCost;

View File

@@ -4,6 +4,7 @@
#include "Subtypes.h"
#include "Counters.h"
#include "ExtraCost.h"
#include "WParsedInt.h"
CardDescriptor::CardDescriptor()
: MTGCardInstance(), mColorExclusions(0)
@@ -21,6 +22,8 @@ CardDescriptor::CardDescriptor()
manacostComparisonMode = COMPARISON_NONE;
counterComparisonMode = COMPARISON_NONE;
convertedManacost = -1;
numofColorsComparisonMode = COMPARISON_NONE;
numofColors = -1;
zposComparisonMode = COMPARISON_NONE;
zposition = -1;
hasKickerCost = 0;
@@ -199,6 +202,16 @@ MTGCardInstance * CardDescriptor::match_or(MTGCardInstance * card)
} else if(!valueInRange(toughnessComparisonMode, card->getToughness(), toughness))
return NULL;
}
if (numofColorsComparisonMode){
int totalcolor = 0;
WParsedInt* value = NEW WParsedInt("mycolnum", NULL, card);
if(value){
totalcolor = value->getValue();
SAFE_DELETE(value);
}
if(!valueInRange(numofColorsComparisonMode, totalcolor, numofColors))
return NULL;
}
if (manacostComparisonMode && !valueInRange(manacostComparisonMode, card->myconvertedcost, convertedManacost))
return NULL;
if (zposComparisonMode && !valueInRange(zposComparisonMode, card->zpos, zposition))
@@ -256,6 +269,16 @@ MTGCardInstance * CardDescriptor::match_and(MTGCardInstance * card)
} else if(!valueInRange(toughnessComparisonMode, card->getToughness(), toughness))
return NULL;
}
if (numofColorsComparisonMode){
int totalcolor = 0;
WParsedInt* value = NEW WParsedInt("mycolnum", NULL, card);
if(value){
totalcolor = value->getValue();
SAFE_DELETE(value);
}
if(!valueInRange(numofColorsComparisonMode, totalcolor, numofColors))
return NULL;
}
if (manacostComparisonMode && !valueInRange(manacostComparisonMode, card->myconvertedcost, convertedManacost))
match = NULL;
if (zposComparisonMode && !valueInRange(zposComparisonMode, card->zpos, zposition))

View File

@@ -1749,6 +1749,12 @@ bool CardGui::FilterCard(MTGCard * _card,string filter)
}
}
else if (attribute.find("numofcols") != string::npos)
{
//Number of color restrictions
cd.numofColors = comparisonCriterion;
cd.numofColorsComparisonMode = comparisonMode;
}
else if (attribute.find("power") != string::npos)
{
//Power restrictions

View File

@@ -917,6 +917,12 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
}
}
else if (attribute.find("numofcols") != string::npos)
{
//Number of color restrictions
cd->numofColors = comparisonCriterion;
cd->numofColorsComparisonMode = comparisonMode;
}
else if (attribute.find("power") != string::npos)
{
//Power restrictions

View File

@@ -1565,6 +1565,22 @@ void WParsedInt::extendedParse(string s, Spell * spell, MTGCardInstance * card)
}
intValue = hasdeadtype;
}
else if(s.find("hasmansym") != string::npos){
string manatocheck = s.substr(9);
if(manatocheck == "c")
intValue = card->getManaCost()->getManaSymbolsHybridMerged(Constants::MTG_COLOR_ARTIFACT);
else if(manatocheck == "g")
intValue = card->getManaCost()->getManaSymbolsHybridMerged(Constants::MTG_COLOR_GREEN);
else if(manatocheck == "u")
intValue = card->getManaCost()->getManaSymbolsHybridMerged(Constants::MTG_COLOR_BLUE);
else if(manatocheck == "r")
intValue = card->getManaCost()->getManaSymbolsHybridMerged(Constants::MTG_COLOR_RED);
else if(manatocheck == "b")
intValue = card->getManaCost()->getManaSymbolsHybridMerged(Constants::MTG_COLOR_BLACK);
else if(manatocheck == "w")
intValue = card->getManaCost()->getManaSymbolsHybridMerged(Constants::MTG_COLOR_WHITE);
else intValue = 0;
}
else if(!intValue)//found nothing, try parsing a atoi
{
intValue = atoi(s.c_str());