more reformatting
This commit is contained in:
@@ -212,6 +212,357 @@ AManaRedux::~AManaRedux()
|
||||
{
|
||||
}
|
||||
|
||||
// ATransformer
|
||||
ATransformer::ATransformer(int id, MTGCardInstance * source, MTGCardInstance * target, string stypes, string sabilities) :
|
||||
MTGAbility(id, source, target)
|
||||
{
|
||||
//TODO this is a copy/past of other code that's all around the place, everything should be in a dedicated parser class;
|
||||
MTGCardInstance * _target = (MTGCardInstance *) target;
|
||||
for (int j = 0; j < Constants::NB_BASIC_ABILITIES; j++)
|
||||
{
|
||||
size_t found = sabilities.find(Constants::MTGBasicAbilities[j]);
|
||||
if (found != string::npos)
|
||||
{
|
||||
abilities.push_back(j);
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < Constants::MTG_NB_COLORS; j++)
|
||||
{
|
||||
size_t found = sabilities.find(Constants::MTGColorStrings[j]);
|
||||
if (found != string::npos)
|
||||
{
|
||||
colors.push_back(j);
|
||||
}
|
||||
}
|
||||
remove = false;
|
||||
if (stypes == "removesubtypes") remove = true;
|
||||
if (stypes == "allsubtypes" || stypes == "removesubtypes")
|
||||
{
|
||||
for (int i = Subtypes::LAST_TYPE + 1;; i++)
|
||||
{
|
||||
string s = Subtypes::subtypesList->find(i);
|
||||
{
|
||||
if (s == "") break;
|
||||
if (s.find(" ") != string::npos) continue;
|
||||
if (s == "Nothing" || s == "Swamp" || s == "Plains" || s == "Mountain" || s == "Forest" || s == "Island" || s
|
||||
== "Shrine" || s == "Basic" || s == "Colony" || s == "Desert" || s == "Dismiss" || s == "Equipment" || s
|
||||
== "Everglades" || s == "Grasslands" || s == "Lair" || s == "Level" || s == "Levelup" || s == "Mine" || s
|
||||
== "Oasis" || s == "World" || s == "Aura")
|
||||
{//dont add "nothing" or land type to this card.
|
||||
}
|
||||
else
|
||||
{
|
||||
types.push_back(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string s = stypes;
|
||||
while (s.size())
|
||||
{
|
||||
size_t found = s.find(" ");
|
||||
if (found != string::npos)
|
||||
{
|
||||
int id = Subtypes::subtypesList->find(s.substr(0, found));
|
||||
types.push_back(id);
|
||||
s = s.substr(found + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
int id = Subtypes::subtypesList->find(s);
|
||||
types.push_back(id);
|
||||
s = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int ATransformer::addToGame()
|
||||
{
|
||||
MTGCardInstance * _target = (MTGCardInstance *) target;
|
||||
if (_target)
|
||||
{
|
||||
while (_target->next)
|
||||
_target = _target->next;
|
||||
for (int j = 0; j < Constants::MTG_NB_COLORS; j++)
|
||||
{
|
||||
if (_target->hasColor(j)) oldcolors.push_back(j);
|
||||
}
|
||||
for (int j = Subtypes::LAST_TYPE + 1;; j++)
|
||||
{
|
||||
string otypes = Subtypes::subtypesList->find(j);
|
||||
if (otypes == "") break;
|
||||
if (otypes.find(" ") != string::npos) continue;
|
||||
if (_target->hasSubtype(j))
|
||||
{
|
||||
oldtypes.push_back(j);
|
||||
}
|
||||
}
|
||||
list<int>::iterator it;
|
||||
for (it = colors.begin(); it != colors.end(); it++)
|
||||
{
|
||||
_target->setColor(0, 1);
|
||||
}
|
||||
|
||||
for (it = types.begin(); it != types.end(); it++)
|
||||
{
|
||||
if (remove == true)
|
||||
{
|
||||
_target->removeType(*it);
|
||||
}
|
||||
else
|
||||
{
|
||||
_target->addType(*it);
|
||||
}
|
||||
}
|
||||
for (it = colors.begin(); it != colors.end(); it++)
|
||||
{
|
||||
_target->setColor(*it);
|
||||
}
|
||||
for (it = abilities.begin(); it != abilities.end(); it++)
|
||||
{
|
||||
_target->basicAbilities[*it]++;
|
||||
}
|
||||
for (it = oldcolors.begin(); it != oldcolors.end(); it++)
|
||||
{
|
||||
}
|
||||
}
|
||||
return MTGAbility::addToGame();
|
||||
}
|
||||
|
||||
int ATransformer::destroy()
|
||||
{
|
||||
MTGCardInstance * _target = (MTGCardInstance *) target;
|
||||
if (_target)
|
||||
{
|
||||
while (_target->next)
|
||||
_target = _target->next;
|
||||
list<int>::iterator it;
|
||||
for (it = types.begin(); it != types.end(); it++)
|
||||
{
|
||||
if (remove == false) _target->removeType(*it);
|
||||
}
|
||||
for (it = colors.begin(); it != colors.end(); it++)
|
||||
{
|
||||
_target->removeColor(*it);
|
||||
}
|
||||
for (it = abilities.begin(); it != abilities.end(); it++)
|
||||
{
|
||||
_target->basicAbilities[*it]--;
|
||||
}
|
||||
for (it = oldcolors.begin(); it != oldcolors.end(); it++)
|
||||
{
|
||||
_target->setColor(*it);
|
||||
}
|
||||
if (remove == true)
|
||||
{
|
||||
for (it = oldtypes.begin(); it != oldtypes.end(); it++)
|
||||
{
|
||||
if (!_target->hasSubtype(*it)) _target->addType(*it);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char * ATransformer::getMenuText()
|
||||
{
|
||||
return "Transform";
|
||||
}
|
||||
|
||||
ATransformer * ATransformer::clone() const
|
||||
{
|
||||
ATransformer * a = NEW ATransformer(*this);
|
||||
a->isClone = 1;
|
||||
return a;
|
||||
}
|
||||
|
||||
ATransformer::~ATransformer()
|
||||
{
|
||||
}
|
||||
|
||||
// AForeverTransformer
|
||||
AForeverTransformer::AForeverTransformer(int id, MTGCardInstance * source, MTGCardInstance * target, string stypes,
|
||||
string sabilities) :
|
||||
MTGAbility(id, source, target)
|
||||
{
|
||||
aType = MTGAbility::STANDARD_BECOMES;
|
||||
//TODO this is a copy/past of other code that's all around the place, everything should be in a dedicated parser class;
|
||||
MTGCardInstance * _target = (MTGCardInstance *) target;
|
||||
for (int j = 0; j < Constants::NB_BASIC_ABILITIES; j++)
|
||||
{
|
||||
size_t found = sabilities.find(Constants::MTGBasicAbilities[j]);
|
||||
if (found != string::npos)
|
||||
{
|
||||
abilities.push_back(j);
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < Constants::MTG_NB_COLORS; j++)
|
||||
{
|
||||
size_t found = sabilities.find(Constants::MTGColorStrings[j]);
|
||||
if (found != string::npos)
|
||||
{
|
||||
colors.push_back(j);
|
||||
}
|
||||
}
|
||||
string s = stypes;
|
||||
while (s.size())
|
||||
{
|
||||
size_t found = s.find(" ");
|
||||
if (found != string::npos)
|
||||
{
|
||||
int id = Subtypes::subtypesList->find(s.substr(0, found));
|
||||
types.push_back(id);
|
||||
s = s.substr(found + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
int id = Subtypes::subtypesList->find(s);
|
||||
types.push_back(id);
|
||||
s = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
int addToGame()
|
||||
{
|
||||
MTGCardInstance * _target = (MTGCardInstance *) target;
|
||||
if (_target)
|
||||
{
|
||||
while (_target->next)
|
||||
_target = _target->next;
|
||||
list<int>::iterator it;
|
||||
for (it = colors.begin(); it != colors.end(); it++)
|
||||
{
|
||||
_target->setColor(0, 1);
|
||||
}
|
||||
for (it = types.begin(); it != types.end(); it++)
|
||||
{
|
||||
_target->addType(*it);
|
||||
}
|
||||
for (it = colors.begin(); it != colors.end(); it++)
|
||||
{
|
||||
_target->setColor(*it);
|
||||
}
|
||||
for (it = abilities.begin(); it != abilities.end(); it++)
|
||||
{
|
||||
_target->basicAbilities[*it]++;
|
||||
}
|
||||
}
|
||||
return MTGAbility::addToGame();
|
||||
}
|
||||
|
||||
const char * AForeverTransformer::getMenuText()
|
||||
{
|
||||
return "Transform";
|
||||
}
|
||||
|
||||
AForeverTransformer * AForeverTransformer::clone() const
|
||||
{
|
||||
AForeverTransformer * a = NEW AForeverTransformer(*this);
|
||||
a->isClone = 1;
|
||||
return a;
|
||||
}
|
||||
AForeverTransformer::~AForeverTransformer()
|
||||
{
|
||||
}
|
||||
|
||||
//ATransformerUEOT
|
||||
ATransformerUEOT::ATransformerUEOT(int id, MTGCardInstance * source, MTGCardInstance * target, string types, string abilities) :
|
||||
InstantAbility(id, source, target)
|
||||
{
|
||||
ability = NEW ATransformer(id, source, target, types, abilities);
|
||||
aType = MTGAbility::STANDARD_BECOMES;
|
||||
}
|
||||
|
||||
int ATransformerUEOT::resolve()
|
||||
{
|
||||
ATransformer * a = ability->clone();
|
||||
GenericInstantAbility * wrapper = NEW GenericInstantAbility(1, source, (Damageable *) (this->target), a);
|
||||
wrapper->addToGame();
|
||||
return 1;
|
||||
}
|
||||
const char * ATransformerUEOT::getMenuText()
|
||||
{
|
||||
return "Transform";
|
||||
}
|
||||
|
||||
ATransformerUEOT * ATransformerUEOT::clone() const
|
||||
{
|
||||
ATransformerUEOT * a = NEW ATransformerUEOT(*this);
|
||||
a->ability = this->ability->clone();
|
||||
a->isClone = 1;
|
||||
return a;
|
||||
}
|
||||
|
||||
ATransformerUEOT::~ATransformerUEOT()
|
||||
{
|
||||
SAFE_DELETE(ability);
|
||||
}
|
||||
|
||||
// ATransformerFOREVER
|
||||
ATransformerFOREVER::ATransformerFOREVER(int id, MTGCardInstance * source, MTGCardInstance * target, string types, string abilities) :
|
||||
InstantAbility(id, source, target)
|
||||
{
|
||||
ability = NEW AForeverTransformer(id, source, target, types, abilities);
|
||||
aType = MTGAbility::STANDARD_BECOMES;
|
||||
}
|
||||
|
||||
int ATransformerFOREVER::resolve()
|
||||
{
|
||||
AForeverTransformer * a = ability->clone();
|
||||
GenericInstantAbility * wrapper = NEW GenericInstantAbility(1, source, (Damageable *) (this->target), a);
|
||||
wrapper->addToGame();
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char * ATransformerFOREVER::getMenuText()
|
||||
{
|
||||
return "Transform";
|
||||
}
|
||||
|
||||
ATransformerFOREVER * ATransformerFOREVER::clone() const
|
||||
{
|
||||
ATransformerFOREVER * a = NEW ATransformerFOREVER(*this);
|
||||
a->ability = this->ability->clone();
|
||||
a->isClone = 1;
|
||||
return a;
|
||||
}
|
||||
|
||||
ATransformerFOREVER::~ATransformerFOREVER()
|
||||
{
|
||||
SAFE_DELETE(ability);
|
||||
}
|
||||
|
||||
// ASwapPTUEOT
|
||||
ASwapPTUEOT::ASwapPTUEOT(int id, MTGCardInstance * source, MTGCardInstance * target) :
|
||||
InstantAbility(id, source, target)
|
||||
{
|
||||
ability = NEW ASwapPT(id, source, target);
|
||||
}
|
||||
|
||||
int ASwapPTUEOT::resolve()
|
||||
{
|
||||
ASwapPT * a = ability->clone();
|
||||
GenericInstantAbility * wrapper = NEW GenericInstantAbility(1, source, (Damageable *) (this->target), a);
|
||||
wrapper->addToGame();
|
||||
return 1;
|
||||
}
|
||||
|
||||
ASwapPTUEOT * ASwapPTUEOT::clone() const
|
||||
{
|
||||
ASwapPTUEOT * a = NEW ASwapPTUEOT(*this);
|
||||
a->ability = this->ability->clone();
|
||||
a->isClone = 1;
|
||||
return a;
|
||||
}
|
||||
|
||||
ASwapPTUEOT::~ASwapPTUEOT()
|
||||
{
|
||||
SAFE_DELETE(ability);
|
||||
}
|
||||
|
||||
// ABecomes
|
||||
ABecomes::ABecomes(int id, MTGCardInstance * source, MTGCardInstance * target, string stypes, WParsedPT * wppt, string sabilities) :
|
||||
MTGAbility(id, source, target), wppt(wppt)
|
||||
@@ -324,7 +675,8 @@ ABecomes::~ABecomes()
|
||||
// ABecomes
|
||||
|
||||
// ABecomesUEOT
|
||||
ABecomesUEOT::ABecomesUEOT(int id, MTGCardInstance * source, MTGCardInstance * target, string types, WParsedPT * wpt, string abilities) :
|
||||
ABecomesUEOT::ABecomesUEOT(int id, MTGCardInstance * source, MTGCardInstance * target, string types, WParsedPT * wpt,
|
||||
string abilities) :
|
||||
InstantAbility(id, source, target)
|
||||
{
|
||||
ability = NEW ABecomes(id, source, target, types, wpt, abilities);
|
||||
|
||||
Reference in New Issue
Block a user