Search in sources :

Example 16 with SubType

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

the class EmbalmEffect method setRule.

private String setRule(Cost cost, Card card) {
    StringBuilder sb = new StringBuilder("Embalm ").append(cost.getText());
    sb.append(" <i>(").append(cost.getText());
    sb.append(", Exile this card from your graveyard: Create a token that's a copy of it, except it's a white Zombie ");
    for (SubType subtype : card.getSubtype()) {
        sb.append(subtype).append(" ");
    }
    sb.append(" with no mana cost. Embalm only as a sorcery.)</i>");
    return sb.toString();
}
Also used : SubType(mage.constants.SubType)

Example 17 with SubType

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

the class EternalizeEffect method setRule.

private String setRule(Cost cost, Card card) {
    StringBuilder sb = new StringBuilder("Eternalize ").append(cost.getText());
    sb.append(" <i>(").append(cost.getText());
    sb.append(", Exile this card from your graveyard: Create a token that's a copy of it, except it's a 4/4 black Zombie ");
    for (SubType subtype : card.getSubtype()) {
        sb.append(subtype).append(" ");
    }
    sb.append(" with no mana cost. Eternalize only as a sorcery.)</i>");
    return sb.toString();
}
Also used : SubType(mage.constants.SubType)

Example 18 with SubType

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

the class CardCriteria method buildQuery.

public void buildQuery(QueryBuilder qb) throws SQLException {
    optimize();
    Where where = qb.where();
    where.eq("nightCard", false);
    where.eq("splitCardHalf", false);
    int clausesCount = 2;
    if (name != null) {
        where.like("name", new SelectArg('%' + name + '%'));
        clausesCount++;
    }
    if (nameExact != null) {
        where.like("name", new SelectArg(nameExact));
        clausesCount++;
    }
    if (rules != null) {
        where.like("rules", new SelectArg('%' + rules + '%'));
        clausesCount++;
    }
    if (doubleFaced != null) {
        where.eq("doubleFaced", doubleFaced);
        clausesCount++;
    }
    if (modalDoubleFaced != null) {
        where.eq("modalDoubleFacesCard", modalDoubleFaced);
        clausesCount++;
    }
    for (Rarity rarity : rarities) {
        where.eq("rarity", rarity);
    }
    if (!rarities.isEmpty()) {
        where.or(rarities.size());
        clausesCount++;
    }
    for (String setCode : setCodes) {
        where.eq("setCode", setCode);
    }
    if (!setCodes.isEmpty()) {
        where.or(setCodes.size());
        clausesCount++;
    }
    for (String ignoreSetCode : ignoreSetCodes) {
        where.ne("setCode", ignoreSetCode);
    }
    if (!ignoreSetCodes.isEmpty()) {
        where.or(ignoreSetCodes.size());
        clausesCount++;
    }
    if (types.size() != 7) {
        // if all types selected - no selection needed (Tribal and Conspiracy not selectable yet)
        for (CardType type : types) {
            where.like("types", new SelectArg('%' + type.name() + '%'));
        }
        if (!types.isEmpty()) {
            where.or(types.size());
            clausesCount++;
        }
    }
    for (CardType type : notTypes) {
        where.not().like("types", new SelectArg('%' + type.name() + '%'));
        clausesCount++;
    }
    for (SuperType superType : supertypes) {
        where.like("supertypes", new SelectArg('%' + superType.name() + '%'));
        clausesCount++;
    }
    for (SuperType superType : notSupertypes) {
        where.not().like("supertypes", new SelectArg('%' + superType.name() + '%'));
        clausesCount++;
    }
    for (SubType subType : subtypes) {
        where.like("subtypes", new SelectArg('%' + subType.toString() + '%'));
        clausesCount++;
    }
    if (manaValue != null) {
        where.eq("manaValue", manaValue);
        clausesCount++;
    }
    int colorClauses = 0;
    if (black) {
        where.eq("black", true);
        colorClauses++;
    }
    if (blue) {
        where.eq("blue", true);
        colorClauses++;
    }
    if (green) {
        where.eq("green", true);
        colorClauses++;
    }
    if (red) {
        where.eq("red", true);
        colorClauses++;
    }
    if (white) {
        where.eq("white", true);
        colorClauses++;
    }
    if (colorless) {
        where.eq("black", false).eq("blue", false).eq("green", false).eq("red", false).eq("white", false);
        where.and(5);
        colorClauses++;
    }
    if (colorClauses > 0) {
        where.or(colorClauses);
        clausesCount++;
    }
    if (minCardNumber != Integer.MIN_VALUE) {
        where.ge("cardNumberAsInt", minCardNumber);
        clausesCount++;
    }
    if (maxCardNumber != Integer.MAX_VALUE) {
        where.le("cardNumberAsInt", maxCardNumber);
        clausesCount++;
    }
    if (clausesCount > 0) {
        where.and(clausesCount);
    } else {
        where.eq("cardNumber", new SelectArg(0));
    }
    if (start != null) {
        qb.offset(start);
    }
    if (count != null) {
        qb.limit(count);
    }
    if (sortBy != null) {
        qb.orderBy(sortBy, true);
    }
}
Also used : Rarity(mage.constants.Rarity) SelectArg(com.j256.ormlite.stmt.SelectArg) SubType(mage.constants.SubType) CardType(mage.constants.CardType) Where(com.j256.ormlite.stmt.Where) SuperType(mage.constants.SuperType)

Example 19 with SubType

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

the class GlobalRuinDestroyLandEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Set<UUID> lands = new HashSet<>();
    for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
        Player player = game.getPlayer(playerId);
        if (player != null) {
            for (SubType landName : Arrays.stream(SubType.values()).filter(p -> p.getSubTypeSet() == SubTypeSet.BasicLandType).collect(Collectors.toSet())) {
                FilterControlledLandPermanent filter = new FilterControlledLandPermanent(landName + " you control");
                filter.add(landName.getPredicate());
                Target target = new TargetControlledPermanent(1, 1, filter, true);
                if (target.canChoose(source.getSourceId(), player.getId(), game)) {
                    player.chooseTarget(outcome, target, source, game);
                    lands.add(target.getFirstTarget());
                }
            }
        }
    }
    for (Permanent permanent : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_LAND, game)) {
        if (!lands.contains(permanent.getId())) {
            permanent.sacrifice(source, game);
        }
    }
    return true;
}
Also used : Target(mage.target.Target) Arrays(java.util.Arrays) StaticFilters(mage.filter.StaticFilters) SubTypeSet(mage.constants.SubTypeSet) Set(java.util.Set) Outcome(mage.constants.Outcome) OneShotEffect(mage.abilities.effects.OneShotEffect) UUID(java.util.UUID) SubType(mage.constants.SubType) Collectors(java.util.stream.Collectors) Player(mage.players.Player) HashSet(java.util.HashSet) CardSetInfo(mage.cards.CardSetInfo) Game(mage.game.Game) CardImpl(mage.cards.CardImpl) Permanent(mage.game.permanent.Permanent) CardType(mage.constants.CardType) TargetControlledPermanent(mage.target.common.TargetControlledPermanent) FilterControlledLandPermanent(mage.filter.common.FilterControlledLandPermanent) Ability(mage.abilities.Ability) TargetControlledPermanent(mage.target.common.TargetControlledPermanent) Player(mage.players.Player) Target(mage.target.Target) SubType(mage.constants.SubType) Permanent(mage.game.permanent.Permanent) TargetControlledPermanent(mage.target.common.TargetControlledPermanent) FilterControlledLandPermanent(mage.filter.common.FilterControlledLandPermanent) UUID(java.util.UUID) FilterControlledLandPermanent(mage.filter.common.FilterControlledLandPermanent) HashSet(java.util.HashSet)

Example 20 with SubType

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

the class KindredChargeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = game.getObject(source.getSourceId());
    if (controller != null && sourceObject != null) {
        SubType subType = ChooseCreatureTypeEffect.getChosenCreatureType(source.getSourceId(), game);
        if (subType != null) {
            FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("creature you control of the chosen type");
            filter.add(subType.getPredicate());
            for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, controller.getId(), game)) {
                if (permanent != null) {
                    CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), null, true);
                    effect.setTargetPointer(new FixedTarget(permanent, game));
                    effect.apply(game, source);
                    for (Permanent addedToken : effect.getAddedPermanents()) {
                        Effect exileEffect = new ExileTargetEffect();
                        exileEffect.setTargetPointer(new FixedTarget(addedToken, game));
                        game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect), source);
                    }
                }
            }
            return true;
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) SubType(mage.constants.SubType) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) Permanent(mage.game.permanent.Permanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) MageObject(mage.MageObject) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) ChooseCreatureTypeEffect(mage.abilities.effects.common.ChooseCreatureTypeEffect) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect) Effect(mage.abilities.effects.Effect) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect)

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