Totem Armor
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user