Search in sources :

Example 6 with SubType

use of mage.constants.SubType in project mage by magefree.

the class HeraldsHornEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = game.getObject(source.getSourceId());
    // Look at the top card of your library.
    if (controller != null && controller.getLibrary().hasCards() && sourceObject != null) {
        Card card = controller.getLibrary().getFromTop(game);
        Cards cards = new CardsImpl(card);
        controller.lookAtCards(sourceObject.getIdName(), cards, game);
        // If it's a creature card of the chosen type, you may reveal it and put it into your hand.
        FilterCreatureCard filter = new FilterCreatureCard("creature card of the chosen type");
        SubType subtype = ChooseCreatureTypeEffect.getChosenCreatureType(source.getSourceId(), game);
        filter.add(subtype.getPredicate());
        String message = "Reveal the top card of your library and put that card into your hand?";
        if (card != null) {
            if (filter.match(card, game) && controller.chooseUse(Outcome.Benefit, message, source, game)) {
                controller.moveCards(card, Zone.HAND, source, game);
                controller.revealCards(sourceObject.getIdName() + " put into hand", cards, game);
                return true;
            }
        }
    }
    return false;
}
Also used : Player(mage.players.Player) FilterCreatureCard(mage.filter.common.FilterCreatureCard) SubType(mage.constants.SubType) MageObject(mage.MageObject) FilterCreatureCard(mage.filter.common.FilterCreatureCard)

Example 7 with SubType

use of mage.constants.SubType in project mage by magefree.

the class IllusionaryPresenceEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    MageObject mageObject = game.getObject(source.getSourceId());
    if (mageObject != null) {
        SubType landTypeChoice = SubType.byDescription((String) game.getState().getValue(mageObject.getId().toString() + "BasicLandType"));
        if (landTypeChoice != null) {
            switch(landTypeChoice) {
                case PLAINS:
                    gainedAbility = new PlainswalkAbility();
                    break;
                case FOREST:
                    gainedAbility = new ForestwalkAbility();
                    break;
                case SWAMP:
                    gainedAbility = new SwampwalkAbility();
                    break;
                case ISLAND:
                    gainedAbility = new IslandwalkAbility();
                    break;
                case MOUNTAIN:
                    gainedAbility = new MountainwalkAbility();
                    break;
            }
            if (gainedAbility != null) {
                GainAbilitySourceEffect effect = new GainAbilitySourceEffect(gainedAbility, Duration.EndOfTurn);
                game.addEffect(effect, source);
                return true;
            }
        }
    }
    return false;
}
Also used : IslandwalkAbility(mage.abilities.keyword.IslandwalkAbility) SubType(mage.constants.SubType) PlainswalkAbility(mage.abilities.keyword.PlainswalkAbility) GainAbilitySourceEffect(mage.abilities.effects.common.continuous.GainAbilitySourceEffect) MountainwalkAbility(mage.abilities.keyword.MountainwalkAbility) MageObject(mage.MageObject) ForestwalkAbility(mage.abilities.keyword.ForestwalkAbility) SwampwalkAbility(mage.abilities.keyword.SwampwalkAbility)

Example 8 with SubType

use of mage.constants.SubType in project mage by magefree.

the class RiptideReplicatorEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    ObjectColor color = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color");
    SubType subType = ChooseCreatureTypeEffect.getChosenCreatureType(source.getSourceId(), game);
    if (subType == null) {
        return false;
    }
    int x = (new CountersSourceCount(CounterType.CHARGE)).calculate(game, source, this);
    Token token = new RiptideReplicatorToken(color, subType, x);
    return token.putOntoBattlefield(1, game, source, source.getControllerId());
}
Also used : CountersSourceCount(mage.abilities.dynamicvalue.common.CountersSourceCount) RiptideReplicatorToken(mage.game.permanent.token.RiptideReplicatorToken) SubType(mage.constants.SubType) ObjectColor(mage.ObjectColor) RiptideReplicatorToken(mage.game.permanent.token.RiptideReplicatorToken) Token(mage.game.permanent.token.Token)

Example 9 with SubType

use of mage.constants.SubType in project mage by magefree.

the class UnclaimedTerritoryManaCondition method setMana.

@Override
public ConditionalManaBuilder setMana(Mana mana, Ability source, Game game) {
    SubType subType = ChooseCreatureTypeEffect.getChosenCreatureType(source.getSourceId(), game);
    if (subType != null) {
        creatureType = subType;
    }
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = game.getObject(source.getSourceId());
    if (controller != null && sourceObject != null && mana.getAny() == 0) {
        game.informPlayers(controller.getLogName() + " produces " + mana.toString() + " with " + sourceObject.getLogName() + " (can only be spent to cast creatures of type " + creatureType + ")");
    }
    return super.setMana(mana, source, game);
}
Also used : Player(mage.players.Player) SubType(mage.constants.SubType) MageObject(mage.MageObject)

Example 10 with SubType

use of mage.constants.SubType in project mage by magefree.

the class SecludedCourtyardManaCondition method setMana.

@Override
public ConditionalManaBuilder setMana(Mana mana, Ability source, Game game) {
    SubType subType = ChooseCreatureTypeEffect.getChosenCreatureType(source.getSourceId(), game);
    if (subType != null) {
        creatureType = subType;
    }
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = game.getObject(source.getSourceId());
    if (controller != null && sourceObject != null && mana.getAny() == 0) {
        game.informPlayers(controller.getLogName() + " produces " + mana.toString() + " with " + sourceObject.getLogName() + " (can only be spent to cast creatures of type " + creatureType + " and activate an ability of a creature or creature card of the chosen type)");
    }
    return super.setMana(mana, source, game);
}
Also used : Player(mage.players.Player) SubType(mage.constants.SubType) MageObject(mage.MageObject)

Aggregations

SubType (mage.constants.SubType)24 Player (mage.players.Player)11 MageObject (mage.MageObject)8 CardType (mage.constants.CardType)6 Permanent (mage.game.permanent.Permanent)6 UUID (java.util.UUID)5 SuperType (mage.constants.SuperType)5 Collectors (java.util.stream.Collectors)4 Ability (mage.abilities.Ability)4 Card (mage.cards.Card)4 ObjectColor (mage.ObjectColor)3 Effect (mage.abilities.effects.Effect)3 OneShotEffect (mage.abilities.effects.OneShotEffect)3 FilterCreatureCard (mage.filter.common.FilterCreatureCard)3 HashSet (java.util.HashSet)2 LinkedHashSet (java.util.LinkedHashSet)2 CardImpl (mage.cards.CardImpl)2 CardSetInfo (mage.cards.CardSetInfo)2 Choice (mage.choices.Choice)2 Rarity (mage.constants.Rarity)2