Package mage.players

Examples of mage.players.PlayerList


    }
  }

  public void setDefenders(Game game) {
    Set<UUID> opponents = game.getOpponents(attackerId);
    PlayerList players;
    switch (game.getAttackOption()) {
      case LEFT:
        players = game.getState().getPlayerList(attackerId);
        while (true) {
          Player opponent = players.getNext(game);
          if (opponents.contains(opponent.getId())) {
            addDefender(opponent.getId(), game);
            break;
          }
        }
        break;
      case RIGHT:
        players = game.getState().getPlayerList(attackerId);
        while (true) {
          Player opponent = players.getPrevious(game);
          if (opponents.contains(opponent.getId())) {
            addDefender(opponent.getId(), game);
            break;
          }
        }
View Full Code Here


  }

  @Override
  public void start() {
    init();
    PlayerList players = state.getPlayerList(startingPlayerId);
    Player player = getPlayer(players.get());
    while (!isGameOver()) {
      if (player.getId().equals(startingPlayerId)) {
        state.setTurnNum(state.getTurnNum() + 1);
        fireInformEvent("Turn " + Integer.toString(state.getTurnNum()));
      }
      state.setActivePlayerId(player.getId());
      state.getTurn().play(this, player.getId());
      if (isGameOver())
        break;
      endOfTurn();
      player = players.getNext(this);
    }

    winnerId = findWinner();

    saveState();
View Full Code Here

  private Map<String, Object> values = new HashMap<String, Object>();
  private Map<UUID, Zone> zones = new HashMap<UUID, Zone>();

  public GameState() {
    players = new Players();
    playerList = new PlayerList();
    turn = new Turn();
    stack = new SpellStack();
    exile = new Exile();
    battlefield = new Battlefield();
    effects = new ContinuousEffects();
View Full Code Here

  public PlayerList getPlayerList() {
    return playerList;
  }

  public PlayerList getPlayerList(UUID playerId) {
    PlayerList newPlayerList = new PlayerList();
    for (Player player: players.values()) {
      if (!player.hasLeft() && !player.hasLost())
        newPlayerList.add(player.getId());
    }
    newPlayerList.setCurrent(playerId);
    return newPlayerList;
  }
View Full Code Here

    private Map<UUID, Zone> zones = new HashMap<>();
    private List<GameEvent> simultaneousEvents = new ArrayList<>();

    public GameState() {
        players = new Players();
        playerList = new PlayerList();
        turn = new Turn();
        stack = new SpellStack();
        command = new Command();
        exile = new Exile();
        revealed = new Revealed();
View Full Code Here

     *
     * @param playerId
     * @return playerList
     */
    public PlayerList getPlayerList(UUID playerId) {
        PlayerList newPlayerList = new PlayerList();
        for (Player player: players.values()) {
            if (!player.hasLeft()&& !player.hasLost()) {
                newPlayerList.add(player.getId());
            }
        }
        newPlayerList.setCurrent(playerId);
        return newPlayerList;
    }
View Full Code Here

                        message.append(" no winner ");
                    }                                      
                    game.informPlayers(message.toString());
                   
                    // decide to put the cards on top or on the buttom of library in turn order beginning with the active player in turn order
                    PlayerList playerList = game.getPlayerList().copy();
                    playerList.setCurrent(game.getActivePlayerId());
                    do {
                        Player current = playerList.getCurrent(game);
                        if (cardController != null && current.getId().equals(controller.getId())) {
                            topController = current.chooseUse(Outcome.Detriment, "Put " + cardController.getLogName() + " back on top of your library? (otherwise it goes to bottom)" , game);
                        }                       
                        if (cardOpponent != null && current.getId().equals(opponent.getId())) {
                            topOpponent = current.chooseUse(Outcome.Detriment, "Put " + cardOpponent.getLogName() + " back on top of your library? (otherwise it goes to bottom)" , game);
                        }                                               
                    } while (!playerList.getNext(game).getId().equals(game.getActivePlayerId()));
                    // put the cards back to library
                    if (cardController != null)  {
                        controller.moveCardToLibraryWithInfo(cardController, source.getSourceId(), game, Zone.LIBRARY, topController, true);
                    }
                    if (cardOpponent != null)  {
View Full Code Here

        }
    }

    @Override
    public void resume() {
        PlayerList players = state.getPlayerList(state.getActivePlayerId());
        Player player = getPlayer(players.get());
        boolean wasPaused = state.isPaused();
        state.resume();
        if (!gameOver(null)) {
            fireInformEvent(new StringBuilder("Turn ").append(state.getTurnNum()).toString());
            if (checkStopOnTurnOption()) {
                return;
            }
            state.getTurn().resumePlay(this, wasPaused);
            if (!isPaused() && !gameOver(null)) {
                endOfTurn();
                player = players.getNext(this);
                state.setTurnNum(state.getTurnNum() + 1);
            }
        }
        play(player.getId());
    }
View Full Code Here

        play(player.getId());
    }

    protected void play(UUID nextPlayerId) {
        if (!isPaused() && !gameOver(null)) {
            PlayerList players = state.getPlayerList(nextPlayerId);
            Player playerByOrder = getPlayer(players.get());
            while (!isPaused() && !gameOver(null)) {
                playExtraTurns();
                GameEvent event = new GameEvent(GameEvent.EventType.PLAY_TURN, null, null, playerByOrder.getId());
                if (!replaceEvent(event)) {
                    if (!playTurn(playerByOrder)) {
                        break;
                    }
                    state.setTurnNum(state.getTurnNum() + 1);
                }
                playExtraTurns();
                playerByOrder = players.getNext(this);
            }
        }
        if (gameOver(null)) {
            winnerId = findWinnersAndLosers();
            StringBuilder sb = new StringBuilder("GAME ended  gameId: ").append(this.getId()).append(" ");
View Full Code Here

        return true;
    }

    public void setDefenders(Game game) {
        Set<UUID> opponents = game.getOpponents(attackerId);
        PlayerList players;
        switch (game.getAttackOption()) {
            case LEFT:
                players = game.getState().getPlayerList(attackerId);
                while (true) {
                    Player opponent = players.getNext(game);
                    if (opponents.contains(opponent.getId())) {
                        addDefender(opponent.getId(), game);
                        break;
                    }
                }
                break;
            case RIGHT:
                players = game.getState().getPlayerList(attackerId);
                while (true) {
                    Player opponent = players.getPrevious(game);
                    if (opponents.contains(opponent.getId())) {
                        addDefender(opponent.getId(), game);
                        break;
                    }
                }
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.