Refactor of the parser. The goal is to reduce maintenance cost, by refactoring some of the most frequent "copy/paste" we have in there. This removes roughly 500 lines, going from 4850 to 4350 lines. I'm getting closer to my goal of getting this file back to 4000 lines :)
Crossing fingers I didn't break anything major. The test suite passes, though I expect some edge case bugs to appear. Apologies in advance, I think this change is worth it.
This commit is contained in:
@@ -1149,10 +1149,10 @@ public:
|
||||
|
||||
//remove from combat
|
||||
|
||||
class ACombatRemovel: public ActivatedAbility
|
||||
class ACombatRemoval: public ActivatedAbility
|
||||
{
|
||||
public:
|
||||
ACombatRemovel(int _id, MTGCardInstance * card, Targetable * _target) :
|
||||
ACombatRemoval(int _id, MTGCardInstance * card, Targetable * _target) :
|
||||
ActivatedAbility(_id, card)
|
||||
{
|
||||
target = _target;
|
||||
@@ -1173,9 +1173,9 @@ public:
|
||||
return "Remove From Combat";
|
||||
}
|
||||
|
||||
ACombatRemovel * clone() const
|
||||
ACombatRemoval * clone() const
|
||||
{
|
||||
ACombatRemovel * a = NEW ACombatRemovel(*this);
|
||||
ACombatRemoval * a = NEW ACombatRemoval(*this);
|
||||
a->isClone = 1;
|
||||
return a;
|
||||
}
|
||||
@@ -2529,12 +2529,6 @@ public:
|
||||
class ATokenCreator: public ActivatedAbility
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
ATOKEN_WHO_CONTROLLER = 0,
|
||||
ATOKEN_WHO_OPPONENT = 1,
|
||||
ATOKEN_WHO_TARGETCONTROLLER = 2
|
||||
};
|
||||
list<int> abilities;
|
||||
list<int> types;
|
||||
list<int> colors;
|
||||
@@ -2695,13 +2689,13 @@ ATOKEN_WHO_TARGETCONTROLLER = 2
|
||||
{
|
||||
switch(who)
|
||||
{
|
||||
case ATokenCreator::ATOKEN_WHO_CONTROLLER:
|
||||
case TargetChooser::CONTROLLER:
|
||||
tokenReciever = source->controller();
|
||||
break;
|
||||
case ATokenCreator::ATOKEN_WHO_OPPONENT:
|
||||
case TargetChooser::OPPONENT:
|
||||
tokenReciever = source->controller()->opponent();
|
||||
break;
|
||||
case ATokenCreator::ATOKEN_WHO_TARGETCONTROLLER:
|
||||
case TargetChooser::TARGET_CONTROLLER:
|
||||
if(target)
|
||||
{
|
||||
tokenReciever = ((MTGCardInstance*)target)->controller();
|
||||
|
||||
@@ -470,7 +470,9 @@ private:
|
||||
TriggeredAbility * parseTrigger(string s, string magicText, int id, Spell * spell, MTGCardInstance *card, Targetable * target);
|
||||
MTGAbility * getAlternateCost( string s, int id, Spell *spell, MTGCardInstance *card );
|
||||
MTGAbility * getManaReduxAbility(string s, int id, Spell *spell, MTGCardInstance *card, MTGCardInstance *target);
|
||||
TargetChooser * parseSimpleTC(string s, string starter, MTGCardInstance *card, bool forceNoTarget = true);
|
||||
TargetChooser * parseSimpleTC(const std::string& s, const std::string& starter, MTGCardInstance *card, bool forceNoTarget = true);
|
||||
std::vector<std::string>& parseBetween(const std::string& s, string start, string stop, bool stopRequired, std::vector<std::string>& elems);
|
||||
std::vector<std::string> parseBetween(const std::string& s, string start, string stop, bool stopRequired = true);
|
||||
|
||||
public:
|
||||
int parseRestriction(string s);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -12,10 +12,12 @@ int PhaseRing::phaseStrToInt(string s)
|
||||
if (s.compare("draw") == 0) return Constants::MTG_PHASE_DRAW;
|
||||
if (s.compare("firstmain") == 0) return Constants::MTG_PHASE_FIRSTMAIN;
|
||||
if (s.compare("combatbegin") == 0) return Constants::MTG_PHASE_COMBATBEGIN;
|
||||
if (s.compare("combatbegins") == 0) return Constants::MTG_PHASE_COMBATBEGIN;
|
||||
if (s.compare("combatattackers") == 0) return Constants::MTG_PHASE_COMBATATTACKERS;
|
||||
if (s.compare("combatblockers") == 0) return Constants::MTG_PHASE_COMBATBLOCKERS;
|
||||
if (s.compare("combatdamage") == 0) return Constants::MTG_PHASE_COMBATDAMAGE;
|
||||
if (s.compare("combatend") == 0) return Constants::MTG_PHASE_COMBATEND;
|
||||
if (s.compare("combatends") == 0) return Constants::MTG_PHASE_COMBATEND;
|
||||
if (s.compare("secondmain") == 0) return Constants::MTG_PHASE_SECONDMAIN;
|
||||
if (s.compare("endofturn") == 0) return Constants::MTG_PHASE_ENDOFTURN;
|
||||
if (s.compare("cleanup") == 0) return Constants::MTG_PHASE_CLEANUP;
|
||||
|
||||
Reference in New Issue
Block a user