Package com.barrybecker4.game.common.player

Examples of com.barrybecker4.game.common.player.Player


     * @return true if all the planets are owned by a single player
     */
    public static boolean allPlanetsOwnedByOnePlayer() {

        Iterator it = planets_.iterator();
        Player player = planets_.get(0).getOwner();
        while (it.hasNext()) {
            Planet p = (Planet)it.next();
            if (p.getOwner() != player)
                return false;
        }
View Full Code Here


    private void doBattleSequence(Order order, Planet destPlanet) {

        int numAttackShips = order.getFleetSize();
        int numDefendShips = destPlanet.getNumShips();
        Player attacker = order.getOwner();
        Player defender = destPlanet.getOwner();

        // create hit sequence
        while (numAttackShips>0 && numDefendShips>0) {
            // int total = numAttackShips + numDefendShips;
View Full Code Here

     * @param player to add
     */
    @Override
    protected void addRow(Object player)
    {
        Player p = (Player) player;
        Object d[] = new Object[getNumColumns()];
        d[NAME_INDEX] = p.getName();
        d[COLOR_INDEX] = p.getColor();
        d[HUMAN_INDEX] = p.isHuman();
        getPlayerModel().addRow(d);
    }
View Full Code Here

        if (players_.anyPlayerWon()) {
            GameContext.log(0, "Game over because one of the players has won."); // NON_NLS
            return true;
        }
        if (moveList_.getNumMoves() > 0 && move == null) {
            Player currentPlayer = getCurrentPlayer();
            GameContext.log(0, "Game is over because there are no more moves for player " + currentPlayer); // NON_NLS
            if (recordWin) {
                currentPlayer.setWon(true);
            }
            return true;
        }

        int absValue = Math.abs(move.getValue());
View Full Code Here

        PlayerOptions p1Opts =
                createPlayerOptions(GameContext.getLabel("PLAYER1"), TwoPlayerPieceRenderer.DEFAULT_PLAYER1_COLOR);
        PlayerOptions p2Opts =
                createPlayerOptions(GameContext.getLabel("PLAYER2"), TwoPlayerPieceRenderer.DEFAULT_PLAYER2_COLOR);

        players.add(new Player(p1Opts, true));
        players.add(new Player(p2Opts, false));
        return players;
    }
View Full Code Here

        }
        return text;
    }

    private String createWonMessage(PlayerList players) {
        String text;Player winningPlayer = players.getPlayer1().hasWon() ? players.getPlayer1() : players.getPlayer2();
        Player losingPlayer = players.getPlayer1().hasWon() ? players.getPlayer2() : players.getPlayer1();

        MessageFormat formatter = new MessageFormat(GameContext.getLabel("WON_MSG"));
        Object[] args = new String[5];
        if (players.allPlayersHuman()) {
            args[0] = "";
        } else {
            args[0] = winningPlayer.isHuman() ? GameContext.getLabel("YOU") : GameContext.getLabel("THE_COMPUTER");
        }
        args[1] = winningPlayer.getName();
        args[2] = Integer.toString(controller_.getNumMoves());
        args[3] = FormatUtil.formatNumber(controller_.getStrengthOfWin());
        text = formatter.format(args);

        assert(!losingPlayer.hasWon()) : "Both players should not win. Players=" + players;
        return text;
    }
View Full Code Here

        final String editWeights = GameContext.getLabel("EDIT_PLAYER_OPTIONS");
        panel.setBorder(
                BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
                        GameContext.getLabel("PLAYER_ASSIGNMENT")));

        Player p1 = controller.getPlayers().getPlayer1();
        Player p2 = controller.getPlayers().getPlayer2();

        human1Button_ = new JRadioButton( human, p1.isHuman() );
        computer1Button_ = new JRadioButton( computer, !p2.isHuman() );
        editOptions1Button_ = new GradientButton(editWeights);
        editOptions1Button_.setEnabled(!p1.isHuman());
        JPanel firstP =
                createPlayerEntry( getPlayer1Label(), human1Button_, computer1Button_, editOptions1Button_);

        human2Button_ = new JRadioButton( human, p2.isHuman());
        computer2Button_ = new JRadioButton( computer, !p2.isHuman() );
        editOptions2Button_ = new GradientButton( editWeights );
        editOptions2Button_.setEnabled( !p2.isHuman() );
        JPanel secondP =
                createPlayerEntry( getPlayer2Label(), human2Button_, computer2Button_, editOptions2Button_);

        firstP.setAlignmentX( Component.LEFT_ALIGNMENT );
        secondP.setAlignmentX( Component.LEFT_ALIGNMENT );
View Full Code Here

     * Use this version if you have only the board and not the controller.
     */
    public TwoPlayerGameExporter(TwoPlayerBoard board) {
        super(board);
        players = new PlayerList();
        players.add(new Player("player1", Color.BLACK, false));
        players.add(new Player("player2", Color.WHITE, false));
    }
View Full Code Here

        return d;
    }

    @Override
    public OnlineGameTable createOnlineTable(String ownerPlayerName, MultiGameOptions options) {
        Player player = createPlayerForName(ownerPlayerName);
        return new OnlinePokerTable(getUniqueName(), player, options);
    }
View Full Code Here

        MultiGameViewer pviewer = (MultiGameViewer) getViewer();
        pviewer.refresh();

        if (!isDone()) {
            advanceToNextPlayerIndex();
            Player currentPlayer = getCurrentPlayer();
            GameContext.log(0, "advanced to player="+ currentPlayer.getName());
            if (currentPlayer.isSurrogate()) {
                GameContext.log(0, "about to request surrogate move for " + currentPlayer
                        + " in controller=" + this + " in thread=" + Thread.currentThread().getName());
                pviewer.doSurrogateMove((SurrogateMultiPlayer)currentPlayer);
            }
            else if (!currentPlayer.isHuman()) {
                GameContext.log(0, "now moving for computer player  = " + currentPlayer);
                pviewer.doComputerMove(currentPlayer);
            }
        }
View Full Code Here

TOP

Related Classes of com.barrybecker4.game.common.player.Player

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.