unearth rule

This commit is contained in:
Anthony Calosa
2017-03-15 06:35:30 +08:00
parent 417c1af21e
commit be1803dfb6
2 changed files with 37 additions and 20 deletions

View File

@@ -1028,26 +1028,6 @@ void GameObserver::gameStateBasedEffects()
c->ProvokeTarget = NULL;
c->Provoker = NULL;
}
for (int jj = z->nb_cards - 1; jj >= 0; jj--)
{
MTGCardInstance * c = z->cards[jj];
if(c && !c->isPhased)
{
if (c->has(Constants::TREASON))
{
MTGCardInstance * beforeCard = c;
p->game->putInZone(c, c->currentZone, c->owner->game->graveyard);
WEvent * e = NEW WEventCardSacrifice(beforeCard,c);
receiveEvent(e);
}
if (c->has(Constants::UNEARTH))
{
p->game->putInZone(c, c->currentZone, c->owner->game->exile);
}
}
}
MTGGameZone * f = p->game->graveyard;
for (int k = 0; k < f->nb_cards; k++)

View File

@@ -2531,7 +2531,11 @@ int MTGMomirRule::reactToClick(MTGCardInstance * card_to_discard, int cardId)
tokCreate = af.parseMagicLine(abi,game->mLayers->actionLayer()->getMaxId(),NULL, card->clone());
tokCreate->aType = MTGAbility::FORCED_TOKEN_CREATOR;
if(tokCreate)
{
if(tokCreate->source)
tokCreate->source->owner = player;
tokCreate->fireAbility();
}
alreadyplayed = 1;
textAlpha = 255;
@@ -3281,6 +3285,39 @@ int MTGUnearthRule::receiveEvent(WEvent * event)
}
}
}
else if (WEventPhaseChange* pe = dynamic_cast<WEventPhaseChange*>(event))
{
if (MTG_PHASE_ENDOFTURN == pe->from->id)
{
bool found = false;
for (int i = 0; i < 2; i++)
{
Player * p = game->players[i];
MTGGameZone * z = game->players[i]->game->inPlay;
for (int j = z->nb_cards - 1; j >= 0; j--)
{
MTGCardInstance * c = z->cards[j];
if(c && c->has(Constants::UNEARTH) && !c->isPhased)
{
found = true;
c->controller()->game->putInZone(c, c->currentZone, c->owner->game->exile);
}
else if(c && c->has(Constants::TREASON) && !c->isPhased)
{
found = true;
MTGCardInstance * beforeCard = c;
c->controller()->game->putInZone(c, c->currentZone, c->owner->game->graveyard);
WEvent * e = NEW WEventCardSacrifice(beforeCard,c);
game->receiveEvent(e);
}
}
}
if(found)
return 1;
}
return 0;
}
return 0;
}