Added new decks for AI, improved "genrand", "altercost" and "changecost" keywords in order to allow the usage of a variable instead of a simple number (e.g. "altercost(colorless, -phandcount)").

This commit is contained in:
Vittorio Alfieri
2021-09-26 12:22:28 +02:00
parent 8ae7439978
commit 9e3caa635d
27 changed files with 1194 additions and 7 deletions
+2 -2
View File
@@ -7388,8 +7388,8 @@ void AAlterCost::refreshCost(MTGCardInstance * card)
original->remove(card->getReducedManaCost());
card->getManaCost()->copy(original);
delete original;
return;
}
return;
}
void AAlterCost::increaseTheCost(MTGCardInstance * card)
{
if(card->getIncreasedManaCost()->getConvertedCost())
+6 -3
View File
@@ -4639,7 +4639,8 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
if(splitChangeCost[1].size())
{
vector<string> ccParameters = split( splitChangeCost[1], ':');
int amount = atoi(ccParameters[1].c_str());
WParsedInt * value = NEW WParsedInt(ccParameters[1].c_str(), NULL, card);
int amount = value->getValue();
int color = Constants::GetColorStringIndex(ccParameters[0]);
if(ccParameters[0] == "colorless")
color = 0;
@@ -6263,7 +6264,8 @@ MTGAbility * AbilityFactory::getManaReduxAbility(string s, int id, Spell *, MTGC
{
int color = -1;
string manaCost = s.substr(s.find(",") + 1);
replace(manaCost.begin(), manaCost.end(), ')', ' ');
trim(manaCost);
const string ColorStrings[] = { Constants::kManaColorless, Constants::kManaGreen, Constants::kManaBlue, Constants::kManaRed, Constants::kManaBlack, Constants::kManaWhite };
for (unsigned int i = 0; i < sizeof(ColorStrings)/sizeof(ColorStrings[0]); ++i)
@@ -6280,7 +6282,8 @@ MTGAbility * AbilityFactory::getManaReduxAbility(string s, int id, Spell *, MTGC
return NULL;
}
// figure out the mana cost
int amount = atoi(manaCost.c_str());
WParsedInt * value = NEW WParsedInt(manaCost.c_str(), NULL, card);
int amount = value->getValue();
return NEW AAlterCost(observer, id, card, target, amount, color);
}
+2 -1
View File
@@ -735,7 +735,8 @@ void WParsedInt::init(string s, Spell * spell, MTGCardInstance * card)
}
else if (s.find("genrand") != string::npos) //Return a random value between 0 and a specific number (minus 1);
{
intValue = std::rand() % atoi(s.substr(7).c_str());
WParsedInt * value = NEW WParsedInt(s.substr(7).c_str(), NULL, card);
intValue = std::rand() % value->getValue();
}
else if (s == "manacost") //Return the converted manacost
{