Merge pull request #696 from kevlahnota/master

Imprint Class
This commit is contained in:
Anthony Calosa
2016-06-16 10:18:01 +08:00
committed by GitHub
4 changed files with 77 additions and 41 deletions
+11 -3
View File
@@ -1665,7 +1665,7 @@ public:
const string getMenuText(); const string getMenuText();
AACopier * clone() const; AACopier * clone() const;
}; };
//imprint //phaseout
class AAPhaseOut: public ActivatedAbility class AAPhaseOut: public ActivatedAbility
{ {
public: public:
@@ -1674,6 +1674,15 @@ public:
const string getMenuText(); const string getMenuText();
AAPhaseOut * clone() const; AAPhaseOut * clone() const;
}; };
//AAImprint
class AAImprint: public ActivatedAbility
{
public:
AAImprint(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target = NULL, ManaCost * _cost = NULL);
int resolve();
const string getMenuText();
AAImprint * clone() const;
};
//cloning...this makes a token thats a copy of the target. //cloning...this makes a token thats a copy of the target.
class AACloner: public ActivatedAbility class AACloner: public ActivatedAbility
{ {
@@ -1703,8 +1712,7 @@ public:
string named; string named;
bool undying; bool undying;
bool persist; bool persist;
bool imprint; AAMover(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target, string dest,string _name, ManaCost * _cost = NULL, bool undying = false, bool persist = false);
AAMover(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target, string dest,string _name, ManaCost * _cost = NULL, bool undying = false, bool persist = false, bool imprint = false);
MTGGameZone * destinationZone(Targetable * target = NULL); MTGGameZone * destinationZone(Targetable * target = NULL);
int resolve(); int resolve();
const string getMenuText(); const string getMenuText();
+57 -7
View File
@@ -511,7 +511,7 @@ AACopier * AACopier::clone() const
return NEW AACopier(*this); return NEW AACopier(*this);
} }
//phaser //phaseout
AAPhaseOut::AAPhaseOut(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target, ManaCost * _cost) : AAPhaseOut::AAPhaseOut(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target, ManaCost * _cost) :
ActivatedAbility(observer, _id, _source, _cost, 0) ActivatedAbility(observer, _id, _source, _cost, 0)
{ {
@@ -544,6 +544,60 @@ AAPhaseOut * AAPhaseOut::clone() const
return NEW AAPhaseOut(*this); return NEW AAPhaseOut(*this);
} }
//AAImprint
AAImprint::AAImprint(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target, ManaCost * _cost) :
ActivatedAbility(observer, _id, _source, _cost, 0)
{
target = _target;
}
int AAImprint::resolve()
{
MTGCardInstance * _target = (MTGCardInstance *) target;
if (_target)
{
Player * p = _target->controller();
if(p)
p->game->putInExile(_target);
while(_target->next)
_target = _target->next;
source->imprintedCards.push_back(_target);
if (source->imprintedCards.size())
{
if (source->imprintedCards.back()->hasColor(Constants::MTG_COLOR_GREEN))
source->imprintG += 1;
if (source->imprintedCards.back()->hasColor(Constants::MTG_COLOR_BLUE))
source->imprintU += 1;
if (source->imprintedCards.back()->hasColor(Constants::MTG_COLOR_RED))
source->imprintR += 1;
if (source->imprintedCards.back()->hasColor(Constants::MTG_COLOR_BLACK))
source->imprintB += 1;
if (source->imprintedCards.back()->hasColor(Constants::MTG_COLOR_WHITE))
source->imprintW += 1;
if (source->imprintedCards.back()->getName().size())
{
source->currentimprintName = source->imprintedCards.back()->getName();
source->imprintedNames.push_back(source->imprintedCards.back()->getName());
}
}
return 1;
}
return 0;
}
const string AAImprint::getMenuText()
{
return "Imprint";
}
AAImprint * AAImprint::clone() const
{
return NEW AAImprint(*this);
}
//Counters //Counters
AACounter::AACounter(GameObserver* observer, int id, MTGCardInstance * source, MTGCardInstance * target,string counterstring, const char * _name, int power, int toughness, AACounter::AACounter(GameObserver* observer, int id, MTGCardInstance * source, MTGCardInstance * target,string counterstring, const char * _name, int power, int toughness,
int nb,int maxNb, ManaCost * cost) : int nb,int maxNb, ManaCost * cost) :
@@ -2928,8 +2982,8 @@ AInstantCastRestrictionUEOT::~AInstantCastRestrictionUEOT()
//AAMover //AAMover
AAMover::AAMover(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target, string dest,string newName, ManaCost * _cost, bool undying, bool persist, bool imprint) : AAMover::AAMover(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target, string dest,string newName, ManaCost * _cost, bool undying, bool persist) :
ActivatedAbility(observer, _id, _source, _cost, 0), destination(dest),named(newName),undying(undying),persist(persist),imprint(imprint) ActivatedAbility(observer, _id, _source, _cost, 0), destination(dest),named(newName),undying(undying),persist(persist)
{ {
if (_target) if (_target)
target = _target; target = _target;
@@ -2987,8 +3041,6 @@ int AAMover::resolve()
p->game->putInZone(_target, fromZone, destZone); p->game->putInZone(_target, fromZone, destZone);
while(_target->next) while(_target->next)
_target = _target->next; _target = _target->next;
if (imprint)
source->imprintedCards.push_back(_target);
if(andAbility) if(andAbility)
{ {
MTGAbility * andAbilityClone = andAbility->clone(); MTGAbility * andAbilityClone = andAbility->clone();
@@ -3065,8 +3117,6 @@ const char* AAMover::getMenuText(TargetChooser * tc)
// move card into exile // move card into exile
else if (dest == game->players[i]->game->exile) else if (dest == game->players[i]->game->exile)
{ {
if(imprint)
return "Imprint";
return "Exile"; return "Exile";
} }
+2 -24
View File
@@ -693,11 +693,6 @@ void GameObserver::gameStateBasedEffects()
for(size_t ic = 0; ic < card->imprintedCards.size(); ic++) for(size_t ic = 0; ic < card->imprintedCards.size(); ic++)
{ {
if(!isInExile(card->imprintedCards[ic])) if(!isInExile(card->imprintedCards[ic]))
card->imprintedCards.erase(card->imprintedCards.begin() + ic);
}
}
//reset imprints
if(isInPlay(card))
{ {
card->imprintG = 0; card->imprintG = 0;
card->imprintU = 0; card->imprintU = 0;
@@ -705,25 +700,8 @@ void GameObserver::gameStateBasedEffects()
card->imprintB = 0; card->imprintB = 0;
card->imprintW = 0; card->imprintW = 0;
card->currentimprintName = ""; card->currentimprintName = "";
if (card->imprintedCards.size()) card->imprintedNames.clear();
{ card->imprintedCards.erase(card->imprintedCards.begin() + ic);
for(size_t i = 0; i < card->imprintedCards.size(); i++)
{
if (card->imprintedCards[i]->hasColor(Constants::MTG_COLOR_GREEN))
card->imprintG += 1;
if (card->imprintedCards[i]->hasColor(Constants::MTG_COLOR_BLUE))
card->imprintU += 1;
if (card->imprintedCards[i]->hasColor(Constants::MTG_COLOR_RED))
card->imprintR += 1;
if (card->imprintedCards[i]->hasColor(Constants::MTG_COLOR_BLACK))
card->imprintB += 1;
if (card->imprintedCards[i]->hasColor(Constants::MTG_COLOR_WHITE))
card->imprintW += 1;
if (card->imprintedCards[i]->getName().size())
{
card->currentimprintName = card->imprintedCards[i]->getName();
card->imprintedNames.push_back(card->imprintedCards[i]->getName());
}
} }
} }
} }
+1 -1
View File
@@ -2378,7 +2378,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
found = s.find("imprint"); found = s.find("imprint");
if (found != string::npos) if (found != string::npos)
{ {
MTGAbility * a = NEW AAMover(observer, id, card, target, "exile",newName,NULL,false,false,true); MTGAbility * a = NEW AAImprint(observer, id, card, target);
a->oneShot = 1; a->oneShot = 1;
return a; return a;
} }