Fixed Legend rule for mutating cards, avoided spell targeting for mutated down cards, added new primitives.

This commit is contained in:
valfieri
2020-06-14 14:03:00 +02:00
parent 2b398b425d
commit 587155353c
6 changed files with 128 additions and 76 deletions
+24 -1
View File
@@ -1,7 +1,7 @@
#include "PrecompiledHeader.h"
#include "AllAbilities.h"
#include "Translate.h"
#include "MTGRules.h"
//display a text animation, this is not a real ability.
MTGEventText::MTGEventText(GameObserver* observer, int _id, MTGCardInstance * card, string textToShow) :
@@ -1606,6 +1606,7 @@ int AACopier::resolve()
MTGCardInstance * _target = (MTGCardInstance *) target;
if (_target)
{
if(_target->mutation && _target->parentCards.size() > 0) return 0; // Mutated down cards cannot be copied, they will follow the fate of top-card
bool tokencopied = false;
if(_target->isToken || (_target->isACopier && _target->hasCopiedToken))
tokencopied = true;
@@ -1756,6 +1757,7 @@ int AAPhaseOut::resolve()
MTGCardInstance * _target = (MTGCardInstance *) target;
if (_target)
{
if(_target->mutation && _target->parentCards.size() > 0) return 0; // Mutated down cards cannot be phased out, they will follow the fate of top-card
_target->isPhased = true;
_target->phasedTurn = game->turn;
@@ -1792,6 +1794,7 @@ int AAImprint::resolve()
MTGCardInstance * _target = (MTGCardInstance *) target;
if (_target)
{
if(_target->mutation && _target->parentCards.size() > 0) return 0; // Mutated down cards cannot be imprinted, they will follow the fate of top-card
Player * p = _target->controller();
if(p)
p->game->putInExile(_target);
@@ -2893,6 +2896,7 @@ int AABuryCard::resolve()
MTGCardInstance * _target = (MTGCardInstance *) target;
if (_target)
{
if(_target->mutation && _target->parentCards.size() > 0) return 0; // Mutated down cards cannot be buried, they will follow the fate of top-card
//Bury (Obsolete)
//A term that meant “put [a permanent] into its owners graveyard.”
//In general, cards that were printed with the term “bury” have received errata
@@ -2955,6 +2959,7 @@ int AADestroyCard::resolve()
MTGCardInstance * _target = (MTGCardInstance *) target;
if (_target)
{
if(_target->mutation && _target->parentCards.size() > 0) return 0; // Mutated down cards cannot be destroyed, they will follow the fate of top-card
_target->destroy();
while(_target->next)
_target = _target->next;
@@ -3007,6 +3012,7 @@ int AASacrificeCard::resolve()
MTGCardInstance * _target = (MTGCardInstance *) target;
if (_target)
{
if(_target->mutation && _target->parentCards.size() > 0) return 0; // Mutated down cards cannot be sacrificed, they will follow the fate of top-card
Player * p = _target->controller();
MTGCardInstance * beforeCard = _target;
p->game->putInGraveyard(_target);
@@ -3184,6 +3190,7 @@ int AAFrozen::resolve()
MTGCardInstance * _target = (MTGCardInstance *) target;
if (_target)
{
if(_target->mutation && _target->parentCards.size() > 0) return 0; // Mutated down cards cannot be frozen, they will follow the fate of top-card
while (_target->next)
_target = _target->next; //This is for cards such as rampant growth
if (freeze)
@@ -3329,6 +3336,11 @@ int AANewTarget::resolve()
source->types[0] = 7;
source->types[1] = 1;
}
if(source->hasType(Subtypes::TYPE_LEGENDARY)){ // Check if the mutated card is a duplicated legendary card
MTGNewLegend *testlegend = NEW MTGNewLegend(source->getObserver(),source->getObserver()->mLayers->actionLayer()->getMaxId());
testlegend->CheckLegend(source);
SAFE_DELETE(testlegend);
}
}
for (unsigned int i = 0; i < (unsigned int)Constants::NB_BASIC_ABILITIES; i++){
if(_target->basicAbilities[i] == 1){
@@ -3388,6 +3400,7 @@ int AAMorph::resolve()
MTGCardInstance * _target = (MTGCardInstance *) target;
if (_target)
{
if(_target->mutation && _target->parentCards.size() > 0) return 0; // Mutated down cards cannot be morphed, they will follow the fate of top-card
while (_target->next)
_target = _target->next;
@@ -3505,6 +3518,7 @@ int AAMeld::resolve()
MTGCardInstance * _target = (MTGCardInstance *)target;
if (_target && _target->controller() == source->controller() && _target->owner == source->owner && !_target->isToken && !source->isToken)
{
if(_target->mutation && _target->parentCards.size() > 0) return 0; // Mutated down cards cannot be melded, they will follow the fate of top-card
source->controller()->game->putInExile(source);
_target->controller()->game->putInExile(_target);
source->next->controller()->game->putInZone(source->next, source->next->currentZone, source->next->controller()->game->temp);
@@ -3550,6 +3564,7 @@ int AAFlip::resolve()
MTGCardInstance * _target = (MTGCardInstance *) target;
if (_target)
{
if(_target->mutation && _target->parentCards.size() > 0) return 0; // Mutated down cards cannot be flipped, they will follow the fate of top-card
if(((_target->isACopier||_target->isToken) && !isflipcard) || _target->has(Constants::CANTTRANSFORM))
{
game->removeObserver(this);
@@ -4374,6 +4389,7 @@ int AACloner::resolve()
MTGCardInstance * _target = (MTGCardInstance *) target;
if (!_target)
return 0;
if(_target->mutation && _target->parentCards.size() > 0) return 0; // Mutated down cards cannot be cloned, they will follow the fate of top-card
MTGCard * clone = NULL;
@@ -4649,6 +4665,7 @@ int AAMover::resolve()
MTGCardInstance * _target = (MTGCardInstance *) target;
if (target)
{
if(_target->mutation && _target->parentCards.size() > 0) return 0; // Mutated down cards cannot be moved to any zone, they will follow the fate of top-card
if(necro)
_target->basicAbilities[Constants::NECROED] = 1;
Player* p = _target->controller();
@@ -4888,6 +4905,7 @@ int AARandomMover::resolve()
MTGCardInstance * _target = (MTGCardInstance *) target;
if (target)
{
if(_target->mutation && _target->parentCards.size() > 0) return 0; // Mutated down cards cannot be randomly moved to any zone, they will follow the fate of top-card
Player* p = _target->controller();
if (p)
{
@@ -5201,6 +5219,7 @@ int AATapper::resolve()
MTGCardInstance * _target = (MTGCardInstance *) target;
if (_target)
{
if(_target->mutation && _target->parentCards.size() > 0) return 0; // Mutated down cards cannot be tapped, they will follow the fate of top-card
while (_target->next)
_target = _target->next; //This is for cards such as rampant growth
_target->tap(_sendNoEvent);
@@ -5231,6 +5250,7 @@ int AAUntapper::resolve()
MTGCardInstance * _target = (MTGCardInstance *) target;
if (_target)
{
if(_target->mutation && _target->parentCards.size() > 0) return 0; // Mutated down cards cannot be untapped, they will follow the fate of top-card
while (_target->next)
_target = _target->next; //This is for cards such as rampant growth
_target->untap();
@@ -8013,6 +8033,7 @@ InstantAbility(observer, id, card, target)
int AABlock::resolve()
{
MTGCardInstance * _target = (MTGCardInstance *) target;
if(_target->mutation && _target->parentCards.size() > 0) return 0; // Mutated down cards cannot be blocked, they will follow the fate of top-card
source = (MTGCardInstance*)source;
if (_target && source->canBlock(_target))
{
@@ -8064,6 +8085,7 @@ InstantAbility(observer, id, card, target)
int dredgeCard::resolve()
{
MTGCardInstance * _target = (MTGCardInstance *) target;
if(_target->mutation && _target->parentCards.size() > 0) return 0; // Mutated down cards cannot be dredged, they will follow the fate of top-card
if(_target)
{
for(int j = 0; j < _target->data->dredge();j++)
@@ -8092,6 +8114,7 @@ InstantAbility(observer, id, card, target)
int AAConnect::resolve()
{
MTGCardInstance * _target = (MTGCardInstance *) target;
if(_target->mutation && _target->parentCards.size() > 0) return 0; // Mutated down cards cannot be connected, they will follow the fate of top-card
if (_target)
{
while (_target->next)
+6
View File
@@ -1035,6 +1035,12 @@ void GameObserver::gameStateBasedEffects()
MTGCardInstance * card = f->cards[k];
card->fresh = 0;
}
MTGGameZone * fe = p->game->exile;
for (int k = 0; k < fe->nb_cards; k++)
{
MTGCardInstance * card = fe->cards[k]; // Remove fresh attribute to previous exiled cards
card->fresh = 0;
}
}
if (z->nb_cards == 0)
{
+1 -1
View File
@@ -928,7 +928,7 @@ int MTGCardInstance::countDuplicateCardNames()
int nb_cards = controller()->game->battlefield->nb_cards;
for(int x = 0; x < nb_cards; x++)
{
if(controller()->game->battlefield->cards[x]->name == this->name)
if(controller()->game->battlefield->cards[x]->name == this->name && !(controller()->game->battlefield->cards[x]->mutation && controller()->game->battlefield->cards[x]->parentCards.size() > 0)) // Don't count Mutated down card
count+=1;
}
}
+8 -2
View File
@@ -3290,6 +3290,10 @@ int MTGUnearthRule::receiveEvent(WEvent * event)
e->card->fresh = 1;
e->card->entersBattlefield = 1;
}
if (e->to == e->card->controller()->game->exile) // Apply fresh attribute for new exiled cards
{
e->card->fresh = 1;
}
if (card && card->basicAbilities[(int)Constants::UNEARTH])
{
@@ -3408,7 +3412,9 @@ int MTGNewLegend::receiveEvent(WEvent * e)
MTGCardInstance * card = ev1->card;
if(card && card->countDuplicateCardNames() > 1 && card->hasType(Subtypes::TYPE_LEGENDARY))
{
CheckLegend(card);
if(card->basicAbilities[(int)Constants::MUTATE] && card->alternateCostPaid[(int)ManaCost::MANA_PAID_WITH_ALTERNATIVE])
return 0; // The Leged rule for Mutating card will be checked later just if it's a Mutation Over choice
CheckLegend(card);
return 1;
}
}
@@ -3481,7 +3487,7 @@ void MTGNewLegend::MoveLegend(MTGCardInstance * card)
vector<MTGAbility*>selection;
MTGCardInstance * myClone = NEW MTGCardInstance(card, card->controller()->game);
TargetChooserFactory tfL(game);
tcL = tfL.createTargetChooser("*[share!name!]|mybattlefield",myClone);
tcL = tfL.createTargetChooser("*[-Mutated;share!name!]|mybattlefield",myClone); // The Mutated down cards cannot be considered as Legendary card anymore
tcL->targetter = NULL;
tcL->maxtargets = 1;
Legendrule = NEW AAMover(game, game->mLayers->actionLayer()->getMaxId(), myClone, NULL,"ownergraveyard","Put in Graveyard");