add support for activated copier

thespian stage etc...
This commit is contained in:
Anthony Calosa
2017-01-31 20:11:09 +08:00
parent 7029636291
commit 41d925d7c9
5 changed files with 67 additions and 5 deletions
+1
View File
@@ -2055,6 +2055,7 @@ public:
class AACopier: public ActivatedAbility class AACopier: public ActivatedAbility
{ {
public: public:
bool isactivated;
vector<MTGAbility *> currentAbilities; vector<MTGAbility *> currentAbilities;
MTGAbility * andAbility; MTGAbility * andAbility;
AACopier(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target = NULL, ManaCost * _cost = NULL); AACopier(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target = NULL, ManaCost * _cost = NULL);
+1
View File
@@ -123,6 +123,7 @@ public:
MTGCardInstance * previous; MTGCardInstance * previous;
MTGCardInstance * next; MTGCardInstance * next;
MTGAbility * TokenAndAbility; MTGAbility * TokenAndAbility;
MTGAbility * GrantedAndAbility;
int doDamageTest; int doDamageTest;
bool skipDamageTestOnce; bool skipDamageTestOnce;
int summoningSickness; int summoningSickness;
+54
View File
@@ -1539,6 +1539,7 @@ AACopier::AACopier(GameObserver* observer, int _id, MTGCardInstance * _source, M
{ {
target = _target; target = _target;
andAbility = NULL; andAbility = NULL;
isactivated = false;
} }
int AACopier::resolve() int AACopier::resolve()
@@ -1546,6 +1547,8 @@ int AACopier::resolve()
MTGCardInstance * _target = (MTGCardInstance *) target; MTGCardInstance * _target = (MTGCardInstance *) target;
if (_target) if (_target)
{ {
if(isactivated)
source->isPhased = true;
bool tokencopied = false; bool tokencopied = false;
if(_target->isToken || (_target->isACopier && _target->hasCopiedToken)) if(_target->isToken || (_target->isACopier && _target->hasCopiedToken))
tokencopied = true; tokencopied = true;
@@ -1606,6 +1609,57 @@ int AACopier::resolve()
TokenandAbilityClone->addToGame(); TokenandAbilityClone->addToGame();
} }
} }
if(isactivated)
{//activated version grant
source->GrantedAndAbility = andAbility;
AbilityFactory af(game);
for(unsigned int i = 0;i < source->cardsAbilities.size();i++)
{
MTGAbility * a = dynamic_cast<MTGAbility *>(source->cardsAbilities[i]);
if(a) game->removeObserver(a);
}
source->cardsAbilities.clear();
source->magicText = _target->magicText;
af.getAbilities(&currentAbilities, NULL, source);
for (size_t i = 0; i < currentAbilities.size(); ++i)
{
MTGAbility * a = currentAbilities[i];
a->source = (MTGCardInstance *) source;
if (a)
{
if (a->oneShot)
{
SAFE_DELETE(a);
}
else
{
a->addToGame();
MayAbility * dontAdd = dynamic_cast<MayAbility*>(a);
if(!dontAdd)
{
source->cardsAbilities.push_back(a);
}
}
}
}
if(source->GrantedAndAbility)
{
MTGAbility * andAbilityClone = source->GrantedAndAbility->clone();
andAbilityClone->target = source;
if(andAbility->oneShot)
{
andAbilityClone->resolve();
SAFE_DELETE(andAbilityClone);
}
else
{
andAbilityClone->addToGame();
}
}
source->isPhased = false;
}
return 1; return 1;
} }
return 0; return 0;
+1
View File
@@ -2781,6 +2781,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
MTGAbility * a = NEW AACopier(observer, id, card, target); MTGAbility * a = NEW AACopier(observer, id, card, target);
a->oneShot = 1; a->oneShot = 1;
a->canBeInterrupted = false; a->canBeInterrupted = false;
((AACopier*)a)->isactivated = activated;
//andability //andability
if(storedAndAbility.size()) if(storedAndAbility.size())
{ {
+10 -5
View File
@@ -140,11 +140,15 @@ void MTGCardInstance::copy(MTGCardInstance * card)
int castMethodBackUP = this->castMethod; int castMethodBackUP = this->castMethod;
mtgid = source->getId(); mtgid = source->getId();
MTGCardInstance * oldStored = this->storedSourceCard; MTGCardInstance * oldStored = this->storedSourceCard;
Spell * spell = NEW Spell(observer, this); if(!isPhased)
observer = card->observer; {
AbilityFactory af(observer); Spell * spell = NEW Spell(observer, this);
af.addAbilities(observer->mLayers->actionLayer()->getMaxId(), spell); observer = card->observer;
delete spell; AbilityFactory af(observer);
af.addAbilities(observer->mLayers->actionLayer()->getMaxId(), spell);
delete spell;
}
if(observer->players[1]->playMode == Player::MODE_TEST_SUITE) if(observer->players[1]->playMode == Player::MODE_TEST_SUITE)
mtgid = backupid; // there must be a way to get the token id... mtgid = backupid; // there must be a way to get the token id...
else else
@@ -284,6 +288,7 @@ void MTGCardInstance::initMTGCI()
previous = NULL; previous = NULL;
next = NULL; next = NULL;
TokenAndAbility = NULL; TokenAndAbility = NULL;
GrantedAndAbility = NULL;
lastController = NULL; lastController = NULL;
regenerateTokens = 0; regenerateTokens = 0;
blocked = false; blocked = false;