Package mage.game.events

Examples of mage.game.events.GameEvent


        }
    }

    @Override
    public boolean canLose(Game game) {
        return !game.replaceEvent(new GameEvent(GameEvent.EventType.LOSES, null, null, playerId));
    }
View Full Code Here


        return !game.replaceEvent(new GameEvent(GameEvent.EventType.LOSES, null, null, playerId));
    }

    @Override
    public void won(Game game) {       
        if (!game.replaceEvent(new GameEvent(GameEvent.EventType.WINS, null, null, playerId))) {
            logger.debug("player won -> start: " + this.getName());
            if (!this.loses) {
                //20130501 - 800.7, 801.16
                // all opponents in range loose the game
                for (UUID opponentId: game.getOpponents(playerId)) {
View Full Code Here

            }
        }
        if (searchedLibrary == null) {
            return false;
        }
        GameEvent event = GameEvent.getEvent(GameEvent.EventType.SEARCH_LIBRARY, targetPlayerId, playerId, playerId, Integer.MAX_VALUE);
        if (!game.replaceEvent(event)) {
            TargetCardInLibrary newTarget = target.copy();
            int count;
            int librarySearchLimit = event.getAmount();
            if (librarySearchLimit == Integer.MAX_VALUE) {
                count = searchedLibrary.count(target.getFilter(), game);
            } else {
                newTarget.setCardLimit(librarySearchLimit);
                count = Math.min(searchedLibrary.count(target.getFilter(), game), librarySearchLimit);
View Full Code Here

     */
    @Override
    public boolean flipCoin(Game game, ArrayList<UUID> appliedEffects) {
        boolean result = rnd.nextBoolean();
        game.informPlayers("[Flip a coin] " + getName() + (result ? " won (head)." : " lost (tail)."));
        GameEvent event = new GameEvent(GameEvent.EventType.FLIP_COIN, playerId, null, playerId, 0, result);
        event.setAppliedEffects(appliedEffects);
        game.replaceEvent(event);
        return event.getFlag();
    }
View Full Code Here

    }

    @Override
    public boolean replaceEvent(GameEvent event, Ability source, Game game) {
        int targetAmount = targetAmountMap.get(event.getTargetId());
        GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, event.getTargetId(), source.getSourceId(), source.getControllerId(), event.getAmount(), false);
        if (!game.replaceEvent(preventEvent)) {
            if (event.getAmount() >= targetAmount) {
                int damage = targetAmount;
                event.setAmount(event.getAmount() - targetAmount);
                targetAmountMap.remove(event.getTargetId());
View Full Code Here

        endPhase(game, activePlayerId);
        return true;
    }

    public boolean beginPhase(Game game, UUID activePlayerId) {
        if (!game.replaceEvent(new GameEvent(event, null, null, activePlayerId))) {
            game.fireEvent(new GameEvent(preEvent, null, null, activePlayerId));
            return true;
        }
        return false;
    }
View Full Code Here

        }
        return false;
    }

    public void endPhase(Game game, UUID activePlayerId) {
        game.fireEvent(new GameEvent(postEvent, null, null, activePlayerId));
    }
View Full Code Here

            if (game.isPaused() || game.gameOver(null)) {
                return;
            }
            if (!isEndTurnRequested() || phase.getType().equals(TurnPhase.END)) {
                currentPhase = phase;
                game.fireEvent(new GameEvent(GameEvent.EventType.PHASE_CHANGED, activePlayerId, null, activePlayerId));
                if (!game.getState().getTurnMods().skipPhase(activePlayerId, currentPhase.getType())) {
                    if (phase.play(game, activePlayerId)) {
                        //20091005 - 500.4/703.4n
                        game.emptyManaPools();                       
                        game.saveState(false);
View Full Code Here

                    //20091005 - 500.8
                    playExtraPhases(game, phase.getType());
                }
            }
            if (!currentPhase.equals(phase)) { // phase was changed from the card
                game.fireEvent(new GameEvent(GameEvent.EventType.PHASE_CHANGED, activePlayerId, null, activePlayerId));
                break;
            }
        }
    }
View Full Code Here

                break;
            default:
                phase = new EndPhase();
        }
        currentPhase = phase;
        game.fireEvent(new GameEvent(GameEvent.EventType.PHASE_CHANGED, activePlayerId, extraPhaseTurnMod.getId(), activePlayerId));
        Player activePlayer = game.getPlayer(activePlayerId);
        if (activePlayer != null) {
            game.informPlayers(new StringBuilder(activePlayer.getName()).append(" starts an additional ").append(phase.getType().toString()).append(" phase").toString());
        }
        phase.play(game, activePlayerId);
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.