Totem Armor
This commit is contained in:
@@ -2855,7 +2855,13 @@ int AABuryCard::resolve()
|
||||
MTGCardInstance * _target = (MTGCardInstance *) target;
|
||||
if (_target)
|
||||
{
|
||||
_target->bury();
|
||||
//Bury (Obsolete)
|
||||
//A term that meant “put [a permanent] into its owner’s graveyard.”
|
||||
//In general, cards that were printed with the term “bury” have received errata
|
||||
//in the Oracle card reference to read, “Destroy [a permanent]. It can’t be regenerated,”
|
||||
//or “Sacrifice [a permanent].”
|
||||
//_target->bury();
|
||||
_target->destroyNoRegen();//so totem armor will take effect on wrath effects since totem armor is not regeneration..
|
||||
while(_target->next)
|
||||
_target = _target->next;
|
||||
if(andAbility)
|
||||
@@ -3221,6 +3227,10 @@ int AANewTarget::resolve()
|
||||
while (_target->next)
|
||||
_target = _target->next;
|
||||
}
|
||||
if(_target->hasSubtype(Subtypes::TYPE_AURA))
|
||||
{
|
||||
_target->target = source;
|
||||
}
|
||||
if(_target->hasSubtype(Subtypes::TYPE_EQUIPMENT))
|
||||
{
|
||||
for (size_t i = 1; i < game->mLayers->actionLayer()->mObjects.size(); i++)
|
||||
|
||||
@@ -445,7 +445,51 @@ int MTGCardInstance::afterDamage()
|
||||
return 0;
|
||||
}
|
||||
|
||||
int MTGCardInstance::bury()
|
||||
int MTGCardInstance::totem(bool noregen)
|
||||
{
|
||||
int testToughness = toughness;
|
||||
testToughness += tbonus;
|
||||
if(testToughness < 1)
|
||||
{
|
||||
if(noregen)
|
||||
return toGrave();
|
||||
else if (!triggerRegenerate())
|
||||
return toGrave();
|
||||
return 0;
|
||||
}
|
||||
bool canregen = (regenerateTokens && !has(Constants::CANTREGEN) && !noregen);
|
||||
vector<MTGAbility*>selection;
|
||||
TargetChooserFactory tf(getObserver());
|
||||
TargetChooser * tcb = tf.createTargetChooser("mytotem",this);
|
||||
tcb->targetter = NULL;
|
||||
tcb->maxtargets = 1;
|
||||
MTGAbility * destroyTotem = NEW ATriggerTotem(getObserver(), getObserver()->mLayers->actionLayer()->getMaxId(),this,NULL);
|
||||
destroyTotem->oneShot = true;
|
||||
destroyTotem->canBeInterrupted = false;
|
||||
MTGAbility * dtTarget = NEW GenericTargetAbility(getObserver(), "","",getObserver()->mLayers->actionLayer()->getMaxId(), this,tcb->clone(), destroyTotem->clone());
|
||||
SAFE_DELETE(destroyTotem);
|
||||
dtTarget->oneShot = true;
|
||||
dtTarget->canBeInterrupted = false;
|
||||
MTGAbility * addTotemtoGame = NEW GenericAddToGame(getObserver(), getObserver()->mLayers->actionLayer()->getMaxId(), this,NULL,dtTarget->clone());
|
||||
SAFE_DELETE(dtTarget);
|
||||
addTotemtoGame->oneShot = true;
|
||||
addTotemtoGame->canBeInterrupted = false;
|
||||
selection.push_back(addTotemtoGame->clone());
|
||||
SAFE_DELETE(addTotemtoGame);
|
||||
SAFE_DELETE(tcb);
|
||||
if(canregen)
|
||||
{
|
||||
MTGAbility * triggerRegen = NEW ATriggerRegen(getObserver(), getObserver()->mLayers->actionLayer()->getMaxId(), this, this);
|
||||
triggerRegen->oneShot = true;
|
||||
triggerRegen->canBeInterrupted = false;
|
||||
selection.push_back(triggerRegen->clone());
|
||||
SAFE_DELETE(triggerRegen);
|
||||
}
|
||||
MTGAbility * menuChoice = NEW MenuAbility(getObserver(), getObserver()->mLayers->actionLayer()->getMaxId(), NULL, this,true,selection,this->controller(),"");
|
||||
menuChoice->addToGame();
|
||||
return 1;
|
||||
}
|
||||
int MTGCardInstance::toGrave( bool forced )
|
||||
{
|
||||
Player * p = controller();
|
||||
if (basicAbilities[(int)Constants::EXILEDEATH])
|
||||
@@ -458,15 +502,29 @@ int MTGCardInstance::bury()
|
||||
p->game->putInZone(this, p->game->inPlay, owner->game->graveyard);
|
||||
return 1;
|
||||
}
|
||||
if (forced)
|
||||
{
|
||||
p->game->putInZone(this, p->game->inPlay, owner->game->graveyard);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int MTGCardInstance::destroy()
|
||||
{
|
||||
if (!triggerRegenerate())
|
||||
return bury();
|
||||
if (hasTotemArmor())
|
||||
return totem();
|
||||
else if (!triggerRegenerate())
|
||||
return toGrave();
|
||||
return 0;
|
||||
}
|
||||
int MTGCardInstance::destroyNoRegen()
|
||||
{
|
||||
if (hasTotemArmor())
|
||||
return totem(true);
|
||||
else
|
||||
return toGrave();
|
||||
return 0;
|
||||
}
|
||||
|
||||
MTGGameZone * MTGCardInstance::getCurrentZone()
|
||||
{
|
||||
return currentZone;
|
||||
@@ -1525,6 +1583,32 @@ bool MTGCardInstance::matchesCastFilter(int castFilter) {
|
||||
return (castFilter == castMethod);
|
||||
};
|
||||
|
||||
bool MTGCardInstance::hasTotemArmor()
|
||||
{
|
||||
int count = 0;
|
||||
if(observer)
|
||||
{
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
int nb_cards = observer->players[i]->game->battlefield->nb_cards;
|
||||
for(int x = 0; x < nb_cards; x++)
|
||||
{
|
||||
if(observer->players[i]->game->battlefield->cards[x]->auraParent)
|
||||
{
|
||||
if(observer->players[i]->game->battlefield->cards[x]->auraParent == this &&
|
||||
observer->players[i]->game->battlefield->cards[x]->has(Constants::TOTEMARMOR))
|
||||
count+=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(count)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int MTGCardInstance::addProtection(TargetChooser * tc)
|
||||
{
|
||||
tc->targetter = NULL;
|
||||
|
||||
@@ -185,7 +185,8 @@ const char* Constants::MTGBasicAbilities[] = {
|
||||
"canplayartifactlibrarytop",//artifact
|
||||
"canplayinstantsorcerylibrarytop",//instant or sorcery
|
||||
"showfromtoplibrary",
|
||||
"showopponenttoplibrary"
|
||||
"showopponenttoplibrary",
|
||||
"totemarmor"
|
||||
};
|
||||
|
||||
map<string,int> Constants::MTGBasicAbilitiesMap;
|
||||
|
||||
@@ -3741,7 +3741,7 @@ int MTGPlaneswalkerDamage::receiveEvent(WEvent * event)
|
||||
if(removel->removed && removel->targetCard && removel->targetCard->hasType(Subtypes::TYPE_PLANESWALKER))
|
||||
if(!removel->targetCard->counters->hasCounter("loyalty",0,0))
|
||||
{
|
||||
removel->targetCard->bury();
|
||||
removel->targetCard->toGrave(true);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,6 +55,13 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
|
||||
return NEW ChildrenChooser(observer, card, maxtargets);
|
||||
};
|
||||
|
||||
found = s.find("mytotem");
|
||||
if (found == 0)
|
||||
{
|
||||
int maxtargets = 1;
|
||||
return NEW TotemChooser(observer, card, maxtargets);
|
||||
};
|
||||
|
||||
found = s.find("targetedplayer");
|
||||
if (found == 0)
|
||||
{
|
||||
@@ -220,6 +227,7 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
|
||||
zones[nbzones++] = MTGGameZone::MY_LIBRARY;
|
||||
zones[nbzones++] = MTGGameZone::MY_HAND;
|
||||
zones[nbzones++] = MTGGameZone::MY_EXILE;
|
||||
zones[nbzones++] = MTGGameZone::MY_SIDEBOARD;
|
||||
}
|
||||
else if (zoneName.compare("opponentcastingzone") == 0)
|
||||
{
|
||||
@@ -2061,3 +2069,42 @@ bool ChildrenChooser::equals(TargetChooser * tc)
|
||||
ChildrenChooser::~ChildrenChooser()
|
||||
{
|
||||
}
|
||||
|
||||
//totem armor chooser
|
||||
bool TotemChooser::canTarget(Targetable * target,bool withoutProtections)
|
||||
{
|
||||
if (MTGCardInstance * card = dynamic_cast<MTGCardInstance*>(target))
|
||||
{
|
||||
if(card == source)
|
||||
return false;
|
||||
if(!card->isInPlay(observer))
|
||||
return false;
|
||||
if(card->auraParent)
|
||||
{
|
||||
if((card->auraParent) == source && (card->has(Constants::TOTEMARMOR)))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
TotemChooser* TotemChooser::clone() const
|
||||
{
|
||||
TotemChooser * a = NEW TotemChooser(*this);
|
||||
return a;
|
||||
}
|
||||
|
||||
bool TotemChooser::equals(TargetChooser * tc)
|
||||
{
|
||||
|
||||
TotemChooser * dtc = dynamic_cast<TotemChooser *> (tc);
|
||||
if (!dtc)
|
||||
return false;
|
||||
|
||||
return TypeTargetChooser::equals(tc);
|
||||
}
|
||||
|
||||
TotemChooser::~TotemChooser()
|
||||
{
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user