Package mage

Examples of mage.MageObject


        return new SetPowerToughnessSourceEffect(this);
    }

    @Override
    public boolean apply(Game game, Ability source) {
        MageObject mageObject = game.getObject(source.getSourceId()); // there are character definig abilities (e.g. P/T Nightmare) that have to work also for P/T of cards
        if (mageObject == null) {
            return false;
        }
        if (amount != null) {
            int value = amount.calculate(game, source, this);
            mageObject.getPower().setValue(value);
            mageObject.getToughness().setValue(value);
            return true;
        } else {
            if (power != Integer.MIN_VALUE) {
                mageObject.getPower().setValue(power);
            }
            if (toughness != Integer.MIN_VALUE) {
                mageObject.getToughness().setValue(toughness);
            }
        }
        return true;
    }
View Full Code Here


    }

    @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) {
            return false;
        }
        if (controller.searchLibrary(target, game)) {
            List<Card> cards = new ArrayList<>();
            for (UUID cardId: (List<UUID>)target.getTargets()) {
                Card card = controller.getLibrary().remove(cardId, game);
                if (card != null) {
                    cards.add(card);
                }
            }
            Cards foundCards = new CardsImpl();
            foundCards.addAll(cards);
            if (reveal) {
                controller.revealCards(sourceObject.getLogName(), foundCards, game);
            }
            if (forceShuffle) {
                controller.shuffleLibrary(game);
            }
            if (cards.size() > 0) {
View Full Code Here

    }

    @Override
    public boolean checkTrigger(GameEvent event, Game game) {
    if (event.getType() == GameEvent.EventType.SACRIFICED_PERMANENT && game.getPlayer(this.getControllerId()).hasOpponent(event.getPlayerId(), game)) {
            MageObject object = game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
            if (object instanceof Permanent && !(object instanceof PermanentToken) ) {
                for (Effect effect : getEffects()) {
                    effect.setTargetPointer(new FixedTarget(event.getTargetId()));
                }
                return true;
View Full Code Here

    }

    @Override
    public boolean replaceEvent(GameEvent event, Ability source, Game game) {
        Player player = game.getPlayer(source.getControllerId());
        MageObject sourceObject = game.getObject(source.getSourceId());
        if (player != null && cost != null && sourceObject != null){
            boolean replace = true;
            if (cost.canPay(source, source.getSourceId(), player.getId(), game)) {
                if (player.chooseUse(outcome, cost.getText() + "? (otherwise " + sourceObject.getLogName() + " is put into graveyard)", game)) {
                    cost.clearPaid();
                    replace = !cost.pay(source, game, source.getSourceId(), source.getControllerId(), false);
                }
            }
            if (replace) {
View Full Code Here

            if (target instanceof TargetSource) {
                Set<UUID> possibleTargets;
                TargetSource t = ((TargetSource) target);
                possibleTargets = t.possibleTargets(sourceId, playerId, game);
                for (UUID targetId : possibleTargets) {
                    MageObject targetObject = game.getObject(targetId);
                    if (targetObject != null) {
                        for (String choose2: choices) {
                            if (targetObject.getName().equals(choose2)) {
                                List<UUID> alreadyTargetted = target.getTargets();
                                if (t.canTarget(targetObject.getId(), game)) {
                                    if (alreadyTargetted != null && !alreadyTargetted.contains(targetObject.getId())) {
                                        target.add(targetObject.getId(), game);
                                        choices.remove(choose2);
                                        return true;
                                    }
                                }
                            }
View Full Code Here

            } else {
                if (ability.getTargets().size() == 0) {
                    throw new AssertionError("Ability has no targets. " + ability.toString());
                }
                for (UUID id: ability.getTargets().get(0).possibleTargets(ability.getSourceId(), ability.getControllerId(), game)) {
                    MageObject object = game.getObject(id);
                    if (object != null && object.getName().equals(targetName)) {
                        if (index >= ability.getTargets().size()) {
                            index--;
                        }
                        if (ability.getTargets().get(index).getNumberOfTargets() == 1) {
                            ability.getTargets().get(index).clearChosen();
View Full Code Here

    }

    @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) {
            return false;
        }

        Cards cards = new CardsImpl();
        int count = Math.min(controller.getLibrary().size(), 3);
        for (int i = 0; i < count; i++) {
            Card card = controller.getLibrary().removeFromTop(game);
            if (card != null) {
                cards.add(card);
                if (card.getCardType().contains(CardType.CREATURE)) {
                    controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
                } else {
                    controller.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
                }
            } else {
                return false;
            }
        }

        if (!cards.isEmpty()) {
            controller.revealCards(sourceObject.getLogName(), cards, game);
        }

        return true;
    }
View Full Code Here

    }

    @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) {
            FilterCard filter = new FilterCard("card in your hand to exile");
            FilterCard filter2 = new FilterCard("(move the window) card exiled by " + sourceObject.getLogName() + " to put on top of library");
            TargetCardInHand target = new TargetCardInHand(0, controller.getHand().size(), filter);
            target.setRequired(false);
            int amountExiled = 0;
            if (target.canChoose(source.getControllerId(), game) && target.choose(Outcome.Neutral, source.getControllerId(), source.getSourceId(), game)) {
                if (!target.getTargets().isEmpty()) {
                    List<UUID> targets = target.getTargets();
                    for (UUID targetId : targets) {
                        Card card = game.getCard(targetId);
                        if (card != null) {
                            card.setFaceDown(true);
                            if (card.moveToExile(source.getSourceId(), sourceObject.getLogName(), source.getSourceId(), game)) {
                                amountExiled++;
                            }
                        }
                    }
                }
            }
            game.informPlayers(controller.getName() + " exiles " + amountExiled + " card" + (amountExiled == 1 ? " ":"s ") + "face down from his or her hand");
            if (amountExiled > 0) {
                int count = Math.min(controller.getLibrary().size(), amountExiled);
                for (int i = 0; i < count; i++) {
                    Card card = controller.getLibrary().removeFromTop(game);
                    if (card != null) {
                        card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
                    }
                }
            }
            game.informPlayers(controller.getName() + " moves " + amountExiled + " card" + (amountExiled == 1 ? " ":"s ") + "from library to hand");

            TargetCardInExile target2 = new TargetCardInExile(filter2, source.getSourceId());
            ExileZone scrollRackExileZone = game.getExile().getExileZone(source.getSourceId());
            if (scrollRackExileZone != null) {
                while (controller.isInGame() && scrollRackExileZone.count(filter, game) > 1) {
                    controller.lookAtCards("exiled cards with " + sourceObject.getLogName(), scrollRackExileZone, game);
                    controller.choose(Outcome.Neutral, scrollRackExileZone, target2, game);
                    Card card = game.getCard(target2.getFirstTarget());
                    if (card != null) {
                        game.getExile().removeCard(card, game);
                        controller.moveCardToLibraryWithInfo(card, source.getSourceId(), game, Zone.EXILED, true, false);
View Full Code Here

    @Override
    public boolean apply(Game game, Ability source) {
        Player controller = game.getPlayer(source.getControllerId());
        if (controller != null) {
            MageObject thisCard = game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
            if (thisCard != null && thisCard instanceof Permanent) {
                EmptyToken token = new EmptyToken();
                CardUtil.copyTo(token).from((Permanent)thisCard);
                if (token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId())) {
                    game.informPlayers(new StringBuilder(controller.getName())
View Full Code Here

                    case STACK:
                    case PICK:
                        // nothing to do
                        break;
                    default:
                        MageObject object = game.getObject(sourceId);
                        logger.warn(new StringBuilder("moveToExile, not fully implemented: from = ").append(fromZone).append(" - ").append(object != null ? object.getName():"null"));
                }
                game.rememberLKI(objectId, event.getFromZone(), this);
            }

            if (exileId == null) {
View Full Code Here

TOP

Related Classes of mage.MageObject

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.