Search in sources :

Example 1 with MadnessCardExiledEvent

use of mage.game.events.MadnessCardExiledEvent in project mage by magefree.

the class MadnessCastEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    Card card = game.getCard(event.getTargetId());
    if (card == null) {
        return false;
    }
    // TODO, deal with deprecated call
    if (controller.moveCardToExileWithInfo(card, source.getSourceId(), "Madness", source, game, ((ZoneChangeEvent) event).getFromZone(), true)) {
        // needed to add Madness ability to cards (e.g. by Falkenrath Gorger)
        game.applyEffects();
        GameEvent gameEvent = new MadnessCardExiledEvent(card.getId(), source, controller.getId());
        game.fireEvent(gameEvent);
    }
    return true;
}
Also used : Player(mage.players.Player) GameEvent(mage.game.events.GameEvent) MadnessCardExiledEvent(mage.game.events.MadnessCardExiledEvent) Card(mage.cards.Card)

Aggregations

Card (mage.cards.Card)1 GameEvent (mage.game.events.GameEvent)1 MadnessCardExiledEvent (mage.game.events.MadnessCardExiledEvent)1 Player (mage.players.Player)1