Search in sources :

Example 26 with Zone

use of mage.constants.Zone in project mage by magefree.

the class TraceUtil method traceForPermanent.

private static void traceForPermanent(Game game, Permanent permanent, String uuid, ContinuousEffectsList<RestrictionEffect> restrictionEffects) {
    for (RestrictionEffect effect : restrictionEffects) {
        log.error(uuid + "     effect=" + effect.toString() + " id=" + effect.getId());
        for (Ability ability : restrictionEffects.getAbility(effect.getId())) {
            if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game, permanent, null)) {
                log.error(uuid + "        ability=" + ability + ", applies_to_attacker=" + effect.applies(permanent, ability, game));
            } else {
                boolean usable = ability.isInUseableZone(game, permanent, null);
                log.error(uuid + "        instanceof StaticAbility: " + (ability instanceof StaticAbility) + ", ability=" + ability);
                log.error(uuid + "        usable zone: " + usable + ", ability=" + ability);
                if (!usable) {
                    Zone zone = ability.getZone();
                    log.error(uuid + "        zone: " + zone);
                    MageObject object = game.getObject(ability.getSourceId());
                    log.error(uuid + "        object: " + object);
                    if (object != null) {
                        log.error(uuid + "        contains ability: " + object.getAbilities().contains(ability));
                    }
                    Zone test = game.getState().getZone(ability.getSourceId());
                    log.error(uuid + "        test_zone: " + test);
                }
            }
        }
    }
}
Also used : CantBeBlockedSourceAbility(mage.abilities.keyword.CantBeBlockedSourceAbility) StaticAbility(mage.abilities.StaticAbility) ReachAbility(mage.abilities.keyword.ReachAbility) TriggeredAbility(mage.abilities.TriggeredAbility) FlyingAbility(mage.abilities.keyword.FlyingAbility) Ability(mage.abilities.Ability) IntimidateAbility(mage.abilities.keyword.IntimidateAbility) StaticAbility(mage.abilities.StaticAbility) Zone(mage.constants.Zone) MageObject(mage.MageObject) RestrictionEffect(mage.abilities.effects.RestrictionEffect)

Example 27 with Zone

use of mage.constants.Zone in project mage by magefree.

the class GhostlyFlickerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = source.getSourceObject(game);
    if (controller != null && sourceObject != null) {
        Set<Card> toExile = new HashSet<>();
        for (UUID permanentId : targetPointer.getTargets(game, source)) {
            Permanent target = game.getPermanent(permanentId);
            if (target != null) {
                toExile.add(target);
            }
        }
        controller.moveCards(toExile, Zone.EXILED, source, game);
        game.getState().processAction(game);
        Set<Card> toBattlefield = new HashSet<>();
        for (Card card : toExile) {
            Zone currentZone = game.getState().getZone(card.getId());
            if (Zone.BATTLEFIELD != currentZone && currentZone.isPublicZone()) {
                toBattlefield.add(card);
            }
        }
        controller.moveCards(toBattlefield, Zone.BATTLEFIELD, source, game);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) Permanent(mage.game.permanent.Permanent) TargetControlledPermanent(mage.target.common.TargetControlledPermanent) Zone(mage.constants.Zone) MageObject(mage.MageObject) UUID(java.util.UUID) Card(mage.cards.Card) HashSet(java.util.HashSet)

Example 28 with Zone

use of mage.constants.Zone in project mage by magefree.

the class CantBeTargetedCardsGraveyardsEffect method applies.

@Override
public boolean applies(GameEvent event, Ability source, Game game) {
    Card targetCard = game.getCard(event.getTargetId());
    StackObject stackObject = game.getStack().getStackObject(event.getSourceId());
    if (targetCard != null && stackObject != null) {
        Zone zone = game.getState().getZone(targetCard.getId());
        if (zone != null && zone == Zone.GRAVEYARD) {
            return true;
        }
    }
    return false;
}
Also used : Zone(mage.constants.Zone) StackObject(mage.game.stack.StackObject) Card(mage.cards.Card)

Example 29 with Zone

use of mage.constants.Zone in project mage by magefree.

the class Cards method layoutCards.

private void layoutCards() {
    // get all the card panels
    java.util.List<MageCard> cardsToLayout = new ArrayList<>();
    for (Component component : cardArea.getComponents()) {
        if (component instanceof MageCard) {
            cardsToLayout.add((MageCard) component);
        }
    }
    // WARNING, must be same sort code as MageActionCallback->sortLayout (if not then hand cards will be messed after drag)
    // sort the cards
    cardsToLayout.sort(Comparator.comparingInt(cp -> cp.getCardLocation().getCardX()));
    // relocate the cards (support only horizontal style: hand and stack panels)
    // TODO: add shrinking of cards list for too big amount (cards will be overlapped, use MageActionCallback.HAND_CARDS_BETWEEN_GAP_X to control it)
    // starting position
    int dx = MageActionCallback.getHandOrStackBetweenGapX(zone);
    for (MageCard component : cardsToLayout) {
        component.setCardLocation(dx, component.getCardLocation().getCardY());
        dx += component.getCardLocation().getCardWidth() + MageActionCallback.getHandOrStackBetweenGapX(zone);
    }
}
Also used : java.util(java.util) MageActionCallback(mage.client.plugins.adapters.MageActionCallback) Zone(mage.constants.Zone) DebugUtil(mage.util.DebugUtil) CardIconRenderSettings(mage.abilities.icon.CardIconRenderSettings) ClientDefaultSettings(mage.client.util.ClientDefaultSettings) Border(javax.swing.border.Border) java.awt(java.awt) mage.view(mage.view) Logger(org.apache.log4j.Logger) PreferencesDialog(mage.client.dialog.PreferencesDialog) Plugins(mage.client.plugins.impl.Plugins) CardsViewUtil(mage.client.util.CardsViewUtil) GUISizeHelper(mage.client.util.GUISizeHelper) EmptyBorder(javax.swing.border.EmptyBorder) MageCard(mage.cards.MageCard) javax.swing(javax.swing) java.util(java.util) MageCard(mage.cards.MageCard)

Example 30 with Zone

use of mage.constants.Zone in project mage by magefree.

the class DeadbridgeChantEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null && !controller.getGraveyard().isEmpty()) {
        Card card = controller.getGraveyard().getRandom(game);
        if (card != null) {
            Zone targetZone = Zone.HAND;
            String text = " put into hand of ";
            if (card.isCreature(game)) {
                targetZone = Zone.BATTLEFIELD;
                text = " put onto battlefield for ";
            }
            controller.moveCards(card, targetZone, source, game);
            game.informPlayers("Deadbridge Chant: " + card.getName() + text + controller.getLogName());
            return true;
        }
    }
    return false;
}
Also used : Player(mage.players.Player) Zone(mage.constants.Zone) Card(mage.cards.Card)

Aggregations

Zone (mage.constants.Zone)31 Player (mage.players.Player)18 Card (mage.cards.Card)15 MageObject (mage.MageObject)13 Permanent (mage.game.permanent.Permanent)12 FilterCard (mage.filter.FilterCard)11 TargetCard (mage.target.TargetCard)9 UUID (java.util.UUID)7 Target (mage.target.Target)7 TargetOpponent (mage.target.common.TargetOpponent)6 ArrayList (java.util.ArrayList)5 CardsImpl (mage.cards.CardsImpl)5 Cards (mage.cards.Cards)4 PermanentCard (mage.game.permanent.PermanentCard)4 ZoneChangeEvent (mage.game.events.ZoneChangeEvent)3 java.util (java.util)2 HashSet (java.util.HashSet)2 LinkedHashSet (java.util.LinkedHashSet)2 Matcher (java.util.regex.Matcher)2 Ability (mage.abilities.Ability)2