Package mage

Examples of mage.MageObject


        return false;
    }

    @Override
    public String getInfoMessage(Ability source, GameEvent event, Game game) {
        MageObject mageObject = game.getObject(source.getSourceId());
        Permanent permanentToUntap = game.getPermanent((event.getTargetId()));
        if (permanentToUntap != null && mageObject != null) {
            return permanentToUntap.getLogName() + " doesn't untap (" + mageObject.getLogName() + ")";
        }
        return null;
    }
View Full Code Here


        return new GetEmblemEffect(this);
    }

    @Override
    public boolean apply(Game game, Ability source) {
        MageObject sourceObject = game.getObject(source.getSourceId());
        if (sourceObject == null) {
            return false;
        }
        game.addEmblem(emblem, source);
        return true;
View Full Code Here

    @Override
    public boolean apply(Game game, Ability source) {
        Spell sourceSpell = (Spell) game.getObject(source.getId());
        if (sourceSpell == null || !sourceSpell.isCopiedSpell()) {
            MageObject mageObject = game.getObject(source.getSourceId());
            if (mageObject instanceof StackObject) {
                StackObject sourceCard = (StackObject) mageObject;
                ReboundEffectCastFromExileDelayedTrigger trigger = new ReboundEffectCastFromExileDelayedTrigger(sourceCard.getSourceId(), sourceCard.getSourceId());
                trigger.setControllerId(source.getControllerId());
                game.addDelayedTriggeredAbility(trigger);
View Full Code Here

        return new LoseLifeTargetControllerEffect(this);
    }

    @Override
    public boolean apply(Game game, Ability source) {
        MageObject targetCard = game.getLastKnownInformation(targetPointer.getFirst(game, source), Zone.BATTLEFIELD);

        if ( targetCard == null ) {
            MageObject obj = game.getObject(targetPointer.getFirst(game, source));
            if ( obj instanceof Card ) {
                targetCard = (Card)obj;
            } else {
                // if target is a countered spell
                targetCard = game.getLastKnownInformation(targetPointer.getFirst(game, source), Zone.STACK);
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) {
            int affectedTargets = 0;
            for (UUID uuid : targetPointer.getTargets(game, source)) {
                Permanent permanent = game.getPermanent(uuid);
                if (permanent != null) {
                    if (counter != null) {
                        Counter newCounter = counter.copy();
                        newCounter.add(amount.calculate(game, source, this));
                        int before = permanent.getCounters().getCount(counter.getName());
                        permanent.addCounters(newCounter, game);
                        int numberAdded = permanent.getCounters().getCount(counter.getName()) - before;
                        affectedTargets ++;
                        game.informPlayers(sourceObject.getLogName() +": "+ controller.getName()+ " puts " +
                                numberAdded + " " + counter.getName().toLowerCase() + " counter on " + permanent.getLogName());
                    }
                } else {
                    Player player = game.getPlayer(uuid);
                    if (player != null) {
                        Counter newCounter = counter.copy();
                        newCounter.add(amount.calculate(game, source, this));
                        player.addCounters(newCounter, game);
                        affectedTargets ++;
                        game.informPlayers(new StringBuilder(sourceObject.getLogName()).append(": ")
                                .append(controller.getName()).append(" puts ")
                                .append(counter.getCount()).append(" ").append(counter.getName().toLowerCase())
                                .append(" counter on ").append(player.getName()).toString());                       
                    }
                }
View Full Code Here

        return newTarget;
    }
   
   
    private String getNamesOftargets(UUID targetId, Game game) {
        MageObject object = game.getObject(targetId);
        String name = null;
        if (object == null) {
            Player targetPlayer = game.getPlayer(targetId);
            if (targetPlayer != null) {
                name = targetPlayer.getName();
            }
        } else {
            name = object.getName();
        }
        return name;
    }
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) {
            if (counter != null) {
                UUID controllerId = source.getControllerId();
                List<Permanent> permanents = game.getBattlefield().getAllActivePermanents();
                for (Permanent permanent : permanents) {
                    if (filter.match(permanent, source.getSourceId(), controllerId, game)) {
                        permanent.addCounters(counter.copy(), game);
                        game.informPlayers(new StringBuilder(sourceObject.getName()).append(": ")
                                .append(controller.getName()).append(" puts ")
                                .append(counter.getCount()).append(" ").append(counter.getName().toLowerCase())
                                .append(" counter on ").append(permanent.getName()).toString());
                    }
                }
View Full Code Here

    @Override
    public void init(Ability source, Game game) {
        super.init(source, game);
        Target target = source.getTargets().get(0);
        MageObject sourceObject = game.getObject(source.getSourceId());
        if (target instanceof TargetCreatureOrPlayerAmount && sourceObject != null) {
            TargetCreatureOrPlayerAmount multiTarget = (TargetCreatureOrPlayerAmount) target;
            for (UUID targetId: multiTarget.getTargets()) {
                Player player = null;
                Permanent permanent = game.getPermanent(targetId);
                if (permanent == null) {
                    player = game.getPlayer(targetId);
                }
                targetAmountMap.put(targetId, multiTarget.getTargetAmount(targetId));
                StringBuilder sb = new StringBuilder(sourceObject.getName()).append(": Prevent the next ");
                sb.append(multiTarget.getTargetAmount(targetId)).append(" damage to ");
                if (player != null) {
                    sb.append(player.getName());
                } else if (permanent != null) {
                    sb.append(permanent.getName());
View Full Code Here

        super(effect);
    }

    @Override
    public boolean apply(Game game, Ability source) {
        MageObject sourceObject = game.getObject(source.getSourceId());
        Player player = game.getPlayer(source.getControllerId());
        if (player == null || sourceObject == null) {
            return false;
        }
        Cards revealed = new CardsImpl();
        Card creatureCard = null;
        Cards nonCreatureCards = new CardsImpl();
        //The first player may reveal cards from the top of his or her library
        while (creatureCard == null && player.getLibrary().size() > 0) {
            Card card = player.getLibrary().removeFromTop(game);
            revealed.add(card);
            // until he or she reveals a creature card.
            if (card.getCardType().contains(CardType.CREATURE)) {
                creatureCard = card;
            } else {
                nonCreatureCards.add(card);
            }
        }
        player.revealCards(sourceObject.getName(), revealed, game);

        //If he or she does, that player puts that card onto the battlefield
        if (creatureCard != null) {
            player.putOntoBattlefieldWithInfo(creatureCard, game, Zone.LIBRARY, source.getSourceId());
        }
View Full Code Here

        return new SetToughnessSourceEffect(this);
    }

    @Override
    public boolean apply(Game game, Ability source) {
        MageObject mageObject = game.getObject(source.getSourceId());
        if (mageObject != null) {
            int value = amount.calculate(game, source, this);
            mageObject.getToughness().setValue(value);
            return true;
        }
        return false;
    }
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.