Package mage.players

Examples of mage.players.PlayerList


        if (sourcePermanent != null && controller != null) {           
            int count = sourcePermanent.getCounters().getCount(CounterType.DESPAIR);
            if (count > 0) {
                // select the permanents and hand cards in turn order
                LinkedList<UUID> selectedObjects = new LinkedList<>();
                PlayerList playerList = game.getState().getPlayerList(controller.getId());
                Player currentPlayer = controller;
                do {
                    selectCards(currentPlayer, selectedObjects, count, source, game);
                    currentPlayer = playerList.getNextInRange(controller, game);                   
                } while (!currentPlayer.equals(controller) && controller.isInGame());
               
                // move permanents and hand cards to exile
                for (UUID objectId : selectedObjects) {
                    if (game.getState().getZone(objectId).equals(Zone.BATTLEFIELD)) {
View Full Code Here


    }

    @Override
    public int calculate(Game game, Ability sourceAbility, Effect effect) {
        int amount = 0;
        PlayerList playerList = game.getPlayerList();
        for (UUID playerUUID : playerList) {
            Player player = game.getPlayer(playerUUID);
            if (player != null) {
                amount += player.getGraveyard().count(filter, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game);
            }
View Full Code Here

        return new TariffEffect(this);
    }
   
    @Override
    public boolean apply(Game game, Ability source) {
        PlayerList playerList = game.getPlayerList().copy();
        playerList.setCurrent(game.getActivePlayerId());
        Player player = game.getPlayer(game.getActivePlayerId());
       
        do {
            processPlayer(game, source, player);
            player = playerList.getNext(game);
        } while (!player.getId().equals(game.getActivePlayerId()));
       
        return true;
    }
View Full Code Here

        if (controller != null) {

            // Map of players and their piles (1,2,3) with values of UUID of the permanents
            Map<UUID, Map<Integer, Set<UUID>>> playerPermanents = new LinkedHashMap<>();

            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(true, 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) {
        game.getPlayerList();
        Player controller = game.getPlayer(source.getControllerId());
        if (controller != null) {
            PlayerList playerList = game.getPlayerList();
            playerList.setCurrent(game.getActivePlayerId());
            Player player = game.getPlayer(game.getActivePlayerId());
            do {
                ArrayList<Permanent> permanentsToTop = new ArrayList<>();
                ArrayList<Permanent> permanentsToBottom = new ArrayList<>();
                for (Permanent permanent:game.getState().getBattlefield().getActivePermanents(new FilterAttackingCreature(), player.getId(), source.getSourceId(), game)) {
                    if (permanent.getOwnerId().equals(player.getId())) {
                        if (player.chooseUse(outcome, "Put " + permanent.getLogName() + " to the top? (else it goes to bottom)", game)) {
                            permanentsToTop.add(permanent);
                            game.informPlayers(permanent.getLogName() + " goes to the top of " + player.getName() + "'s library");
                        } else {
                            permanentsToBottom.add(permanent);
                            game.informPlayers(permanent.getLogName() + " goes to the bottom of " + player.getName() + "'s library");
                        }
                    }
                }
                // cards to top
                Cards cards = new CardsImpl();
                ArrayList<Permanent> toLibrary = new ArrayList<>();
                for (Permanent permanent: permanentsToTop) {
                    if (permanent instanceof PermanentToken) {
                        toLibrary.add(permanent);
                    } else {
                        Card card = game.getCard(permanent.getId());
                        if (card != null) {
                            cards.add(card);
                        }
                    }
                }
                TargetCard target = new TargetCard(Zone.BATTLEFIELD, new FilterCard("order to put on the top of library (last choosen will be the top most)"));
                while (player.isInGame() && cards.size() > 1) {
                    player.choose(Outcome.Neutral, cards, target, game);
                    Card card = cards.get(target.getFirstTarget(), game);
                    if (card != null) {
                        cards.remove(card);
                        Permanent permanent = game.getPermanent(card.getId());
                        if (permanent != null) {
                            toLibrary.add(permanent);
                        }
                    }
                    target.clearChosen();
                }
                if (cards.size() == 1) {
                    Card card = cards.get(cards.iterator().next(), game);
                    Permanent permanent = game.getPermanent(card.getId());
                    if (permanent != null) {
                        toLibrary.add(permanent);
                    }
                }
                // move all permanents to lib at the same time
                for(Permanent permanent: toLibrary) {
                    player.moveCardToLibraryWithInfo(permanent, source.getSourceId(), game, Zone.BATTLEFIELD, true, false);
                }
                // cards to bottom
                cards.clear();
                toLibrary.clear();
                for (Permanent permanent: permanentsToBottom) {
                    if (permanent instanceof PermanentToken) {
                        toLibrary.add(permanent);
                    } else {
                        Card card = game.getCard(permanent.getId());
                        if (card != null) {
                            cards.add(card);
                        }
                    }
                }
                target = new TargetCard(Zone.BATTLEFIELD, new FilterCard("order to put on bottom of library (last choosen will be bottommost card)"));
                while (player.isInGame() && cards.size() > 1) {
                    player.choose(Outcome.Neutral, cards, target, game);
                    Card card = cards.get(target.getFirstTarget(), game);
                    if (card != null) {
                        cards.remove(card);
                        Permanent permanent = game.getPermanent(card.getId());
                        if (permanent != null) {
                            toLibrary.add(permanent);
                        }
                    }
                    target.clearChosen();
                }
                if (cards.size() == 1) {
                    Card card = cards.get(cards.iterator().next(), game);
                    Permanent permanent = game.getPermanent(card.getId());
                    if (permanent != null) {                   
                        toLibrary.add(permanent);
                    }
                }
                // move all permanents to lib at the same time
                for(Permanent permanent: toLibrary) {
                    player.moveCardToLibraryWithInfo(permanent, source.getSourceId(), game, Zone.BATTLEFIELD, false, false);
                }
                player = playerList.getNext(game);           
            } while (player != null && !player.getId().equals(game.getActivePlayerId()));
            return true;
        }
        return false;
    }
View Full Code Here

        Card sourceCard = game.getCard(source.getSourceId());
        Map<UUID, Integer> payLife = new HashMap<>();
        int currentLifePaid;
        int totalPaidLife;
        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;

            while (controller.isInGame()) {
                if (currentPlayer != null && controller.getInRange().contains(currentPlayer.getId())) {
                    if (firstInactivePlayer == null) {
                        firstInactivePlayer = currentPlayer.getId();
                    }
                    currentLifePaid = 0;
                    totalPaidLife = 0;
                    if (currentPlayer.chooseUse(Outcome.AIDontUseIt, "Pay life?", game)) {
                        totalPaidLife = currentPlayer.getAmount(0, controller.getLife(), "Pay how many life?", game);
                        if (totalPaidLife > 0) {
                            currentPlayer.loseLife(totalPaidLife, game);
                            if (payLife.get(currentPlayer.getId()) == null) {
                                payLife.put(currentPlayer.getId(), totalPaidLife);
                            } else {
                                currentLifePaid = payLife.get(currentPlayer.getId());
                                payLife.put(currentPlayer.getId(), currentLifePaid + totalPaidLife);
                            }
                        }
                        game.informPlayers(new StringBuilder(sourceCard.getName()).append(": ").append(currentPlayer.getName()).append(" pays ").append(payLife.get(currentPlayer.getId())).append(" life").toString());
                        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 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(new FilterPermanentCard());

            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 permanent 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

            Effect effect = new PutTokenOntoBattlefieldCopyTargetEffect();
            effect.setTargetPointer(getTargetPointer());
            effect.apply(game, source);

            Set<UUID> playersSaidYes = new HashSet<>();
            PlayerList playerList = game.getPlayerList().copy();
            playerList.setCurrent(game.getActivePlayerId());
            Player player = game.getPlayer(game.getActivePlayerId());
            do {
                if (game.getOpponents(source.getControllerId()).contains(player.getId())) {
                    String decision;
                    if (player.chooseUse(outcome, "Put a copy of target creature onto the battlefield for you?", game)) {
                        playersSaidYes.add(player.getId());
                        decision = " chooses to copy ";
                    } else {
                        decision = " won't copy ";
                    }
                    game.informPlayers((new StringBuilder(player.getName()).append(decision).append(permanent.getName()).toString()));
                }
                player = playerList.getNext(game);
            } while (!player.getId().equals(game.getActivePlayerId()));

            for (UUID playerId: playersSaidYes) {
                effect = new PutTokenOntoBattlefieldCopyTargetEffect(playerId);
                effect.setTargetPointer(getTargetPointer());
View Full Code Here

            Map<Permanent, Integer> chosenCards = new HashMap<>(2);
            int maxCount = 0;
            FilterNonlandPermanent filter = new FilterNonlandPermanent("a nonland permanent " + controller.getName() + " doesn't control");
            filter.add(Predicates.not(new ControllerIdPredicate(controller.getId())));
            //Players each choose a legal permanent
            PlayerList playerList = game.getState().getPlayerList();
            while (!playerList.get().equals(controller.getId()) && controller.isInGame()) {
                playerList.getNext();
            }
            do {
                Player player = game.getPlayer(playerList.get());
                if (player != null) {
                    Target target = new TargetNonlandPermanent(filter);
                    target.setNotTarget(true);
                    if (player.choose(Outcome.Exile, target, source.getSourceId(), game)) {
                        Permanent permanent = game.getPermanent(target.getFirstTarget());
                        if (permanent != null) {
                            if (chosenCards.containsKey(permanent)) {
                                int count = chosenCards.get(permanent) + 1;
                                if (count > maxCount) {
                                    maxCount = count;
                                }
                                chosenCards.put(permanent, count);
                            }
                            else {
                                if (maxCount == 0) {
                                    maxCount = 1;
                                }
                                chosenCards.put(permanent, 1);
                            }
                            game.informPlayers(player.getName() + " has chosen: " + permanent.getName());
                        }
                    }
                }
            } while (playerList.getNextInRange(controller, game) != controller && controller.isInGame());
            //Exile the card(s) with the most votes.
            for (Entry<Permanent, Integer> entry : chosenCards.entrySet()) {
                if (entry.getValue() == maxCount) {
                    Permanent permanent = entry.getKey();
                    controller.moveCardToExileWithInfo(permanent, null, "", source.getSourceId(), game, Zone.BATTLEFIELD);
View Full Code Here

        if (controller == null) {
            return false;
        }
        List<Card> cardsToPutIntoPlay = new ArrayList<>();
        TargetCardInHand target = new TargetCardInHand(filter);
        PlayerList playerList = game.getPlayerList().copy();
        playerList.setCurrent(game.getActivePlayerId());
        Player player = game.getPlayer(game.getActivePlayerId());
        do {
            if (player.chooseUse(outcome, "Put an artifact, creature, enchantment, or land card from hand onto the battlefield?", game)) {
                target.clearChosen();
                if (player.chooseTarget(outcome, target, source, game)) {
                    Card card = game.getCard(target.getFirstTarget());
                    if (card != null) {
                        cardsToPutIntoPlay.add(card);
                    }
                }
            }
            player = playerList.getNextInRange(controller, game);
        } while (!player.getId().equals(game.getActivePlayerId()));

        for (Card card: cardsToPutIntoPlay) {
            player = game.getPlayer(card.getOwnerId());
            if (player != null) {
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.