Package com.barrybecker4.game.common.board

Examples of com.barrybecker4.game.common.board.CaptureList



    private int addJumpMoves(BoardPosition pos, int rowInc, TwoPlayerMove lastMove,
                             BoardPosition next, BoardPosition beyondNext, MoveList moveList) {
       CheckersMove m;
       CaptureList capture = new CaptureList();
       capture.add( next.copy() );
       m = CheckersMove.createMove( pos.getLocation(), beyondNext.getLocation(),
                                    capture, lastMove.getValue(), pos.getPiece().copy() );

       List<CheckersMove> jumps = findJumpMoves( beyondNext, rowInc, m, weights_ );
       moveList.addAll( jumps );
View Full Code Here


        // loop through the possible moves.
        // if any of them capture the king then the opponents king is in check.
        for (Object move : moves) {
            ChessMove nextMove = (ChessMove) move;
            CaptureList cl = nextMove.captureList;
            if (null != cl && !cl.isEmpty()) {
                ChessPiece piece = (ChessPiece)cl.getFirst().getPiece();
                if (piece.is(ChessPieceType.KING)) {
                    checked = true;
                    break;
                }
            }
View Full Code Here

     */
    public static boolean isTakeBack( int row, int col, GoMove lastMove, GoBoard board ) {

        if ( lastMove == null ) return false;

        CaptureList captures = lastMove.getCaptures();
        if ( captures != null && captures.size() == 1 ) {
            GoBoardPosition capture = (GoBoardPosition) captures.getFirst();
            if ( capture.getRow() == row && capture.getCol() == col ) {
                GoBoardPosition lastStone =
                        (GoBoardPosition) board.getPosition( lastMove.getToRow(), lastMove.getToCol() );
                if ( lastStone.getNumLiberties( board ) == 1 && lastStone.getString().getMembers().size() == 1 ) {
                    GameContext.log( 2, "it is a takeback " );
View Full Code Here

            throw new RuntimeException(e);
        }

        try {
            // initial update to the game tables for someone entering the room.
            GameCommand cmd = new GameCommand(GameCommand.Name.UPDATE_TABLES, cmdProcessor.getTables());
            update(cmd);

            while (!stopped) {
                // receive the serialized commands that are sent and process them.
                cmd = (GameCommand) iStream.readObject();
View Full Code Here

            default:
                assert false : "Unhandled command: "+ cmd;
        }

        if (useUpdateTable) {
            GameCommand response = new GameCommand(GameCommand.Name.UPDATE_TABLES, getTables());
            responses.add(0, response)// add as first command in response.
        }

        return responses;
    }
View Full Code Here

        // get all robot player actions until the next human player
        List<PlayerAction> robotActions = ((MultiGameController)controller_).getRecentRobotActions();

        for (PlayerAction act : robotActions) {
            GameCommand robotCmd = new GameCommand(GameCommand.Name.DO_ACTION, act);
            GameContext.log(0, "adding response command for robot action on server :" + robotCmd);
            responses.add(robotCmd);
        }
    }
View Full Code Here

        GameContext.log(0, "UpdateWorker terminated.");
    }

    private void processNextCommand() throws IOException, ClassNotFoundException {

        GameCommand cmd = (GameCommand) inputStream.readObject();
        GameContext.log(0, "Client Connection: got an update from the server:" + cmd);

        boolean processed = false;
        int count = 0;
View Full Code Here

                GameContext.log(2, "chat message=" + cmd.getArgument());
                useUpdateTable = false;
                responses.add(cmd);
                break;
            case START_GAME:
                OnlineGameTable tableToStart = (OnlineGameTable) cmd.getArgument();
                startGame(tableToStart);
                useUpdateTable = false;
                tableManager.removeTable(tableToStart);
                break;
            case DO_ACTION :
View Full Code Here

    /**
     * Create the online game server to serve all online clients.
     */
    public GameTableManager() {

        tables_ = new OnlineGameTableList();
    }
View Full Code Here

    /**
     * Create the online game server to serve all online clients.
     */
    private OnlineGameServerFrame(String gameName) {
        initUI(gameName);
        server = new OnlineGameServer(gameName, textArea);
    }
View Full Code Here

TOP

Related Classes of com.barrybecker4.game.common.board.CaptureList

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.