Package mage.cards

Examples of mage.cards.Card


    }

    @Override
    public boolean apply(Game game, Ability source) {
        Player player = game.getPlayer(source.getControllerId());
        Card card = game.getCard(source.getSourceId());
        if (player != null && card != null) {
            // remove temporary suspend ability (used e.g. for Epochrasite)
            List<Ability> abilitiesToRemove = new ArrayList<>();
            for (Ability ability : card.getAbilities()) {
                if (ability instanceof SuspendAbility) {
                    if (((SuspendAbility)ability).isGainedTemporary()) {
                        abilitiesToRemove.add(ability);
                    }
                }
            }
            if (!abilitiesToRemove.isEmpty()) {
                for (Ability ability : card.getAbilities()) {
                    if (ability instanceof SuspendBeginningOfUpkeepTriggeredAbility || ability instanceof SuspendPlayCardAbility ) {
                        abilitiesToRemove.add(ability);
                    }
                }
                // remove the triggered abilities from the game
                game.getState().resetTriggersForSourceId(card.getId());
                // remove the continious effects from the game
                game.getState().getContinuousEffects().removeGainedEffectsForSource(card.getId());
                // remove the abilities from the card
                card.getAbilities().removeAll(abilitiesToRemove);
            }
            // cast the card for free
            return player.cast(card.getSpellAbility(), game, true);
        }
        return false;
    }
View Full Code Here


        Player controller = game.getPlayer(controllerId);
        if (controller == null) {
            return false;
        }
        lastAddedTokenIds.clear();
        Card source = game.getCard(sourceId);
        String setCode;
        if (this.getOriginalExpansionSetCode() != null && !this.getOriginalExpansionSetCode().isEmpty()) {
            setCode = this.getOriginalExpansionSetCode();
        } else {
            setCode = source != null ? source.getExpansionSetCode() : null;
        }
        GameEvent event = GameEvent.getEvent(EventType.CREATE_TOKEN, null, sourceId, controllerId, amount);
        if (!game.replaceEvent(event)) {
            amount = event.getAmount();
            for (int i = 0; i < amount; i++) {
View Full Code Here

        zoneChangeCounter = 0;
    }

    @Override
    public boolean isActivated(Ability ability, Game game) {
        Card card = game.getCard(sourceId);
        if (card != null && card.getZoneChangeCounter() <= zoneChangeCounter +1) {
            return alternateCosts.isActivated(game);
        }
        return false;
    }
View Full Code Here

    private void activateMorph(Game game) {
        alternateCosts.activate();
        // remember zone change counter
        if (zoneChangeCounter == 0) {
            Card card = game.getCard(getSourceId());
            if (card != null) {
                zoneChangeCounter = card.getZoneChangeCounter();
            } else {
                throw new IllegalArgumentException("Morph source card not found");
            }
        }
    }
View Full Code Here

                    break;
                case ColorChangingEffects_5:
                    permanent.getColor().setColor(new ObjectColor());
                    break;
                case AbilityAddingRemovingEffects_6:
                    Card card = game.getCard(permanent.getId()); // 
                    List<Ability> abilities = new ArrayList<>();
                    for (Ability ability : permanent.getAbilities()) {
                        if (card != null && !card.getAbilities().contains(ability)) {
                            // gained abilities from other sources won't be removed
                            continue;
                        }
                        // TODO: Add flag "works also face down" to ability and use it to control ability removement instead of instanceof check
                        if (ability.getWorksFaceDown()) {
View Full Code Here

    public boolean replaceEvent(GameEvent event, Ability source, Game game) {
        Player player = game.getPlayer(event.getPlayerId());
        if (player != null) {
            TargetCardInLibrary target = new TargetCardInLibrary();
            if (player.searchLibrary(target, game)) {
                Card card = game.getCard(target.getFirstTarget());
                if (card != null) {
                    card.moveToZone(Zone.HAND, id, game, false);
                    player.shuffleLibrary(game);
                }
            }
        }
        return true;
View Full Code Here

    public static Deck load(DeckCardLists deckCardLists, boolean ignoreErrors, boolean mockCards) throws GameException {
        Deck deck = new Deck();
        deck.setName(deckCardLists.getName());
        for (DeckCardInfo deckCardInfo: deckCardLists.getCards()) {
            Card card = createCard(deckCardInfo, mockCards);
            if (card != null) {
                deck.cards.add(card);
            } else if (!ignoreErrors) {
                throw new GameException("Error loading card - " + deckCardInfo.getCardName() + " for deck - " + deck.getName());
            }
        }
        for (DeckCardInfo deckCardInfo: deckCardLists.getSideboard()) {
            Card card = createCard(deckCardInfo, mockCards);
            if (card != null) {
                deck.sideboard.add(card);
            } else if (!ignoreErrors) {
                throw new GameException("Error loading card - " + deckCardInfo.getCardName() + " for deck - " + deck.getName());
            }
View Full Code Here

        this.targetOwner = targetOwner;
    }

    @Override
    public boolean apply(ObjectPlayer<Card> input, Game game) {
        Card card = input.getObject();
        UUID playerId = input.getPlayerId();
        if (card == null || playerId == null) {
            return false;
        }

        switch (targetOwner) {
            case YOU:
                if (card.getOwnerId().equals(playerId)) {
                    return true;
                }
                break;
            case OPPONENT:
                if (!card.getOwnerId().equals(playerId) &&
                        game.getPlayer(playerId).hasOpponent(card.getOwnerId(), game)) {
                    return true;
                }
                break;
            case NOT_YOU:
                if (!card.getOwnerId().equals(playerId)) {
                    return true;
                }
                break;
        }
View Full Code Here

    }

    @Override
    public int calculate(Game game, Ability source, Effect effect) {
        if (zoneChangeCounter == 0) {
            Card card = game.getCard(source.getSourceId());
            if (card != null) {
                zoneChangeCounter = card.getZoneChangeCounter();
                if (previousZone) {
                    zoneChangeCounter--;
                }
            }
        }
View Full Code Here

    }

    @Override
    public int calculate(Game game, Ability source, Effect effect) {
        int count = 0;
        Card card = game.getCard(source.getSourceId());
        if (card != null) {
            for (Ability ability: card.getAbilities()) {
                if (ability instanceof KickerAbility) {
                    count += ((KickerAbility) ability).getKickedCounter(game);
                }
            }
        }
View Full Code Here

TOP

Related Classes of mage.cards.Card

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.