Add Upkeep costs to parser.

upcost[cost[,phase]] effect

cost is any cost that you might use for an auto line, including sacrifice and counters, phase is optional and defaults to upkeep, phase can have an optional prefix next which will make it so you only need to pay the cost once.

Effect is any effect that can go in an auto line and only goes off if cost is not paid during phase. For example, force of nature would be: auto=upcost[{G}{G}{G}{G}] damage:4 controller.
goblin patrol would have: auto=upcost[{R},next upkeep] moveto(mygraveyard)
This commit is contained in:
salmelo16
2010-04-21 01:56:44 +00:00
parent 73cfbce0ae
commit 3339b6b6a8
3 changed files with 97 additions and 1 deletions

View File

@@ -526,7 +526,45 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
SAFE_DELETE(tc);
//Upkeep Cost
found = s.find("upcost");
if (found != string::npos){
size_t start = s.find("[");
size_t end = s.find("]",start);
string s1 = s.substr(start + 1,end - start - 1);
size_t seperator = s1.find(",");
int phase = Constants::MTG_PHASE_UPKEEP;
int once = 0;
if (seperator != string::npos){
for (int i = 0; i < Constants::NB_MTG_PHASES; i++){
if (s1.find("next") != string::npos) once = 1;
if(s1.find(Constants::MTGPhaseCodeNames[i]) != string::npos){
phase = i;
}
}
s1 = s1.substr(0,seperator - 1);
}
ManaCost * cost = ManaCost::parseManaCost(s1);
if (!cost){
OutputDebugString("MTGABILITY: Parsing Error:");
OutputDebugString(s.c_str());
OutputDebugString("\n");
return NULL;
}
string sAbility = s.substr(end + 1);
MTGAbility * a = parseMagicLine(sAbility,id,spell,card);
if (!a){
OutputDebugString("MTGABILITY: Parsing Error:");
OutputDebugString(s.c_str());
OutputDebugString("\n");
return NULL;
}
return NEW AUpkeep(id,card,a,cost,doTap,restrictions,phase,once);
}
//Cycling
found = s.find("cycling");
@@ -945,6 +983,8 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
return a;
}
return NULL;
}