Package mage

Examples of mage.MageObject


    }

    @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) {
            Choice cardChoice = new ChoiceImpl();
            switch(typeOfName) {
                case ALL:
                    cardChoice.setChoices(CardRepository.instance.getNames());
                    cardChoice.setMessage("Name a card");
                    break;
                case NON_LAND_AND_NON_CREATURE_NAME:
                    cardChoice.setChoices(CardRepository.instance.getNonLandAndNonCreatureNames());
                    cardChoice.setMessage("Name a non land and non creature card");
                    break;                   
                case NON_LAND_NAME:
                    cardChoice.setChoices(CardRepository.instance.getNonLandNames());
                    cardChoice.setMessage("Name a non land card");
                    break;                   
            }           
            cardChoice.clearChoice();
            while (!controller.choose(Outcome.Detriment, cardChoice, game)) {
                if (!controller.isInGame()) {
                    return false;
                }
            }
            String cardName = cardChoice.getChoice();
            game.informPlayers(sourceObject.getLogName() + ", named card: [" + cardName + "]");
            game.getState().setValue(source.getSourceId().toString() + INFO_KEY, cardName);
            if (sourceObject instanceof Permanent) {
                ((Permanent)sourceObject).addInfo(INFO_KEY, CardUtil.addToolTipMarkTags("Named card: " + cardName));
            }
            return true;
View Full Code Here


   @Override
    public MageObject getObject(UUID objectId) {
        if (objectId == null) {
            return null;
        }
        MageObject object;
        if (state.getBattlefield().containsPermanent(objectId)) {
            object = state.getBattlefield().getPermanent(objectId);
            state.setZone(objectId, Zone.BATTLEFIELD);
            return object;
        }
View Full Code Here

    @Override
    public UUID getControllerId(UUID objectId) {
        if (objectId == null) {
            return null;
        }
        MageObject object = getObject(objectId);
        if (object != null) {
            if (object instanceof Permanent) {
                return ((Permanent)object).getControllerId();
            }
            if (object instanceof Card) {
View Full Code Here

        return gameCards.get(cardId);
    }

    @Override
    public Ability getAbility(UUID abilityId, UUID sourceId) {
        MageObject object = getObject(sourceId);
        if (object != null) {
            return object.getAbilities().get(abilityId);
        }
        return null;
    }
View Full Code Here

        for (Effect effect : getState().getContinuousEffects().getLayeredEffects(this)) {
            if (effect instanceof CopyEffect) {
                CopyEffect copyEffect = (CopyEffect) effect;
                // there is another copy effect that our targetPermanent copies stats from
                if (copyEffect.getSourceId().equals(copyFromPermanent.getId())) {
                    MageObject object = ((CopyEffect) effect).getTarget();
                    if (object instanceof Permanent) {
                        // so we will use original card instead of target
                        Permanent original = (Permanent)object;
                        // copy it and apply changes we need
                        original = original.copy();
View Full Code Here

        }
        if (amountToPrevent != Integer.MAX_VALUE) {
            // set remaining amount
            result.setRemainingAmount(amountToPrevent -= result.getPreventedDamage());
        }
        MageObject damageSource = game.getObject(damageEvent.getSourceId());
        MageObject preventionSource = game.getObject(source.getSourceId());

        if (damageSource != null && preventionSource != null) {
            MageObject targetObject = game.getObject(event.getTargetId());
            String targetName = "";
            if (targetObject == null) {
                Player targetPlayer = game.getPlayer(event.getTargetId());
                if (targetPlayer != null) {
                    targetName = targetPlayer.getName();
                }
            } else {
                targetName = targetObject.getLogName();
            }
            StringBuilder message = new StringBuilder(preventionSource.getLogName()).append(": Prevented ");
            message.append(Integer.toString(result.getPreventedDamage())).append(" damage from ").append(damageSource.getName());
            if (!targetName.isEmpty()) {
                message.append(" to ").append(targetName);
View Full Code Here

        /*if (!lki.containsKey(objectId)) {
            return getCard(objectId);
        }*/
        Map<UUID, MageObject> lkiMap = lki.get(zone);
        if (lkiMap != null) {
            MageObject object = lkiMap.get(objectId);
            if (object != null) {
                return object.copy();
            }
            for (MageObject mageObject:lkiMap.values()) {
                if (mageObject instanceof Spell) {
                    if (((Spell)mageObject).getCard().getId().equals(objectId)) {
                        return mageObject;
View Full Code Here

    public MageObject getLastKnownInformation(UUID objectId, Zone zone, int zoneChangeCounter) {
        if (zone.equals(Zone.BATTLEFIELD)) {
            Map<Integer, MageObject> lkiMapExtended = lkiExtended.get(objectId);

            if (lkiMapExtended != null) {
                MageObject object = lkiMapExtended.get(zoneChangeCounter);
                if (object != null) {
                    return object.copy();
                }
            }
        }

        return getLastKnownInformation(objectId, zone);
View Full Code Here

    @Override
    public MageObject getShortLivingLKI(UUID objectId, Zone zone) {
        Map<UUID, MageObject> shortLivingLkiMap = shortLivingLKI.get(zone);
        if (shortLivingLkiMap != null) {
            MageObject object = shortLivingLkiMap.get(objectId);
            if (object != null) {
                return object.copy();
            }
        }
        return null;
    }
View Full Code Here

     * @param object
     */
    @Override
    public void rememberLKI(UUID objectId, Zone zone, MageObject object) {
        if (object instanceof Permanent || object instanceof StackObject) {
            MageObject copy = object.copy();

            Map<UUID, MageObject> lkiMap = lki.get(zone);
            if (lkiMap != null) {
                lkiMap.put(objectId, copy);
            } else {
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.