Pretty huge patch here(sorry old habits never die :( )

lots of changes, many bug fixes,
first
added auto=count(targetchooser)
and countedamount wparsed int
they work together for cards where it is difficult to get working without knowing in advance how many we had ie: exile blah creatures, for each creature you exiled do effect.
auto=count(creature|mybattlefield)
auto=moveto(exile)
auto=draw:countedamount
it takes into account token creatures, which our old methods did not.

second, added "freeze" which is a "frozen" that automatically taps your target for you, for use when nesting or whenever needed where it was difficult to nest the ability with tap included.

added devotion for "iroas"

added reveal:x and scry x
reveal contains optionone/optiononeend ; optiontwo/optiontwoend ; repeat; afterrevealed/afterrevealed end.

this ability has heavy use of targetListIsSet(<amount>) and upto:amount, you MUST be certain that all cards being revealed have an action that removes them from reveal either in the first, second, or 3rd ability.
there are over 300 examples in the new card code, the ability is VERY easy to understand.

scry contains automatic put on top, put on bottom, then scrycore/scrycoreend which is an ability to fire.
it also contains keywords, dontshow which is nested in scrycore, scry reveals, puts on top or bottom, then reveal AGAIN, and does an effect, dontshow eliminates the 2nd revealing.
is also contains "delayed" keyword, which delays the ability until AFTER the core fires.

added bestow. update rules mtg.txt!!!!
examples are in primitives, every bestow card was supported.

added a new lord based on varibles and restrictions
while(restriction{morbid})
while(varible:blah)
this simplifies and expands on this(, allowing you to even use while(cantarget together and check if a card is targetable by the variable. examples are in primitives

added token(by card name)
auto=token(Eldrazi Scion) 
will search primitives and card dats for this card and give it to you as a token.
valid card dat info is still required.

added variable delirium
added restriction madnessplayed to allow checking if the card was played with madness.

added restriction "geared" for checking if a card has equipment on it.

added abilities words
skulk

menace <--cant be blocked except by 2 or more, if you dont block it with 2 or more we automatically unassign the single blocker and the creature is considered not blocked.

nosolo <--cant attack alone

mustblock <---if you dont assign as a blocker, we assign automatically the first thing it can block legally.

changed iscolorless back to "colorless"

enjoy, cards coming soon, theyre coded but im debating on not alpha sorting, cards being added this patch 965 uniques.

there is a section of the commit which was just VS2016 normalizing line ends, sorry if it makes it a cluster mess.
This commit is contained in:
zethfoxster
2016-06-28 18:40:55 -04:00
parent 9439b347c9
commit 6ee00c138c
29 changed files with 3854 additions and 2289 deletions
+175 -32
View File
@@ -19,8 +19,8 @@
const string kLordKeywords[] = { "lord(", "foreach(", "aslongas(", "teach(", "all(" };
const size_t kLordKeywordsCount = 5;
const string kThisKeywords[] = { "this(", "thisforeach(" };
const size_t kThisKeywordsCount = 2;
const string kThisKeywords[] = { "this(", "thisforeach(","while(", };
const size_t kThisKeywordsCount = 3;
// Used for the maxCast/maxPlay ability parsing
@@ -353,6 +353,24 @@ int AbilityFactory::parseCastRestrictions(MTGCardInstance * card, Player * playe
return 0;
}
check = restriction[i].find("delirium");
if (check != string::npos)
{
Player * checkCurrent = card->controller();
MTGGameZone * grave = checkCurrent->game->graveyard;
int checkTypesAmount = 0;
if(grave->hasType("creature")) checkTypesAmount++;
if (grave->hasType("enchantment")) checkTypesAmount++;
if (grave->hasType("sorcery")) checkTypesAmount++;
if (grave->hasType("instant")) checkTypesAmount++;
if (grave->hasType("land")) checkTypesAmount++;
if (grave->hasType("artifact")) checkTypesAmount++;
if (grave->hasType("planeswalker")) checkTypesAmount++;
if (checkTypesAmount < 4)
return 0;
}
check = restriction[i].find("miracle");
if(check != string::npos)
{
@@ -362,6 +380,13 @@ int AbilityFactory::parseCastRestrictions(MTGCardInstance * card, Player * playe
return 0;
}
check = restriction[i].find("madnessplayed");
if (check != string::npos)
{
if (card->previous && !card->previous->MadnessPlay)
return 0;
}
check = restriction[i].find("prowl");
if(check != string::npos)
{
@@ -437,6 +462,13 @@ int AbilityFactory::parseCastRestrictions(MTGCardInstance * card, Player * playe
return 0;
}
check = restriction[i].find("geared");
if (check != string::npos)
{
if (card->equipment < 1)
return 0;
}
check = restriction[i].find("raid");
if(check != string::npos)
{
@@ -1139,6 +1171,13 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
observer->addObserver(NEW MTGFlashBackRule(observer, -1));
return NULL;
}
//alternative cost type flashback
found = s.find("bestowrule");
if (found != string::npos)
{
observer->addObserver(NEW MTGBestowRule(observer, -1));
return NULL;
}
//alternative cost type retrace
found = s.find("retracerule");
if(found != string::npos)
@@ -1306,19 +1345,46 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
//actual abilities, this is a limitation.
string unchangedS = "";
unchangedS.append(s);
found = s.find("pay(");
if (found != string::npos && storedPayString.empty())
{
vector<string> splitMayPaystr = parseBetween(s, "pay(", ")", true);
if(splitMayPaystr.size())
{
storedPayString.append(splitMayPaystr[2]);
s = splitMayPaystr[0];
s.append("pay(");
s.append(splitMayPaystr[1]);
s.append(")");
}
}
//Reveal:x remove the core so we dont build them prematurely
vector<string>transPayfound = parseBetween(s, "newability[pay(", " ");
vector<string>transfound = parseBetween(s,"newability[reveal:"," ");//if we are using reveal inside a newability, let transforms remove the string instead.
vector<string>abilfound = parseBetween(s, "ability$!name(reveal) reveal:", " ");
if(!abilfound.size())
abilfound = parseBetween(s, "ability$!reveal:", " ");//see above. this allows us to nest reveals inside these 2 other master classes. while also allowing us to nest them inside reveals.
found = s.find("pay(");
if (found != string::npos && storedPayString.empty() && !transPayfound.size())
{
vector<string> splitMayPaystr = parseBetween(s, "pay(", ")", true);
if (splitMayPaystr.size())
{
storedPayString.append(splitMayPaystr[2]);
s = splitMayPaystr[0];
s.append("pay(");
s.append(splitMayPaystr[1]);
s.append(")");
}
}
vector<string> splitRevealx = parseBetween(s, "reveal:", " revealend", false);
if (!abilfound.size() && !transfound.size() && splitRevealx.size() && storedAbilityString.empty())
{
storedAbilityString = splitRevealx[1];
s = splitRevealx[0];
s.append("reveal: ");
s.append(splitRevealx[2]);
}
vector<string> splitScryx = parseBetween(s, "scry:", " scryend", false);
if (splitScryx.size() && storedAbilityString.empty())
{
storedAbilityString = splitScryx[1];
s = splitScryx[0];
s.append("scry: ");
s.append(splitScryx[2]);
}
found = s.find("transforms((");
if (found != string::npos && storedString.empty())
{
@@ -1750,15 +1816,25 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
}
if (end != string::npos)
{
ThisDescriptor * td = NULL;
string thisDescriptorString = s.substr(found + header, end - found - header);
ThisDescriptorFactory tdf;
ThisDescriptor * td = tdf.createThisDescriptor(observer, thisDescriptorString);
vector<string> splitRest = parseBetween(s, "restriction{", "}");
if (splitRest.size())
{
if (!td)
{
DebugTrace("MTGABILITY: Parsing Error:" << s);
return NULL;
}
}
else
{
ThisDescriptorFactory tdf;
td = tdf.createThisDescriptor(observer, thisDescriptorString);
if (!td)
{
DebugTrace("MTGABILITY: Parsing Error:" << s);
return NULL;
}
}
MTGAbility * a = parseMagicLine(s1, id, spell, card, 0, activated);
if (!a)
@@ -1795,6 +1871,9 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
case 1:
result = NEW AThisForEach(observer, id, card, _target, td, a);
break;
case 2:
result = NEW AThis(observer, id, card, _target, NULL, a, thisDescriptorString);
break;
default:
result = NULL;
}
@@ -1986,7 +2065,6 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
return NEW APaired(observer,id, card,card->myPair,a);
return NULL;
}
//mana of the listed type doesnt get emptied from the pools.
vector<string>colorType = parseBetween(s,"poolsave(",")",false);
if (colorType.size())
@@ -2269,9 +2347,21 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
tok->oneShot = 1;
return tok;
}
string tokenDesc = splitToken[1];
vector<string> tokenParameters = split(tokenDesc, ',');
//lets try finding a token by card name.
if (splitToken[1].size() && tokenParameters.size() ==1)
{
string cardName = splitToken[1];
MTGCard * safetycard = MTGCollection()->getCardByName(cardName);
if (safetycard) //lets try constructing it then,we didnt find it by name
{
ATokenCreator * tok = NEW ATokenCreator(observer, id, card, target, NULL, cardName, starfound, multiplier, who);
tok->oneShot = 1;
return tok;
}
}
if (tokenParameters.size() < 3)
{
DebugTrace("incorrect Parameters for Token" << tokenDesc);
@@ -2474,6 +2564,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
bool withRestrictions = splitCastCard[1].find("restricted") != string::npos;
bool asCopy = splitCastCard[1].find("copied") != string::npos;
bool asNormal = splitCastCard[1].find("normal") != string::npos;
bool asNormalMadness = splitCastCard[1].find("madness") != string::npos;
bool sendNoEvent = splitCastCard[1].find("noevent") != string::npos;
bool putinplay = splitCastCard[1].find("putinplay") != string::npos;
string nameCard = "";
@@ -2485,7 +2576,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
nameCard = splitCastName[1];
}
}
MTGAbility *a = NEW AACastCard(observer, id, card, target,withRestrictions,asCopy,asNormal,nameCard,newName,sendNoEvent,putinplay);
MTGAbility *a = NEW AACastCard(observer, id, card, target,withRestrictions,asCopy,asNormal,nameCard,newName,sendNoEvent,putinplay, asNormalMadness);
a->oneShot = false;
if(splitCastCard[1].find("trigger[to]") != string::npos)
{
@@ -2933,6 +3024,16 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
return a;
}
//bestow
found = s.find("bstw");
if (found != string::npos)
{
MTGAbility * a = NEW ABestow(observer, id, card, target);
a->oneShot = 1;
return a;
}
//no counters on target of optional type
vector<string> splitCounterShroud = parseBetween(s, "countershroud(", ")");
if (splitCounterShroud.size())
@@ -3122,6 +3223,30 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
}
//Reveal:x (activate aility)
vector<string> splitReveal = parseBetween(s, "reveal:", "revealend", false);
if (splitReveal.size())
{
string backup = storedAbilityString;
storedAbilityString = "";//we clear the string here for cards that contain more than 1 reveal.
GenericRevealAbility * a = NEW GenericRevealAbility(observer, id, card, target, backup);
a->oneShot = 1;
a->canBeInterrupted = false;
return a;
}
//scry:x (activate aility)
vector<string> splitScry = parseBetween(s, "scry:", "scryend", false);
if (splitScry.size())
{
string backup = storedAbilityString;
storedAbilityString = "";//we clear the string here for cards that contain more than 1 reveal.
GenericScryAbility * a = NEW GenericScryAbility(observer, id, card, target, backup);
a->oneShot = 1;
a->canBeInterrupted = false;
return a;
}
//flip
vector<string> splitFlipStat = parseBetween(s, "flip(", ")", true);
if(splitFlipStat.size())
@@ -3291,11 +3416,20 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
found = s.find("frozen");
if (found != string::npos)
{
MTGAbility * a = NEW AAFrozen(observer, id, card, target);
MTGAbility * a = NEW AAFrozen(observer, id, card, target,false);
a->oneShot = 1;
return a;
}
//frozen, next untap this does not untap.
found = s.find("freeze");
if (found != string::npos)
{
MTGAbility * a = NEW AAFrozen(observer, id, card, target,true);
a->oneShot = 1;
return a;
}
//get a new target - retarget and newtarget makes the card refreshed - from exile to play...
if ((s.find("retarget") != string::npos) || s.find("newtarget") != string::npos)
{
@@ -3330,6 +3464,14 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
return a;
}
vector<string> splitCountObject = parseBetween(s, "count(", ")", false);
if (splitCountObject.size())
{
MTGAbility * a = NEW AACountObject(observer, id, card, card, NULL, splitCountObject[1]);
a->oneShot = 1;
return a;
}
//switch targest power with toughness
found = s.find("swap");
if (found != string::npos)
@@ -4625,6 +4767,7 @@ MTGAbility::MTGAbility(const MTGAbility& a): ActionElement(a)
BuyBack = a.BuyBack; //? NEW ManaCost(a.BuyBack) : NULL;
FlashBack = a.FlashBack; // ? NEW ManaCost(a.FlashBack) : NULL;
Retrace = a.Retrace;// ? NEW ManaCost(a.Retrace) : NULL;
Bestow = a.Bestow;
morph = a.morph; //? NEW ManaCost(a.morph) : NULL;
suspend = a.suspend;// ? NEW ManaCost(a.suspend) : NULL;
@@ -5101,7 +5244,7 @@ int TargetAbility::reactToClick(MTGCardInstance * card)
}
else
{
if (tc->toggleTarget(card) == TARGET_OK_FULL)
if (tc->toggleTarget(card) == TARGET_OK_FULL && tc->targetsReadyCheck() == TARGET_OK_FULL)
{
int result = ActivatedAbility::reactToClick(source);
if (result)
@@ -5360,8 +5503,8 @@ void ListMaintainerAbility::updateTargets()
for (int i = 0; i < 2; i++)
{
Player * p = game->players[i];
MTGGameZone * zones[] = { p->game->inPlay, p->game->graveyard, p->game->hand, p->game->library, p->game->stack, p->game->exile };
for (int k = 0; k < 6; k++)
MTGGameZone * zones[] = { p->game->inPlay, p->game->graveyard, p->game->hand, p->game->library, p->game->stack, p->game->exile ,p->game->reveal };
for (int k = 0; k < 7; k++)
{
MTGGameZone * zone = zones[k];
if (canTarget(zone))
@@ -5432,8 +5575,8 @@ void ListMaintainerAbility::checkTargets()
for (int i = 0; i < 2; i++)
{
Player * p = game->players[i];
MTGGameZone * zones[] = { p->game->inPlay, p->game->graveyard, p->game->hand, p->game->library, p->game->stack, p->game->exile };
for (int k = 0; k < 6; k++)
MTGGameZone * zones[] = { p->game->inPlay, p->game->graveyard, p->game->hand, p->game->library, p->game->stack, p->game->exile, p->game->reveal };
for (int k = 0; k < 7; k++)
{
MTGGameZone * zone = zones[k];
if (canTarget(zone))
@@ -5772,7 +5915,7 @@ int AManaProducer::resolve()
Player * player = getPlayerFromTarget(_target);
if (!player)
return 0;
player->getManaPool()->add(output, source);
if(DoesntEmpty)
player->doesntEmpty->add(output);