Search in sources :

Example 1 with YouMaySpendManaAsAnyColorToCastTargetEffect

use of mage.abilities.effects.common.asthought.YouMaySpendManaAsAnyColorToCastTargetEffect in project mage by magefree.

the class RobberOfTheRichEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Player damagedPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source));
    if (controller == null || damagedPlayer == null) {
        return false;
    }
    Card card = damagedPlayer.getLibrary().getFromTop(game);
    if (card == null) {
        return false;
    }
    // move card to exile
    controller.moveCardsToExile(card, source, game, true, CardUtil.getExileZoneId(game, source), CardUtil.getSourceName(game, source));
    // don't worry about land
    if (card.getSpellAbility() != null) {
        // the exiled card is independent and requires a new ability in case the Robber leaves the battlefield
        // the exiled card can be cast throughout the entire game as long as the controller attacked with a rogue that turn
        Ability copiedAbility = source.copy();
        copiedAbility.newId();
        copiedAbility.setSourceId(card.getId());
        copiedAbility.setControllerId(source.getControllerId());
        PlayFromNotOwnHandZoneTargetEffect playFromExile = new PlayFromNotOwnHandZoneTargetEffect(Zone.EXILED, Duration.EndOfGame);
        YouMaySpendManaAsAnyColorToCastTargetEffect spendAnyMana = new YouMaySpendManaAsAnyColorToCastTargetEffect(Duration.EndOfGame);
        ConditionalAsThoughEffect castOnlyIfARogueAttackedThisTurn = new ConditionalAsThoughEffect(playFromExile, new RogueAttackedThisTurnCondition(copiedAbility));
        playFromExile.setTargetPointer(new FixedTarget(card, game));
        spendAnyMana.setTargetPointer(new FixedTarget(card, game));
        castOnlyIfARogueAttackedThisTurn.setTargetPointer(new FixedTarget(card, game));
        game.addEffect(castOnlyIfARogueAttackedThisTurn, copiedAbility);
        game.addEffect(spendAnyMana, copiedAbility);
        return true;
    }
    return false;
}
Also used : AttacksTriggeredAbility(mage.abilities.common.AttacksTriggeredAbility) HasteAbility(mage.abilities.keyword.HasteAbility) ReachAbility(mage.abilities.keyword.ReachAbility) ConditionalInterveningIfTriggeredAbility(mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility) Ability(mage.abilities.Ability) FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) PlayFromNotOwnHandZoneTargetEffect(mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect) ConditionalAsThoughEffect(mage.abilities.decorator.ConditionalAsThoughEffect) YouMaySpendManaAsAnyColorToCastTargetEffect(mage.abilities.effects.common.asthought.YouMaySpendManaAsAnyColorToCastTargetEffect) Card(mage.cards.Card)

Example 2 with YouMaySpendManaAsAnyColorToCastTargetEffect

use of mage.abilities.effects.common.asthought.YouMaySpendManaAsAnyColorToCastTargetEffect in project mage by magefree.

the class CardUtil method makeCardPlayable.

/**
 * Add effects to game that allows to play/cast card from current zone and spend mana as any type for it.
 * Effects will be discarded/ignored on any card movements or blinks (after ZCC change)
 * <p>
 * Affected to all card's parts
 *
 * @param game
 * @param card
 * @param duration
 * @param anyColor
 * @param condition can be null
 */
public static void makeCardPlayable(Game game, Ability source, Card card, Duration duration, boolean anyColor, UUID playerId, Condition condition) {
    // Effect can be used for cards in zones and permanents on battlefield
    // PermanentCard's ZCC is static, but we need updated ZCC from the card (after moved to another zone)
    // So there is a workaround to get actual card's ZCC
    // Example: Hostage Taker
    UUID objectId = card.getMainCard().getId();
    int zcc = game.getState().getZoneChangeCounter(objectId);
    game.addEffect(new CanPlayCardControllerEffect(game, objectId, zcc, duration, playerId, condition), source);
    if (anyColor) {
        game.addEffect(new YouMaySpendManaAsAnyColorToCastTargetEffect(duration, playerId, condition).setTargetPointer(new FixedTarget(objectId, zcc)), source);
    }
}
Also used : CanPlayCardControllerEffect(mage.abilities.effects.common.asthought.CanPlayCardControllerEffect) FixedTarget(mage.target.targetpointer.FixedTarget) YouMaySpendManaAsAnyColorToCastTargetEffect(mage.abilities.effects.common.asthought.YouMaySpendManaAsAnyColorToCastTargetEffect) Hint(mage.abilities.hint.Hint)

Aggregations

YouMaySpendManaAsAnyColorToCastTargetEffect (mage.abilities.effects.common.asthought.YouMaySpendManaAsAnyColorToCastTargetEffect)2 FixedTarget (mage.target.targetpointer.FixedTarget)2 Ability (mage.abilities.Ability)1 AttacksTriggeredAbility (mage.abilities.common.AttacksTriggeredAbility)1 ConditionalAsThoughEffect (mage.abilities.decorator.ConditionalAsThoughEffect)1 ConditionalInterveningIfTriggeredAbility (mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility)1 CanPlayCardControllerEffect (mage.abilities.effects.common.asthought.CanPlayCardControllerEffect)1 PlayFromNotOwnHandZoneTargetEffect (mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect)1 Hint (mage.abilities.hint.Hint)1 HasteAbility (mage.abilities.keyword.HasteAbility)1 ReachAbility (mage.abilities.keyword.ReachAbility)1 Card (mage.cards.Card)1 Player (mage.players.Player)1