Search in sources :

Example 1 with TransformSourceEffect

use of mage.abilities.effects.common.TransformSourceEffect in project mage by magefree.

the class AberrantResearcherEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null || controller.millCards(1, source, game).getCards(game).stream().noneMatch(card -> card.isInstantOrSorcery(game))) {
        return false;
    }
    new TransformSourceEffect().apply(game, source);
    return true;
}
Also used : OneShotEffect(mage.abilities.effects.OneShotEffect) UUID(java.util.UUID) MageInt(mage.MageInt) TransformSourceEffect(mage.abilities.effects.common.TransformSourceEffect) Player(mage.players.Player) CardSetInfo(mage.cards.CardSetInfo) BeginningOfUpkeepTriggeredAbility(mage.abilities.common.BeginningOfUpkeepTriggeredAbility) Game(mage.game.Game) TransformAbility(mage.abilities.keyword.TransformAbility) CardImpl(mage.cards.CardImpl) FlyingAbility(mage.abilities.keyword.FlyingAbility) mage.constants(mage.constants) Ability(mage.abilities.Ability) Player(mage.players.Player) TransformSourceEffect(mage.abilities.effects.common.TransformSourceEffect)

Example 2 with TransformSourceEffect

use of mage.abilities.effects.common.TransformSourceEffect in project mage by magefree.

the class HeirloomMirrorEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Permanent permanent = source.getSourcePermanentIfItStillExists(game);
    if (player == null || permanent == null) {
        return false;
    }
    player.drawCards(1, source, game);
    player.millCards(1, source, game);
    permanent.addCounters(CounterType.RITUAL.createInstance(), source.getControllerId(), source, game);
    int counters = permanent.getCounters(game).getCount(CounterType.RITUAL);
    if (counters < 3) {
        return true;
    }
    permanent.removeCounters(CounterType.RITUAL.createInstance(counters), source, game);
    new TransformSourceEffect().apply(game, source);
    return true;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TransformSourceEffect(mage.abilities.effects.common.TransformSourceEffect)

Example 3 with TransformSourceEffect

use of mage.abilities.effects.common.TransformSourceEffect in project mage by magefree.

the class LudevicsTestSubjectEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent p = game.getPermanent(source.getSourceId());
    if (p != null) {
        if (p.getCounters(game).getCount(CounterType.HATCHLING) >= 5) {
            p.removeCounters(CounterType.HATCHLING.getName(), p.getCounters(game).getCount(CounterType.HATCHLING), source, game);
            TransformSourceEffect effect = new TransformSourceEffect();
            return effect.apply(game, source);
        }
    }
    return false;
}
Also used : Permanent(mage.game.permanent.Permanent) TransformSourceEffect(mage.abilities.effects.common.TransformSourceEffect)

Example 4 with TransformSourceEffect

use of mage.abilities.effects.common.TransformSourceEffect in project mage by magefree.

the class PrimalAmuletEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Permanent permanent = game.getPermanent(source.getSourceId());
    if (permanent != null && player != null) {
        permanent.addCounters(CounterType.CHARGE.createInstance(), source.getControllerId(), source, game);
        int counters = permanent.getCounters(game).getCount(CounterType.CHARGE);
        if (counters > 3 && player.chooseUse(Outcome.Benefit, "Transform this?", source, game)) {
            permanent.removeCounters("charge", counters, source, game);
            new TransformSourceEffect().apply(game, source);
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TransformSourceEffect(mage.abilities.effects.common.TransformSourceEffect)

Example 5 with TransformSourceEffect

use of mage.abilities.effects.common.TransformSourceEffect in project mage by magefree.

the class TreasureMapEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getSourceId());
    Player player = game.getPlayer(source.getControllerId());
    if (player != null) {
        player.scry(1, source, game);
        if (permanent != null) {
            permanent.addCounters(CounterType.LANDMARK.createInstance(), source.getControllerId(), source, game);
            int counters = permanent.getCounters(game).getCount(CounterType.LANDMARK);
            if (counters > 2) {
                permanent.removeCounters("landmark", counters, source, game);
                new TransformSourceEffect().apply(game, source);
                new CreateTokenEffect(new TreasureToken(), 3).apply(game, source);
            }
            return true;
        }
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TransformSourceEffect(mage.abilities.effects.common.TransformSourceEffect) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) TreasureToken(mage.game.permanent.token.TreasureToken)

Aggregations

TransformSourceEffect (mage.abilities.effects.common.TransformSourceEffect)10 Player (mage.players.Player)8 Permanent (mage.game.permanent.Permanent)6 UUID (java.util.UUID)3 MageObject (mage.MageObject)3 Card (mage.cards.Card)2 ExileZone (mage.game.ExileZone)2 HashSet (java.util.HashSet)1 MageInt (mage.MageInt)1 Ability (mage.abilities.Ability)1 BeginningOfUpkeepTriggeredAbility (mage.abilities.common.BeginningOfUpkeepTriggeredAbility)1 OneShotEffect (mage.abilities.effects.OneShotEffect)1 CreateTokenEffect (mage.abilities.effects.common.CreateTokenEffect)1 ExileTargetEffect (mage.abilities.effects.common.ExileTargetEffect)1 UntapSourceEffect (mage.abilities.effects.common.UntapSourceEffect)1 FlyingAbility (mage.abilities.keyword.FlyingAbility)1 TransformAbility (mage.abilities.keyword.TransformAbility)1 CardImpl (mage.cards.CardImpl)1 CardSetInfo (mage.cards.CardSetInfo)1 CardsImpl (mage.cards.CardsImpl)1