Package mage.players

Examples of mage.players.PlayerList


                            if (planeswalker != null) {
                                defender = game.getPlayer(planeswalker.getControllerId());
                            }
                        }
                        if (defender != null) {
                            PlayerList playerList = game.getState().getPlayerList(event.getPlayerId());
                            if (allowedDirection.equals(MysticBarrier.ALLOW_ATTACKING_LEFT)) {
                                if (!playerList.getNext().equals(defender.getId())) {
                                    // the defender is not the player to the left
                                    Player attacker = game.getPlayer(event.getPlayerId());
                                    if (attacker != null) {
                                        game.informPlayer(attacker, "You can only attack to the left!");
                                    }
                                    return true;
                                }
                            }
                            if (allowedDirection.equals(MysticBarrier.ALLOW_ATTACKING_RIGHT)) {
                                if (!playerList.getPrevious().equals(defender.getId())) {
                                    // the defender is not the player to the right
                                    Player attacker = game.getPlayer(event.getPlayerId());
                                    if (attacker != null) {
                                        game.informPlayer(attacker, "You can only attack to the right!");
                                    }
View Full Code Here


    @Override
    public boolean apply(Game game, Ability source) {
        List<Permanent> permanents = new ArrayList<>();
        Target target = new TargetNonlandPermanent();
        target.setNotTarget(false);
        PlayerList playerList = game.getPlayerList().copy();
        playerList.setCurrent(game.getActivePlayerId());
        Player player = game.getPlayer(game.getActivePlayerId());
        do {
            target.clearChosen();
            if (player.chooseTarget(outcome, target, source, game)) {
                Permanent permanent = game.getPermanent(target.getFirstTarget());
                if (permanent != null) {
                    permanents.add(permanent);
                    game.informPlayers((new StringBuilder(player.getName()).append(" chooses ").append(permanent.getName()).toString()));
                }
            }
            player = playerList.getNext(game);
        } while (!player.getId().equals(game.getActivePlayerId()));

        for (Permanent permanent: permanents) {
            permanent.addCounters(CounterType.DOOM.createInstance(), game);
        }
View Full Code Here

    public boolean apply(Game game, Ability source) {
        Player controller = game.getPlayer(source.getControllerId());
        if (controller != null) {
            Map<UUID, UUID> playerCreature = new HashMap<>();
            boolean left = source.getChoices().get(0).getChoice().equals("Left");
            PlayerList playerList = game.getState().getPlayerList();
            while (!playerList.get().equals(source.getControllerId()) && controller.isInGame()) {
                playerList.getNext();
            }
            Player currentPlayer = game.getPlayer(playerList.get());
            Player nextPlayer;
            UUID firstNextPlayer = null;

            while (!getNextPlayerInDirection(left, playerList, game).equals(firstNextPlayer) && controller.isInGame()){
                nextPlayer = game.getPlayer(playerList.get());
                if (nextPlayer == null) {
                    return false;
                }
                if (firstNextPlayer == null) {
                    firstNextPlayer = nextPlayer.getId();
View Full Code Here

    }

    @Override
    public boolean apply(Game game, Ability source) {
        Random random = new Random();
        PlayerList players = game.getPlayerList();
        int count = players.size();
        if (count > 1) {
            FilterNonlandPermanent nonLand = new FilterNonlandPermanent();
            for (Permanent permanent : game.getBattlefield().getActivePermanents(nonLand, source.getControllerId(), source.getSourceId(), game)) {
                ContinuousEffect effect = new ScrambleverseControlEffect(players.get(random.nextInt(count)));
                effect.setTargetPointer(new FixedTarget(permanent.getId()));
                game.addEffect(effect, source);
            }
        }
        return true;
View Full Code Here

    @Override
    public boolean apply(Game game, Ability source) {
        Player controller = game.getPlayer(source.getControllerId());
        if (controller != null) {
            PlayerList playerList = game.getState().getPlayerList();
            while (!playerList.get().equals(source.getControllerId()) && controller.isInGame()) {
                playerList.getNext();
            }
            Player currentPlayer = game.getPlayer(playerList.get());
            UUID firstInactivePlayer = null;
            Target target = new TargetCardInHand(filter);

            while (controller.isInGame()) {
                if (currentPlayer != null && controller.getInRange().contains(currentPlayer.getId())) {
                    if (firstInactivePlayer == null) {
                        firstInactivePlayer = currentPlayer.getId();
                    }
                    target.clearChosen();
                    if (target.canChoose(source.getSourceId(), currentPlayer.getId(), game)
                            && currentPlayer.chooseUse(outcome, "Put card from your hand to play?", game)) {
                        if (target.chooseTarget(outcome, currentPlayer.getId(), source, game)) {
                            Card card = game.getCard(target.getFirstTarget());
                            if (card != null) {
                                currentPlayer.putOntoBattlefieldWithInfo(card, game, Zone.HAND, source.getSourceId());
                                firstInactivePlayer = null;
                            }
                        }
                    }
                }
                // get next player
                playerList.getNext();
                currentPlayer = game.getPlayer(playerList.get());
                // if all player since this player didn't put permanent in play finish the process
                if (currentPlayer.getId().equals(firstInactivePlayer)) {
                    break;
                }
            }
View Full Code Here

   
    @Override
    public void init(Ability source, Game game) {
        Permanent targetCreature = game.getPermanent(source.getFirstTarget());
        if (targetCreature != null) {
            PlayerList playerList = game.getPlayerList().copy();
            playerList.setCurrent(game.getActivePlayerId());
           
            Player winner = game.getPlayer(game.getActivePlayerId());
            int highBid = 0;
            game.informPlayers(new StringBuilder(winner.getName()).append(" bet 0 lifes").toString());
           
            Player currentPlayer = playerList.getNext(game);
            while (currentPlayer != winner) {
                String text = new StringBuilder(winner.getName()).append(" bet ").append(highBid).append(" life")
                        .append(highBid > 1 ? "s" : "").append(". Top the bid?").toString();
                if (currentPlayer.chooseUse(Outcome.GainControl, text, game)) {
                    int newBid = currentPlayer.getAmount(highBid + 1, Integer.MAX_VALUE, "Choose bid", game);
                    if (newBid > highBid) {
                        highBid = newBid;
                        winner = currentPlayer;
                        game.informPlayers(new StringBuilder(currentPlayer.getName()).append(" bet ")
                                .append(newBid).append(" life").append(newBid > 1 ? "s" : "").toString());
                    }
                }
                currentPlayer = playerList.getNext(game);
            }
           
            game.informPlayers(new StringBuilder(winner.getName()).append(" won auction with a bid of ").append(highBid).append(" life")
                    .append(highBid > 1 ? "s" : "").toString());
            winner.loseLife(highBid, game);
View Full Code Here

            permanentsOwned.put(permanent.getOwnerId(), list);
        }

        // shuffle permanents into owner's library
        Map<UUID, Integer> permanentsCount = new HashMap<>();
        PlayerList playerList = game.getPlayerList();
        playerList.setCurrent(game.getActivePlayerId());
        Player player = game.getPlayer(game.getActivePlayerId());
        do {
            List<Permanent> list = permanentsOwned.remove(player.getId());
            Integer count = 0;
            if (list != null) {
                count = list.size();
                for (Permanent permanent : list) {
                    permanent.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
                }
            }

            if (count > 0) {
                player.shuffleLibrary(game);
            }

            permanentsCount.put(player.getId(), count);
            player = playerList.getNext(game);
        } while (!player.getId().equals(game.getActivePlayerId()));


        Map<UUID, CardsImpl> cardsRevealed = new HashMap<>();

        // draw cards and reveal them
        playerList.setCurrent(game.getActivePlayerId());
        player = game.getPlayer(game.getActivePlayerId());
        do {
            Integer count = Math.min(permanentsCount.get(player.getId()), player.getLibrary().size());
            CardsImpl cards = new CardsImpl();
            for (int i = 0; i < count; i++) {
                Card card = player.getLibrary().removeFromTop(game);
                if (card != null) {
                    cards.add(card);
                }
            }
            player.revealCards("Warp World " + player.getName(), cards, game);

            cardsRevealed.put(player.getId(), cards);

            player = playerList.getNext(game);
        } while (!player.getId().equals(game.getActivePlayerId()));


        // put artifacts, creaturs and lands onto the battlefield
        playerList.setCurrent(game.getActivePlayerId());
        player = game.getPlayer(game.getActivePlayerId());
        do {
            CardsImpl cards = cardsRevealed.get(player.getId());
            for (Card card : cards.getCards(game)) {
                if (card != null && (card.getCardType().contains(CardType.ARTIFACT)
                        || card.getCardType().contains(CardType.CREATURE)
                        || card.getCardType().contains(CardType.LAND))) {
                    card.putOntoBattlefield(game, Zone.HAND, source.getSourceId(), player.getId());
                    cards.remove(card);
                }
            }

            player = playerList.getNext(game);
        } while (!player.getId().equals(game.getActivePlayerId()));

        // put enchantments onto the battlefield
        playerList.setCurrent(game.getActivePlayerId());
        player = game.getPlayer(game.getActivePlayerId());
        do {
            CardsImpl cards = cardsRevealed.get(player.getId());
            for (Card card : cards.getCards(game)) {
                if (card != null && card.getCardType().contains(CardType.ENCHANTMENT)) {
                    card.putOntoBattlefield(game, Zone.HAND, source.getSourceId(), player.getId());
                    cards.remove(card);
                }
            }

            player = playerList.getNext(game);
        } while (!player.getId().equals(game.getActivePlayerId()));

        // put the rest of the cards into the graveyard
        playerList.setCurrent(game.getActivePlayerId());
        player = game.getPlayer(game.getActivePlayerId());
        do {
            CardsImpl cards = cardsRevealed.get(player.getId());
            for (Card card : cards.getCards(game)) {
                if (card != null) {
                    card.moveToZone(Zone.GRAVEYARD, source.getSourceId(), game, false);
                }
            }

            player = playerList.getNext(game);
        } while (!player.getId().equals(game.getActivePlayerId()));

        return true;
    }
View Full Code Here

            if (card != null) {
                // reveals it instead
                player.revealCards(sourceObject != null ? sourceObject.getName() : null, new CardsImpl(card), game);
               
                // Then any other player may pay 2 life. If a player does, put that card into its owner's graveyard
                PlayerList playerList = game.getPlayerList().copy();
                playerList.setCurrent(player.getId());
                Player currentPlayer = playerList.getNext(game);
                String message = new StringBuilder("Pay 2 life to put ").append(card.getName()).append(" into graveyard?").toString();
                while (!currentPlayer.getId().equals(player.getId())) {
                    if (currentPlayer.canPayLifeCost() &&
                            currentPlayer.getLife() >= 2 &&
                            currentPlayer.chooseUse(Outcome.Benefit, message, game)) {
                        currentPlayer.loseLife(2, game);
                        player.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
                       
                        game.getState().getRevealed().reset();

                        return true;
                    }
                   
                    currentPlayer = playerList.getNext(game);
                }
               
                game.getState().getRevealed().reset();
            }
        }
View Full Code Here

TOP

Related Classes of mage.players.PlayerList

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.