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

View File

@@ -2055,6 +2055,7 @@ public:
class AACopier: public ActivatedAbility
{
public:
bool isactivated;
vector<MTGAbility *> currentAbilities;
MTGAbility * andAbility;
AACopier(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target = NULL, ManaCost * _cost = NULL);

View File

@@ -123,6 +123,7 @@ public:
MTGCardInstance * previous;
MTGCardInstance * next;
MTGAbility * TokenAndAbility;
MTGAbility * GrantedAndAbility;
int doDamageTest;
bool skipDamageTestOnce;
int summoningSickness;

View File

@@ -1539,6 +1539,7 @@ AACopier::AACopier(GameObserver* observer, int _id, MTGCardInstance * _source, M
{
target = _target;
andAbility = NULL;
isactivated = false;
}
int AACopier::resolve()
@@ -1546,6 +1547,8 @@ int AACopier::resolve()
MTGCardInstance * _target = (MTGCardInstance *) target;
if (_target)
{
if(isactivated)
source->isPhased = true;
bool tokencopied = false;
if(_target->isToken || (_target->isACopier && _target->hasCopiedToken))
tokencopied = true;
@@ -1606,6 +1609,57 @@ int AACopier::resolve()
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 0;

View File

@@ -2781,6 +2781,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
MTGAbility * a = NEW AACopier(observer, id, card, target);
a->oneShot = 1;
a->canBeInterrupted = false;
((AACopier*)a)->isactivated = activated;
//andability
if(storedAndAbility.size())
{

View File

@@ -140,11 +140,15 @@ void MTGCardInstance::copy(MTGCardInstance * card)
int castMethodBackUP = this->castMethod;
mtgid = source->getId();
MTGCardInstance * oldStored = this->storedSourceCard;
Spell * spell = NEW Spell(observer, this);
observer = card->observer;
AbilityFactory af(observer);
af.addAbilities(observer->mLayers->actionLayer()->getMaxId(), spell);
delete spell;
if(!isPhased)
{
Spell * spell = NEW Spell(observer, this);
observer = card->observer;
AbilityFactory af(observer);
af.addAbilities(observer->mLayers->actionLayer()->getMaxId(), spell);
delete spell;
}
if(observer->players[1]->playMode == Player::MODE_TEST_SUITE)
mtgid = backupid; // there must be a way to get the token id...
else
@@ -284,6 +288,7 @@ void MTGCardInstance::initMTGCI()
previous = NULL;
next = NULL;
TokenAndAbility = NULL;
GrantedAndAbility = NULL;
lastController = NULL;
regenerateTokens = 0;
blocked = false;