Search in sources :

Example 11 with Plane

use of mage.game.command.Plane in project mage by magefree.

the class FieldsOfSummerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Plane cPlane = game.getState().getCurrentPlane();
    if (cPlane == null || !cPlane.getPlaneType().equals(Planes.PLANE_FIELDS_OF_SUMMER)) {
        return false;
    }
    Player owner = game.getPlayer(this.getTargetPointer().getFirst(game, source));
    if (owner != null && owner.canRespond() && owner.chooseUse(Outcome.Benefit, "Gain 2 life?", source, game)) {
        Effect effect = new GainLifeTargetEffect(2);
        effect.setTargetPointer(new FixedTarget(owner.getId())).apply(game, source);
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Plane(mage.game.command.Plane) GainLifeTargetEffect(mage.abilities.effects.common.GainLifeTargetEffect) RollPlanarDieEffect(mage.abilities.effects.common.RollPlanarDieEffect) PlanarDieRollCostIncreasingEffect(mage.abilities.effects.common.cost.PlanarDieRollCostIncreasingEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) GainLifeEffect(mage.abilities.effects.common.GainLifeEffect) Effect(mage.abilities.effects.Effect) GainLifeTargetEffect(mage.abilities.effects.common.GainLifeTargetEffect)

Example 12 with Plane

use of mage.game.command.Plane in project mage by magefree.

the class PanopticonTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    Plane cPlane = game.getState().getCurrentPlane();
    if (cPlane == null || !cPlane.getPlaneType().equals(Planes.PLANE_PANOPTICON)) {
        return false;
    }
    Player activePlayer = game.getPlayer(game.getActivePlayerId());
    if (activePlayer != null) {
        getEffects().setTargetPointer(new FixedTarget(activePlayer.getId()));
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Plane(mage.game.command.Plane)

Example 13 with Plane

use of mage.game.command.Plane in project mage by magefree.

the class TheGreatForestCombatDamageRuleEffect method apply.

@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
    Plane cPlane = game.getState().getCurrentPlane();
    if (cPlane == null) {
        return false;
    }
    if (!cPlane.getPlaneType().equals(Planes.PLANE_THE_GREAT_FOREST)) {
        return false;
    }
    // Change the rule
    game.getCombat().setUseToughnessForDamage(true);
    game.getCombat().addUseToughnessForDamageFilter(StaticFilters.FILTER_PERMANENT_CREATURES);
    return true;
}
Also used : Plane(mage.game.command.Plane)

Example 14 with Plane

use of mage.game.command.Plane in project mage by magefree.

the class TurriIslandEffect method applies.

@Override
public boolean applies(Ability abilityToModify, Ability source, Game game) {
    if (abilityToModify instanceof SpellAbility) {
        Plane cPlane = game.getState().getCurrentPlane();
        if (cPlane == null) {
            return false;
        }
        if (!cPlane.getPlaneType().equals(Planes.PLANE_TURRI_ISLAND)) {
            return false;
        }
        Card spellCard = ((SpellAbility) abilityToModify).getCharacteristics(game);
        if (spellCard != null) {
            return filter.match(spellCard, game) && selectedByRuntimeData(spellCard, source, game);
        }
    }
    return false;
}
Also used : Plane(mage.game.command.Plane) SpellAbility(mage.abilities.SpellAbility) FilterCard(mage.filter.FilterCard) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Card(mage.cards.Card)

Example 15 with Plane

use of mage.game.command.Plane in project mage by magefree.

the class MageBook method loadTokens.

public List<Object> loadTokens() {
    List<Object> res = new ArrayList<>();
    // tokens
    List<CardDownloadData> allTokens = getTokenCardUrls();
    for (CardDownloadData token : allTokens) {
        if (token.getSet().equals(currentSet)) {
            try {
                String className = token.getName();
                className = className.replaceAll("[^a-zA-Z0-9]", "");
                className = "mage.game.permanent.token." + className + "Token";
                if (token.getTokenClassName() != null && token.getTokenClassName().length() > 0) {
                    if (token.getTokenClassName().toLowerCase(Locale.ENGLISH).matches(".*token.*")) {
                        className = token.getTokenClassName();
                        className = "mage.game.permanent.token." + className;
                    } else if (token.getTokenClassName().toLowerCase(Locale.ENGLISH).matches(".*emblem.*")) {
                        continue;
                    }
                }
                Class<?> c = Class.forName(className);
                Constructor<?> cons = c.getConstructor();
                Object newToken = cons.newInstance();
                if (newToken instanceof Token) {
                    ((Token) newToken).setOriginalExpansionSetCode(currentSet);
                    ((Token) newToken).setExpansionSetCodeForImage(currentSet);
                    ((Token) newToken).setTokenType(token.getType());
                    res.add(newToken);
                }
            } catch (ClassNotFoundException | NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
            // Swallow exception
            }
        }
    }
    // emblems
    List<CardDownloadData> allEmblems = getTokenCardUrls();
    for (CardDownloadData emblem : allEmblems) {
        if (emblem.getSet().equals(currentSet)) {
            try {
                String className = emblem.getName();
                if (emblem.getTokenClassName() != null && emblem.getTokenClassName().length() > 0) {
                    if (emblem.getTokenClassName().toLowerCase(Locale.ENGLISH).matches(".*emblem.*")) {
                        className = emblem.getTokenClassName();
                        className = "mage.game.command.emblems." + className;
                    }
                } else {
                    continue;
                }
                Class<?> c = Class.forName(className);
                Constructor<?> cons = c.getConstructor();
                Object newEmblem = cons.newInstance();
                if (newEmblem instanceof Emblem) {
                    ((Emblem) newEmblem).setExpansionSetCodeForImage(currentSet);
                    res.add(newEmblem);
                }
            } catch (ClassNotFoundException | InvocationTargetException | IllegalArgumentException | IllegalAccessException | InstantiationException | SecurityException | NoSuchMethodException ex) {
            // Swallow exception
            }
        }
    }
    // planes
    List<CardDownloadData> allPlanes = getTokenCardUrls();
    for (CardDownloadData plane : allPlanes) {
        if (plane.getSet().equals(currentSet)) {
            try {
                String className = plane.getName();
                if (plane.getTokenClassName() != null && plane.getTokenClassName().length() > 0) {
                    if (plane.getTokenClassName().toLowerCase(Locale.ENGLISH).matches(".*plane.*")) {
                        className = plane.getTokenClassName();
                        className = "mage.game.command.planes." + className;
                    }
                } else {
                    continue;
                }
                Class<?> c = Class.forName(className);
                Constructor<?> cons = c.getConstructor();
                Object newPlane = cons.newInstance();
                if (newPlane instanceof Plane) {
                    ((Plane) newPlane).setExpansionSetCodeForImage(currentSet);
                    res.add(newPlane);
                }
            } catch (ClassNotFoundException | InvocationTargetException | IllegalArgumentException | IllegalAccessException | InstantiationException | SecurityException | NoSuchMethodException ex) {
            // Swallow exception
            }
        }
    }
    // dungeons
    List<CardDownloadData> allDungeons = getTokenCardUrls();
    for (CardDownloadData dungeon : allDungeons) {
        if (dungeon.getSet().equals(currentSet)) {
            try {
                String className = dungeon.getName();
                if (dungeon.getTokenClassName() != null && dungeon.getTokenClassName().length() > 0) {
                    if (dungeon.getTokenClassName().toLowerCase(Locale.ENGLISH).matches(".*dungeon.*")) {
                        className = dungeon.getTokenClassName();
                        className = "mage.game.command.dungeons." + className;
                    }
                } else {
                    continue;
                }
                Class<?> c = Class.forName(className);
                Constructor<?> cons = c.getConstructor();
                Object newDungeon = cons.newInstance();
                if (newDungeon instanceof Dungeon) {
                    ((Dungeon) newDungeon).setExpansionSetCodeForImage(currentSet);
                    res.add(newDungeon);
                }
            } catch (ClassNotFoundException | InvocationTargetException | IllegalArgumentException | IllegalAccessException | InstantiationException | SecurityException | NoSuchMethodException ex) {
            // Swallow exception
            }
        }
    }
    return res;
}
Also used : CardDownloadData(org.mage.plugins.card.images.CardDownloadData) Plane(mage.game.command.Plane) ArrayList(java.util.ArrayList) PermanentToken(mage.game.permanent.PermanentToken) Token(mage.game.permanent.token.Token) InvocationTargetException(java.lang.reflect.InvocationTargetException) Emblem(mage.game.command.Emblem) Dungeon(mage.game.command.Dungeon)

Aggregations

Plane (mage.game.command.Plane)17 Effect (mage.abilities.effects.Effect)6 Player (mage.players.Player)6 Card (mage.cards.Card)4 FixedTarget (mage.target.targetpointer.FixedTarget)4 UUID (java.util.UUID)3 MageObject (mage.MageObject)3 Ability (mage.abilities.Ability)3 ContinuousEffect (mage.abilities.effects.ContinuousEffect)3 RollPlanarDieEffect (mage.abilities.effects.common.RollPlanarDieEffect)3 PlanarDieRollCostIncreasingEffect (mage.abilities.effects.common.cost.PlanarDieRollCostIncreasingEffect)3 FilterCard (mage.filter.FilterCard)3 Permanent (mage.game.permanent.Permanent)3 ActivatedAbility (mage.abilities.ActivatedAbility)2 SpellAbility (mage.abilities.SpellAbility)2 SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)2 OneShotEffect (mage.abilities.effects.OneShotEffect)2 InfoEffect (mage.abilities.effects.common.InfoEffect)2 CardInfo (mage.cards.repository.CardInfo)2 CommandObject (mage.game.command.CommandObject)2