Search in sources :

Example 1 with CanPlayCardControllerEffect

use of mage.abilities.effects.common.asthought.CanPlayCardControllerEffect 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

CanPlayCardControllerEffect (mage.abilities.effects.common.asthought.CanPlayCardControllerEffect)1 YouMaySpendManaAsAnyColorToCastTargetEffect (mage.abilities.effects.common.asthought.YouMaySpendManaAsAnyColorToCastTargetEffect)1 Hint (mage.abilities.hint.Hint)1 FixedTarget (mage.target.targetpointer.FixedTarget)1