Package mage

Examples of mage.MageObject


        this.gainedTemporary = ability.gainedTemporary;
    }

    @Override
    public boolean canActivate(UUID playerId, Game game) {
        MageObject object = game.getObject(sourceId);
        return (object.getCardType().contains(CardType.INSTANT) ||
                object.hasAbility(FlashAbility.getInstance().getId(), game) ||
                game.getContinuousEffects().asThough(sourceId, AsThoughEffectType.CAST_AS_INSTANT, this, playerId,  game) ||
                game.canPlaySorcery(playerId));
    }
View Full Code Here


        return new GetEmblemTargetPlayerEffect(this);
    }

    @Override
    public boolean apply(Game game, Ability source) {
        MageObject sourceObject = game.getObject(source.getSourceId());
        if (sourceObject == null) {
            return false;
        }
        Player toPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
        if (toPlayer == null) {
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

*/
public class CreatureCastManaCondition extends ManaCondition implements Condition {
    @Override
    public boolean apply(Game game, Ability source) {
        if (source instanceof SpellAbility) {
            MageObject object = game.getObject(source.getSourceId());
            if (object != null && object.getCardType().contains(CardType.CREATURE)) {
                return true;
            }
        }
        return false;
    }
View Full Code Here

public class ArtifactCastManaCondition extends ManaCondition implements Condition {
    @Override
    public boolean apply(Game game, Ability source) {
        if (source instanceof SpellAbility) {
            MageObject object = game.getObject(source.getSourceId());
            if (object != null && object.getCardType().contains(CardType.ARTIFACT)) {
                return true;
            }
        }
        return false;
    }
View Full Code Here

        this.setColor = effect.setColor;
    }

    @Override
    public boolean apply(Game game, Ability source) {
        MageObject o = game.getObject(source.getSourceId());
        if (o != null) {
            if (o instanceof Permanent || o instanceof StackObject) {
                o.getColor().setColor(setColor);
            }
        }

        return false;
    }
View Full Code Here

        if (target == null) {
            throw new IllegalArgumentException("Target can't be null");
        }
        // A copy contains only the attributes of the basic card or basic Token that's the base of the permanent
        // else gained abililies would be copied too.
        MageObject sourceObj = source;
        if (source instanceof PermanentToken) {
            sourceObj = ((PermanentToken) source).getToken();
            // to show the source image, the original values have to be used
            target.setOriginalExpansionSetCode(((Token)sourceObj).getOriginalExpansionSetCode());
            target.setOriginalCardNumber(((Token)sourceObj).getOriginalCardNumber());
        } else if (source instanceof PermanentCard) {
            sourceObj = ((PermanentCard) source).getCard();
            target.setOriginalExpansionSetCode(source.getExpansionSetCode());
            target.setOriginalCardNumber(source.getCardNumber());
        } else {
            target.setOriginalExpansionSetCode(source.getExpansionSetCode());
            target.setOriginalCardNumber(source.getCardNumber());
        }

        target.setName(sourceObj.getName());
        target.getColor().setColor(sourceObj.getColor());
        target.getManaCost().clear();
        target.getManaCost().add(sourceObj.getManaCost());
        target.getCardType().clear();
        for (CardType type : sourceObj.getCardType()) {
            target.getCardType().add(type);
        }
        target.getSubtype().clear();
        for (String type : sourceObj.getSubtype()) {
            target.getSubtype().add(type);
        }
        target.getSupertype().clear();
        for (String type : sourceObj.getSupertype()) {
            target.getSupertype().add(type);
        }

        target.getAbilities().clear();

        for (Ability ability0 : sourceObj.getAbilities()) {
            Ability ability = ability0.copy();
            ability.newId();
            ability.setSourceId(target.getId());
            target.addAbility(ability);
        }
        // Needed to do it this way because only the cardValue does not include the increased value from cards like "Intangible Virtue" will be copied.
        target.getPower().initValue(Integer.parseInt(sourceObj.getPower().toString()));
        target.getToughness().initValue(Integer.parseInt(sourceObj.getToughness().toString()));

        return target;
    }
View Full Code Here

        return new EpicReplacementEffect(this);
    }

    @Override
    public String getInfoMessage(Ability source, GameEvent event, Game game) {
        MageObject mageObject = game.getObject(source.getSourceId());
        if (mageObject != null) {
            return "For the rest of the game, you can't cast spells (Epic - " + mageObject.getName() +")";
        }
        return null;
    }
View Full Code Here

   
    @Override
    public boolean applies(GameEvent event, Ability source, Game game) {
        if (event.getType() == GameEvent.EventType.CAST_SPELL
                && source.getControllerId() == event.getPlayerId()) {
            MageObject object = game.getObject(event.getSourceId());
            if (object != null) {
                return true;
            }
        }
        return false;
View Full Code Here

        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

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.