Fixed primitives, updated italian lang file, added a new setting to sort decks by creation date (by default they will be sorted by name), added new filters to match cards that don't contain a particular color or that are multicolored, fixed an issue when the transformation with uynt is triggered by instant/sorcery or by card that left the battlefield before the ability ending turn, fixed a rendering overlap on mana symbols in deck editor, fixed some crashes on ManaCost parser (e.g. Filter by mana producer).

This commit is contained in:
Vittorio Alfieri
2021-11-15 21:38:04 +01:00
parent 2eed51dea6
commit 477ffa6a0c
16 changed files with 204 additions and 60 deletions
+2 -2
View File
@@ -7782,9 +7782,8 @@ int ATransformer::addToGame()
if(UYNT)
{
if(myCurrentTurn != 1000 && game->turn > myCurrentTurn && source->controller()->getId() == game->currentPlayer->getId())
{
return 1;
}
return 0; // Fixed an issue when the transformation with uynt is triggered by instant/sorcery or by card that left the battlefield before the ability ending turn.
}
return MTGAbility::testDestroy();
}
@@ -7793,6 +7792,7 @@ int ATransformer::destroy()
{
if(aForever)
return 0;
MTGCardInstance * _target = (MTGCardInstance *) target;
if (_target)
{
+6 -6
View File
@@ -161,18 +161,18 @@ void DeckView::renderCard(int index, int alpha, bool asThumbnail, bool griddeckv
if (last_user_activity < 3)
{
int fontAlpha = alpha;
float qtY = cardPosition.y - 135 * cardPosition.scale;
float qtX = cardPosition.x + 40 * cardPosition.scale;
float qtY = cardPosition.y - 115 * cardPosition.scale;
float qtX = cardPosition.x + 62 * cardPosition.scale;
char buffer[4096];
sprintf(buffer, "x%i", deck()->count(cardPosition.card));
WFont * font = mFont;
font->SetScale(1.4f);
font->SetColor(ARGB(fontAlpha/2,0,0,0));
JRenderer::GetInstance()->FillRect(qtX, qtY, font->GetStringWidth(buffer) + 6, 18, ARGB(fontAlpha/2,0,0,0));
JRenderer::GetInstance()->DrawRect(qtX, qtY, font->GetStringWidth(buffer) + 6, 18, ARGB(fontAlpha/2,240,240,240));
font->DrawString(buffer, qtX + 5, qtY + 3);
JRenderer::GetInstance()->FillRect(qtX, qtY, font->GetStringWidth(buffer) + 6, 15, ARGB(fontAlpha/2,0,0,0));
JRenderer::GetInstance()->DrawRect(qtX, qtY, font->GetStringWidth(buffer) + 6, 15, ARGB(fontAlpha/2,240,240,240));
font->DrawString(buffer, qtX + 5, qtY + 0);
font->SetColor(ARGB(fontAlpha,255,255,255));
font->DrawString(buffer, qtX + 4, qtY + 2);
font->DrawString(buffer, qtX + 4, qtY - 1);
font->SetColor(ARGB(255,255,255,255));
font->SetScale(1.0f);
}
+1
View File
@@ -22,6 +22,7 @@ const string Options::optionNames[] = {
"cheatmodedecks",
"ShowBorder",
"BlackBorder",
"SortDecksByDate",
"ShowTokens",
"SortingSets",
"GDVLargeImages",
+5 -2
View File
@@ -94,10 +94,13 @@ vector<DeckMetaData *> GameState::BuildDeckList(const string& path, const string
}
meta = NULL;
}
// Now decks can be sorted by name or by creation date.
if(!options[Options::SORTINGDECKS].number)
std::sort(retList.begin(), retList.end(), sortByName); // Ordered by name from A to Z.
else
std::reverse(retList.begin(), retList.end()); // Ordered by creation date from the last to the first one (e.g. we consider deck2.txt newer than deck1.txt).
std::sort(retList.begin(), retList.end(), sortByName);
return retList;
}
// build a menu with the given deck list and return a vector of the deck ids created.
+2 -2
View File
@@ -893,9 +893,9 @@ void GameStateDeckViewer::renderOnScreenBasicInfo()
float w = mFont->GetStringWidth(buffer);
PIXEL_TYPE backupColor = mFont->GetColor();
renderer->FillRoundRect(SCREEN_WIDTH - (w + 27), y + 5, w + 10, 15, 5, ARGB(hudAlpha/2,0,0,0));
renderer->FillRoundRect(SCREEN_WIDTH - (w + 27), y, w + 5, 4, 5, ARGB(hudAlpha/2,0,0,0));
mFont->SetColor(ARGB(hudAlpha,255,255,255));
mFont->DrawString(buffer, SCREEN_WIDTH - 22, y + 15, JGETEXT_RIGHT);
mFont->DrawString(buffer, SCREEN_WIDTH - 20, y + 1, JGETEXT_RIGHT);
mFont->SetColor(backupColor);
if (mView->filter() != 0) renderer->RenderQuad(mIcons[mView->filter() - 1].get(), SCREEN_WIDTH - 10, y + 15, 0.0f, 0.5, 0.5);
+2
View File
@@ -63,6 +63,8 @@ void GameStateOptions::Start()
optionsList->Add(NEW OptionInteger(Options::SHOWBORDER, "Show Borders"));
//black border
optionsList->Add(NEW OptionInteger(Options::BLKBORDER, "All Black Borders"));
//Sort deck by date
optionsList->Add(NEW OptionInteger(Options::SORTINGDECKS, "Sort decks by date"));
//show tokens in editor
optionsList->Add(NEW OptionInteger(Options::SHOWTOKENS, "Show Tokens in Editor"));
WDecoStyled * wMisc = NEW WDecoStyled(NEW WGuiHeader("Warning!!!"));
+4
View File
@@ -266,6 +266,8 @@ ManaCost * ManaCost::parseManaCost(string s, ManaCost * _manaCost, MTGCardInstan
case 'p' :
{
SAFE_DELETE(tc);
if (value.find("power") != string::npos) // Fix to avoid crash on ManaCost parse (e.g. Filter by mana producer).
break;
size_t start = value.find("(");
size_t end = value.rfind(")");
string manaType = value.substr(start + 1, end - start - 1);
@@ -298,6 +300,8 @@ ManaCost * ManaCost::parseManaCost(string s, ManaCost * _manaCost, MTGCardInstan
break;
case 'c': //Counters or cycle
{
if (value.find("compare(") != string::npos) // Fix to avoid crash on ManaCost parse (e.g. Filter by mana producer).
break;
if (value.find("convoke") != string::npos)
{
if (!tc)
+100 -18
View File
@@ -12,10 +12,12 @@ WCFilterFactory* WCFilterFactory::GetInstance()
if (!me) me = NEW WCFilterFactory();
return me;
}
void WCFilterFactory::Destroy()
{
SAFE_DELETE(me);
}
size_t WCFilterFactory::findNext(string src, size_t start, char open, char close)
{
int num = 0;
@@ -30,6 +32,7 @@ size_t WCFilterFactory::findNext(string src, size_t start, char open, char close
}
return string::npos;
}
WCardFilter * WCFilterFactory::Construct(string src)
{
size_t x = 0;
@@ -152,6 +155,8 @@ WCardFilter * WCFilterFactory::Terminal(string src, string arg)
return NEW WCFilterRarity(arg);
else if (type == "c" || type == "color")
return NEW WCFilterColor(arg);
else if (type == "nc" || type == "ncolor")
return NEW WCFilterNotColor(arg);
else if (type == "xc" || type == "xcolor")
return NEW WCFilterOnlyColor(arg);
else if (type == "s" || type == "set")
@@ -172,6 +177,7 @@ WCardFilter * WCFilterFactory::Terminal(string src, string arg)
return NEW WCFilterNULL();
}
//WCFilterLetter
WCFilterLetter::WCFilterLetter(string arg)
{
@@ -180,6 +186,7 @@ WCFilterLetter::WCFilterLetter(string arg)
else
alpha = tolower(arg[0]);
}
bool WCFilterLetter::isMatch(MTGCard * c)
{
if (!c || !c->data) return false;
@@ -188,12 +195,14 @@ bool WCFilterLetter::isMatch(MTGCard * c)
if (s[0] == alpha || (alpha == '#' && (isdigit(s[0]) || ispunct(s[0])))) return true;
return false;
}
string WCFilterLetter::getCode()
{
char buf[24];
sprintf(buf, "alpha:%c;", alpha);
return buf;
}
//WCFilterSet
WCFilterSet::WCFilterSet(string arg)
{
@@ -208,7 +217,6 @@ string WCFilterSet::getCode()
sprintf(buf, "set:%s;", setName.c_str());
return buf;
}
;
//WCFilterColor
bool WCFilterColor::isMatch(MTGCard * c)
@@ -216,15 +224,16 @@ bool WCFilterColor::isMatch(MTGCard * c)
if (!c || !c->data) return false;
return (c->data->hasColor(color));
}
string WCFilterColor::getCode()
{
char buf[12];
char c = '?';
if (color < 0 || color >= Constants::NB_Colors) c = Constants::MTGColorChars[color];
if (color >= 0 && color < Constants::NB_Colors) c = Constants::MTGColorChars[color];
sprintf(buf, "color:%c;", c);
return buf;
}
;
WCFilterColor::WCFilterColor(string arg)
{
color = -1;
@@ -238,6 +247,57 @@ WCFilterColor::WCFilterColor(string arg)
}
}
}
//WCFilterNotColor
bool WCFilterNotColor::isMatch(MTGCard * c)
{
if (!c || !c->data) return false;
if(color == -1){ // Only multicolored cards
for (int i = 1; i < 6; i++){
if(c->data->hasColor(i)){
for (int j = i+1; j < 6; j++){
if(c->data->hasColor(j))
return true;
}
}
}
return false;
} else if(color == 0){ // Not colorless cards
for (int i = 1; i < 6; i++){
if(c->data->hasColor(i))
return true;
}
return false;
} else
return !(c->data->hasColor(color));
}
string WCFilterNotColor::getCode()
{
char buf[12];
char c = '?';
if (color >= 0 && color < Constants::NB_Colors)
c = Constants::MTGColorChars[color];
else if (color < 0)
c = 'm';
sprintf(buf, "ncolor:%c;", c);
return buf;
}
WCFilterNotColor::WCFilterNotColor(string arg)
{
color = -1;
char c = tolower(arg[0]);
for (int i = 0; i < Constants::NB_Colors; i++)
{
if (Constants::MTGColorChars[i] == c)
{
color = i;
break;
}
}
}
//WCFilterOnlyColor
bool WCFilterOnlyColor::isMatch(MTGCard * c)
{
@@ -249,14 +309,16 @@ bool WCFilterOnlyColor::isMatch(MTGCard * c)
}
return (c->data->hasColor(color));
}
string WCFilterOnlyColor::getCode()
{
char buf[12];
char c = '?';
if (color < 0 || color >= Constants::NB_Colors) c = Constants::MTGColorChars[color];
if (color >= 0 && color < Constants::NB_Colors) c = Constants::MTGColorChars[color];
sprintf(buf, "xcolor:%c;", c);
return buf;
}
//WCFilterProducesColor
bool WCFilterProducesColor::isMatch(MTGCard * c)
{
@@ -271,23 +333,27 @@ bool WCFilterProducesColor::isMatch(MTGCard * c)
return true;
//Retrieve non basic Mana abilities
string s = c->data->magicText;
size_t t = s.find("add{");
while (t != string::npos)
{
s = s.substr(t + 3);
ManaCost * mc = ManaCost::parseManaCost(s);
if (mc->hasColor(color) > 0)
vector<string> rows = split(c->data->magicText, '\n'); // Now the parser analyze the full card text row by row to avoid fake color matches.
for(size_t j = 0; j < rows.size(); j++){
string s = rows[j];
size_t t = s.find("add{");
while (t != string::npos)
{
bMatch = true;
s = s.substr(t + 3);
ManaCost * mc = ManaCost::parseManaCost(s);
if (mc->hasColor(color) > 0)
{
bMatch = true;
SAFE_DELETE(mc);
break;
}
SAFE_DELETE(mc);
break;
t = s.find("add{");
}
SAFE_DELETE(mc);
t = s.find("add");
}
return bMatch;
}
string WCFilterProducesColor::getCode()
{
char buf[12];
@@ -296,11 +362,13 @@ string WCFilterProducesColor::getCode()
sprintf(buf, "produces:%c;", c);
return buf;
}
//WCFilterNumeric
WCFilterNumeric::WCFilterNumeric(string arg)
{
number = atoi(arg.c_str());
}
//WCFilterCMC
bool WCFilterCMC::isMatch(MTGCard * c)
{
@@ -315,30 +383,35 @@ string WCFilterCMC::getCode()
sprintf(buf, "cmc:%i;", number);
return buf;
}
//WCFilterPower
bool WCFilterPower::isMatch(MTGCard * c)
{
if (!c || !c->data) return false;
return (c->data->getPower() == number);
}
string WCFilterPower::getCode()
{
char buf[64];
sprintf(buf, "power:%i;", number);
return buf;
}
//WCFilterPower
bool WCFilterToughness::isMatch(MTGCard * c)
{
if (!c || !c->data) return false;
return (c->data->getToughness() == number);
}
string WCFilterToughness::getCode()
{
char buf[64];
sprintf(buf, "toughness:%i;", number);
return buf;
}
//WCFilterRarity
float WCFilterRarity::filterFee()
{
@@ -355,12 +428,14 @@ float WCFilterRarity::filterFee()
}
return 0.0f;
}
bool WCFilterRarity::isMatch(MTGCard * c)
{
if (!c || !c->data) return false;
if (rarity == 'A') return true; //A for "Any" or "All"
return (c->getRarity() == rarity);
}
string WCFilterRarity::getCode()
{
char buf[64];
@@ -393,7 +468,7 @@ string WCFilterRarity::getCode()
sprintf(buf, "rarity:%s;", rarities[x]);
return buf;
}
;
WCFilterRarity::WCFilterRarity(string arg)
{
rarity = -1;
@@ -412,6 +487,7 @@ WCFilterRarity::WCFilterRarity(string arg)
}
rarity = 'A';
}
//WCFilterAbility
bool WCFilterAbility::isMatch(MTGCard * c)
{
@@ -433,6 +509,7 @@ WCFilterAbility::WCFilterAbility(string arg)
}
ability = -1;
}
string WCFilterAbility::getCode()
{
char buf[64];
@@ -440,7 +517,6 @@ string WCFilterAbility::getCode()
sprintf(buf, "ability:%s;", Constants::MTGBasicAbilities[ability]);
return buf;
}
;
float WCFilterAbility::filterFee()
{
@@ -487,22 +563,26 @@ float WCFilterAbility::filterFee()
}
return 0.0f;
}
//WCFilterType
bool WCFilterType::isMatch(MTGCard * c)
{
return c->data->hasType(type.c_str());
}
string WCFilterType::getCode()
{
char buf[4068];
sprintf(buf, "type:%s;", type.c_str());
return buf;
}
//Misc. filter code
float WCFilterAND::filterFee()
{
return lhs->filterFee() + rhs->filterFee();
}
float WCFilterOR::filterFee()
{
float lFee = lhs->filterFee();
@@ -511,12 +591,14 @@ float WCFilterOR::filterFee()
return lFee;
return rFee;
}
string WCFilterNOT::getCode()
{
char buf[4068];
sprintf(buf, "{%s}", kid->getCode().c_str());
return buf;
}
string WCFilterGROUP::getCode()
{
char buf[4068];
@@ -530,6 +612,7 @@ string WCFilterAND::getCode()
sprintf(buf, "%s&%s", lhs->getCode().c_str(), rhs->getCode().c_str());
return buf;
}
string WCFilterOR::getCode()
{
char buf[4068];
@@ -543,4 +626,3 @@ bool WCFilterOR::isMatch(MTGCard *c)
if (rhs->isMatch(c)) return true;
return false;
}
;
+7
View File
@@ -2186,6 +2186,13 @@ void WGuiFilterItem::updateValue()
mParent->addArg("Exclusively Black", "xc:b;");
mParent->addArg("Exclusively Red", "xc:r;");
mParent->addArg("Exclusively Green", "xc:g;");
mParent->addArg("Not White", "nc:w;");
mParent->addArg("Not Blue", "nc:u;");
mParent->addArg("Not Black", "nc:b;");
mParent->addArg("Not Red", "nc:r;");
mParent->addArg("Not Green", "nc:g;");
mParent->addArg("Not Colorless", "nc:x;");
mParent->addArg("Only Multicolored", "nc:m;");
}
else if (filterType == FILTER_PRODUCE)
{