Package mage.game.events

Examples of mage.game.events.GameEvent


        if (this.getOriginalExpansionSetCode() != null && !this.getOriginalExpansionSetCode().isEmpty()) {
            setCode = this.getOriginalExpansionSetCode();
        } else {
            setCode = source != null ? source.getExpansionSetCode() : null;
        }
        GameEvent event = GameEvent.getEvent(EventType.CREATE_TOKEN, null, sourceId, controllerId, amount);
        if (!game.replaceEvent(event)) {
            amount = event.getAmount();
            for (int i = 0; i < amount; i++) {
                PermanentToken newToken = new PermanentToken(this, controllerId, setCode, game);
                game.getState().addCard(newToken);
                game.addPermanent(newToken);
                if (tapped) {
View Full Code Here


        return faceDown;
    }

    @Override
    public boolean turnFaceUp(Game game, UUID playerId) {
        GameEvent event = GameEvent.getEvent(GameEvent.EventType.TURNFACEUP, getId(), playerId);
        if (!game.replaceEvent(event)) {
            setFaceDown(false);
            game.getCard(objectId).setFaceDown(false); // Another instance?
            for (Ability ability :abilities) { // abilities that were set to not visible face down must be set to visible again
                if (ability.getWorksFaceDown() && !ability.getRuleVisible()) {
View Full Code Here

        return false;
    }

    @Override
    public boolean turnFaceDown(Game game, UUID playerId) {
        GameEvent event = GameEvent.getEvent(GameEvent.EventType.TURNFACEDOWN, getId(), playerId);
        if (!game.replaceEvent(event)) {
            setFaceDown(true);
            game.getCard(objectId).setFaceDown(true); // Another instance?
            game.fireEvent(GameEvent.getEvent(GameEvent.EventType.TURNEDFACEDOWN, getId(), playerId));
            return true;
View Full Code Here

        addCounters(name, amount, game, null);
    }

    @Override
    public void addCounters(String name, int amount, Game game, ArrayList<UUID> appliedEffects) {
        GameEvent countersEvent = GameEvent.getEvent(GameEvent.EventType.ADD_COUNTERS, objectId, ownerId, name, amount);
        countersEvent.setAppliedEffects(appliedEffects);
        if (!game.replaceEvent(countersEvent)) {
            for (int i = 0; i < countersEvent.getAmount(); i++) {
                GameEvent event = GameEvent.getEvent(GameEvent.EventType.ADD_COUNTER, objectId, ownerId, name, 1);
                event.setAppliedEffects(appliedEffects);
                if (!game.replaceEvent(event)) {
                    counters.addCounter(name, 1);
                    game.fireEvent(GameEvent.getEvent(GameEvent.EventType.COUNTER_ADDED, objectId, ownerId, name, 1));
                }
            }
View Full Code Here

        addCounters(counter, game, null);
    }

    @Override
    public void addCounters(Counter counter, Game game, ArrayList<UUID> appliedEffects) {
        GameEvent countersEvent = GameEvent.getEvent(GameEvent.EventType.ADD_COUNTERS, objectId, ownerId, counter.getName(), counter.getCount());
        countersEvent.setAppliedEffects(appliedEffects);
        if (!game.replaceEvent(countersEvent)) {
            int amount = countersEvent.getAmount();
            for (int i = 0; i < amount; i++) {
                Counter eventCounter = counter.copy();
                eventCounter.remove(amount - 1);
                GameEvent event = GameEvent.getEvent(GameEvent.EventType.ADD_COUNTER, objectId, ownerId, counter.getName(), 1);
                event.setAppliedEffects(appliedEffects);
                if (!game.replaceEvent(event)) {
                    counters.addCounter(eventCounter);
                    game.fireEvent(GameEvent.getEvent(GameEvent.EventType.COUNTER_ADDED, objectId, ownerId, counter.getName(), 1));
                }
            }
View Full Code Here

    @Override
    public void removeCounters(String name, int amount, Game game) {
        for (int i = 0; i < amount; i++) {
            counters.removeCounter(name, 1);
            GameEvent event = GameEvent.getEvent(GameEvent.EventType.COUNTER_REMOVED, objectId, ownerId);
            event.setData(name);
            game.fireEvent(event);
        }
    }
View Full Code Here

                        controller.moveCardToLibraryWithInfo(cardController, source.getSourceId(), game, Zone.LIBRARY, topController, true);
                    }
                    if (cardOpponent != null)  {
                        opponent.moveCardToLibraryWithInfo(cardOpponent, source.getSourceId(), game, Zone.LIBRARY, topOpponent, true);
                    }
                    game.fireEvent(new GameEvent(EventType.CLASHED, opponent.getId(), source.getSourceId(), controller.getId(), 0, cmcController > cmcOpponent));
                    // set opponent to DoIfClashWonEffect
                    for (Effect effect :source.getEffects()) {
                        if (effect instanceof DoIfClashWonEffect) {
                            effect.setValue("clashOpponent", opponent);
                        }                       
View Full Code Here

        }
        for (ManaPoolItem mana : manaItems) {
            if (filter == null || filter.match(game.getObject(mana.getSourceId()), game)) {
                boolean spendAnyMana = spendAnyMana(ability, game);
                if (mana.get(manaType) > 0 || (spendAnyMana && mana.count() > 0)) {
                    game.fireEvent(new GameEvent(GameEvent.EventType.MANA_PAYED, ability.getId(), mana.getSourceId(), ability.getControllerId(), 0, mana.getFlag()));
                    if (spendAnyMana) {
                        mana.removeAny();
                    } else {
                        mana.remove(manaType);
                    }
View Full Code Here

            ConditionalMana conditionalItem = item.getConditionalMana();
            for (ManaType manaType : ManaType.values()) {
                if (!doNotEmptyManaTypes.contains(manaType)) {
                    if (item.get(manaType) > 0) {
                        if (!item.getDuration().equals(Duration.EndOfTurn) || game.getPhase().getType().equals(TurnPhase.END)) {
                             if (game.replaceEvent(new GameEvent(GameEvent.EventType.EMPTY_MANA_POOL, playerId, null, playerId))) {
                                int amount = item.get(manaType);
                                item.clear(manaType);
                                item.add(ManaType.COLORLESS, amount);
                            } else {
                                total += item.get(manaType);
                                item.clear(manaType);
                            }
                        }
                    }
                    if (conditionalItem != null) {
                        if (conditionalItem.get(manaType) > 0) {
                            if (!item.getDuration().equals(Duration.EndOfTurn) || game.getPhase().getType().equals(TurnPhase.END)) {
                                 if (game.replaceEvent(new GameEvent(GameEvent.EventType.EMPTY_MANA_POOL, playerId, null, playerId))) {
                                    int amount = conditionalItem.get(manaType);
                                    conditionalItem.clear(manaType);
                                    conditionalItem.add(ManaType.COLORLESS, amount);
                                } else {
                                    total += conditionalItem.get(manaType);
View Full Code Here

                if (emptyOnTurnsEnd) {
                    item.setDuration(Duration.EndOfTurn);
                }               
                this.manaItems.add(item);
            }
            GameEvent event = GameEvent.getEvent(GameEvent.EventType.MANA_ADDED, source.getId(), source.getSourceId(), source.getControllerId());
            event.setData(mana.toString());
            game.fireEvent(event);
        }
    }
View Full Code Here

TOP

Related Classes of mage.game.events.GameEvent

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.