Package mage

Examples of mage.MageObject


        if (source.getTargets().get(0) instanceof TargetSpell) {
            UUID objectId = source.getFirstTarget();
            StackObject stackObject = game.getStack().getStackObject(objectId);
            if (stackObject != null) {
                MageObject targetObject = game.getObject(stackObject.getSourceId());
                if (targetObject instanceof Card) {
                    cardName = targetObject.getName();
                }
                searchPlayerId = stackObject.getControllerId();
                result = game.getStack().counter(objectId, source.getSourceId(), game);
            }
        }
View Full Code Here


   
    @Override
    public boolean apply(Game game, Ability source) {
        Player you = game.getPlayer(source.getControllerId());
        Player targetPlayer = game.getPlayer(source.getFirstTarget());
        MageObject sourceObject = game.getObject(source.getSourceId());
        if (you != null && targetPlayer != null) {
            you.lookAtCards(sourceObject != null ? sourceObject.getName() : null, targetPlayer.getHand(), game);
            return true;
        }
        return false;
    }
View Full Code Here

    @Override
    public boolean replaceEvent(GameEvent event, Ability source, Game game) {
        if (optional) {
            Player controller = game.getPlayer(source.getControllerId());
            MageObject object = game.getObject(source.getSourceId());
            if (controller == null || object == null) {
                return false;
            }
            if (!controller.chooseUse(outcome, new StringBuilder("Use effect of ").append(object.getLogName()).append("?").toString(), game)) {
                return false;
            }
        }
        Spell spell = game.getStack().getSpell(event.getSourceId());
        for (Effect effect: baseEffects) {
View Full Code Here

    @Override
    public boolean canTarget(UUID id, Ability source, Game game) {
        Permanent permanent = game.getPermanent(id);
        if (permanent != null) {
            if (source != null) {
                MageObject targetSource = game.getObject(source.getSourceId());
                return permanent.canBeTargetedBy(targetSource, source.getControllerId(), game) && filter.match(permanent, source.getSourceId(), source.getControllerId(), game);
            } else {
                return filter.match(permanent, game);
            }
        }
View Full Code Here

        } else {
            objectColor = this.setColor;
        }
        if (objectColor != null) {
            for (UUID targetId :targetPointer.getTargets(game, source)) {
                MageObject o = game.getObject(targetId);
                if (o != null) {
                    if (o instanceof Permanent || o instanceof StackObject) {
                        o.getColor().setColor(objectColor);
                        result = true;
                    }
                }
            }
        }
View Full Code Here

    }

    @Override
    public void init(Ability source, Game game) {
        super.init(source, game); //To change body of generated methods, choose Tools | Templates.
        MageObject sourceObject = game.getObject(source.getSourceId());
        Player controller = game.getPlayer(source.getControllerId());
        if (sourceObject != null && controller != null) {
            while (!choice.isChosen()) {
                controller.choose(Outcome.Protect, choice, game);
                if (!controller.isInGame()) {
                    return;
                }
            }
            if (choice.isChosen()) {
                game.informPlayers(sourceObject.getLogName() + ": " + controller.getName() + " has chosen protection from " + choice.getChoice());
            }
        }
    }
View Full Code Here

public class SharesColorWithSourcePredicate implements ObjectSourcePlayerPredicate<ObjectSourcePlayer<MageObject>> {

    @Override
    public boolean apply(ObjectSourcePlayer<MageObject> input, Game game) {
        MageObject sourceObject = game.getObject(input.getSourceId());
        if (sourceObject != null) {
            return input.getObject().getColor().shares(sourceObject.getColor());
        }
        return false;

    }
View Full Code Here

    }

    @Override
    public boolean apply(Game game, Ability source) {
        Card sourceCard = game.getCard(source.getSourceId());
        MageObject sourceObject = game.getObject(source.getSourceId());
        if (sourceCard != null) {
            Player player = game.getPlayer(sourceCard.getOwnerId());
            if (player != null) {
                Zone fromZone = game.getState().getZone(sourceCard.getId());
                Cards cards = new CardsImpl();
                cards.add(sourceCard);
                player.revealCards(sourceObject.getLogName(), cards, game);
                player.moveCardToLibraryWithInfo(sourceCard, source.getSourceId(), game, fromZone, true, true);
                player.shuffleLibrary(game);
                return true;
            }
        }
View Full Code Here

    }

    @Override
    public String getInfoMessage(Ability source, GameEvent event, Game game) {
        ObjectColor chosenColor = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color");
        MageObject mageObject = game.getObject(source.getSourceId());
        if (mageObject != null && chosenColor != null) {
            return "You can't cast " + chosenColor.toString() +" spells (" + mageObject.getLogName() + ").";
        }
        return null;
    }
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 (sourceObject == null || controller == null) {
            return false;
        }
        if (!controller.getLibrary().isEmptyDraw()) {
            Card card = controller.getLibrary().getFromTop(game);
            if (card == null) {
                return false;
            }
            controller.lookAtCards(sourceObject.getLogName(), new CardsImpl(card), game);
            boolean toBottom = controller.chooseUse(outcome, "Put card on the bottom of your library?", game);
            return controller.moveCardToLibraryWithInfo(card, source.getSourceId(), game, Zone.LIBRARY, !toBottom, false);
        }
        return true;
    }
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.