亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? gamecontroller.java

?? chess 一個beguanyu國際象棋的一個Java源碼
?? JAVA
字號:
/*  GameController - A class to control the game of chess.  Copyright (C) 2003 The Java-Chess team <info@java-chess.de>  This program is free software; you can redistribute it and/or  modify it under the terms of the GNU General Public License  as published by the Free Software Foundation; either version 2  of the License, or (at your option) any later version.  This program is distributed in the hope that it will be useful,  but WITHOUT ANY WARRANTY; without even the implied warranty of  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License for more details.  You should have received a copy of the GNU General Public License  along with this program; if not, write to the Free Software  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.*/ package de.java_chess.javaChess;import de.java_chess.javaChess.board.*;import de.java_chess.javaChess.dialogs.*;import de.java_chess.javaChess.engine.*;import de.java_chess.javaChess.game.*;import de.java_chess.javaChess.notation.*;import de.java_chess.javaChess.piece.*;import de.java_chess.javaChess.ply.*;import de.java_chess.javaChess.position.*;import de.java_chess.javaChess.renderer.ChessBoardRenderer;import de.java_chess.javaChess.timer.*;import java.awt.event.*;import javax.swing.*;/** * This class controls the game. */public class GameController implements ActionListener {    // Instance variables    /**     * The current game.     */    private Game _game;    /**     * The game notation.     */    private GameNotation _gameNotation;    /**     * A flag to indicate, if white has the next move.     */    private boolean _moveRight = true;    /**     * A flag to indicate, if the computer play with white pieces.     */    private boolean _computerIsWhite = false;    /**     * The chess engine.     */    private ChessEngine _engine;    /**     * The current board.     */    private Board _board;    /**     * The renderer.     */    ChessBoardRenderer _renderer;    /**     * The timer for the game.     */    GameTimer _gameTimer;     /**     * The current game state.     */    byte _gameState;    // Constructors    /**     * Create a new controller instance.     *     * @param game The current game.     * @param gameNotation The notation of the game.     * @param engine The current engine.     * @param board The current board.     * @param timer The game timer.     */    public GameController( Game game, GameNotation gameNotation, ChessEngine engine, Board board, GameTimer timer) {	setGame( game);	setGameNotation( gameNotation);	setEngine( engine);	setBoard( board);	setGameTimer( timer);    }        // Methods    /**     * Get the current game.     *     * @return The current game.     */    public final Game getGame() {	return _game;    }    /**     * Set the current game.     *     * @param The current game.     */    public final void setGame( Game game) {	_game = game;    }    /**     * Get the current game notation.     *     * @return The current game notation.     */    public final GameNotation getGameNotation() {	return _gameNotation;    }    /**     * Set the current game notation.     *     * @param gameNotation The new game notation.     */    public final void setGameNotation( GameNotation gameNotation) {	_gameNotation = gameNotation;    }    /**     * Get the current chess engine.     *     * @return The current chess engine.     */    final ChessEngine getEngine() {	return _engine;    }    /**     * Set a new chess engine.     *     * @param engine The new engine.     */    final void setEngine( ChessEngine engine) {	_engine = engine;    }    /**     * Get the current board.     *     * @return The current board.     */    final Board getBoard() {	return _board;    }    /**     * Set a new board.     *     * @param board The new board.     */    final void setBoard( Board board) {	_board = board;    }    /**     * Get the renderer.     *     * @return The current renderer.     */    final ChessBoardRenderer getRenderer() {	return _renderer;    }    /**     * Set a new renderer.     *     * @param renderer The new renderer.     */    final void setRenderer( ChessBoardRenderer renderer) {	_renderer = renderer;    }    /**     * Get the current game timer.     *     * @return The current game timer.     */    final GameTimer getGameTimer() {	return _gameTimer;    }    /**     * Set a new game timer.     *     * @param timer The new game timer.     */    final void setGameTimer( GameTimer timer) {	_gameTimer = timer;	timer.addActionListener( this);    }    /**     * Reset the game controller.     */    public final void reset() {	_moveRight = true;               // White has the first move.	_gameState = GameState.STOPPED;  // The game is stopped until white moves.    }    /**     * Let the computer make a move.     */    public final boolean computerPly() {	Ply nextPly = getEngine().computeBestPly();	if( nextPly == null) {	    System.out.println( "No computer move returned");	    return false;	} else {	    doPly( nextPly);	    getEngine().startPermanentBrain();	    return true;	}    }    /**     * The user moved a piece.     *     * @param ply The ply of the user.     */    public final void userPly( Ply ply) {	// Before any user ply can be applied, we have to stop	// the permanent brain, so the engine is free to process	// the user ply.	getEngine().stopPermanentBrain();	// plyInterpretation	ply = convertUserPly( ply);	// Check if the user has the right to move a piece	// and made a valid move.	if( _moveRight != _computerIsWhite) {	    if( ( _gameState != GameState.CHECKMATE) && ( _gameState != GameState.DRAW) && (_gameState != GameState.TIMEOUT)) {		if( getEngine().validateUserPly( ply)) {		    doPly( ply);    // Ok => move the piece.		} else {  // The user had to right to move or made an invalid move.		    signalUserInputError( "invalid move");		}	    } else {		signalUserInputError( "game is already over");	    }	} else {	    signalUserInputError( "user is not about to move");	}    }        /**     * Try to interpretate a user ply, if it's a castling or so.     *     * @param ply The user ply.     *     * @return The converted ply.     */    private final Ply convertUserPly( Ply ply) {	Position source = ply.getSource();	Position destination = ply.getDestination();	Piece piece = getBoard().getPiece( source);	if( piece != null) {	    // Check, if the user wanted a castling.	    if( piece.getType() == Piece.KING) {		int sourceLine = source.getSquareIndex() & 7;		int destinationLine = destination.getSquareIndex() & 7;				// If the castling goes to the left.		if( ( sourceLine - 2) == destinationLine) {		    return new CastlingPlyImpl( source, true);		}		// If the castling goes to the right.		if( ( sourceLine + 2) == destinationLine) {		    return new CastlingPlyImpl( source, false);		}	    } else {  // Check if this is a transformation ply		if( piece.getType() == Piece.PAWN) {		    int destinationRow = destination.getSquareIndex() >> 3;		    // If the pawn reached the last row		    if( destinationRow == 7) {			TransformationDialog.getInstance().show();			byte pieceType = TransformationDialog.getInstance().getPieceType();			// Create and return a new transformation ply.			return new TransformationPlyImpl( source, destination, pieceType, getBoard().getPiece( destination) != null);		    } else {			int sourceLine = source.getSquareIndex() & 7;			int sourceRow = source.getSquareIndex() >> 3;			int destinationLine = destination.getSquareIndex() & 7;			if( ( sourceRow == 4)			    && ( destinationRow == 5)			    && ( 1 == Math.abs( sourceLine - destinationLine))) {			    Ply lastPly = _game.getLastPly();			    if( ( lastPly != null)				&& ( lastPly.getSource().getSquareIndex() == ( destination.getSquareIndex() + 8))				&& ( lastPly.getDestination().getSquareIndex() == ( destination.getSquareIndex() - 8))				&& ( getBoard().getPiece( lastPly.getDestination()).getType() ==  Piece.PAWN)) {				return new EnPassantPlyImpl( source, destination, new PositionImpl( destination.getSquareIndex() - 8));			    }			}		    }		}	    }	}	// Set the capture flag properly.	((PlyImpl)ply).setCapture( getBoard().getPiece( destination) != null);		return ply;  // Return the original ply    }    /**     * Perform a ply.     *     * @param ply The ply to do.     */    private final void doPly( Ply ply) {	// If the game is over, stop here.	if( _gameState == GameState.TIMEOUT) {	    return;	}	// Store the ply notation to set the check flags a bit later, since they are computed in the gameOver()	// call in the move right toggle.	PlyNotation plyNotation = new PlyNotationImpl( ply, getBoard().getPiece( ply.getSource()));	getGame().doPly( ply);	getBoard().doPly( ply);    	getRenderer().doPly( ply);	// Now try to get some info on the current game state.	boolean gameOver = gameOver( ! _moveRight);	// Set check info for this ply.	if( _gameState == GameState.CHECKMATE) {	    plyNotation.setCheckMate( true);	} else {	    if( _gameState == GameState.CHECK) {		plyNotation.setCheck( true);	    }	}		// Add the ply to the notation.	getGameNotation().addPly( plyNotation);	if( gameOver) {	    getGameTimer().stop();  // The game has ended.	    if( _gameState == GameState.DRAW) {		signalGameOver( "Draw! Use File -> Reset to play again!");	    } else {		signalGameOver( _moveRight == _computerIsWhite ? "Checkmate! I win! :-)" : "Checkmate! I lose... :-(" );	    }	} else {	    toggleMoveRight();	}    }    /**     * Turn the right to move from one player to the other.     */    public void toggleMoveRight() {	_moveRight = ! _moveRight;	if( getGameTimer().isRunning()) {	    getGameTimer().toggle();	} else {	    getGameTimer().start();	    _gameState = GameState.ONGOING;  // Change the game state to running.	}		// Check if the computer has the next move.	if( _moveRight == _computerIsWhite) {	    if( ! computerPly()) {		System.out.println( "Computer cannot move!");	    }	}    }    /**     * Check if the game is over.     *     * @param white True, if white is about to move.     *     * @return true, if the game is over.     */    private final boolean gameOver( boolean white) {	_gameState = getEngine().getCurrentGameState( white);	return ( _gameState == GameState.CHECKMATE) || ( _gameState == GameState.DRAW);    }    /**     * Process a event, that we are listening to.     *     * @param event The event.     */    public void actionPerformed( ActionEvent event) {	System.out.println( "Got event " + event.getActionCommand());	// If the timer fired the event, check for timeout.	if( event.getSource() == getGameTimer()) {	    String command = event.getActionCommand();	    if( "timeout white".equals( command)) {		_gameState = GameState.TIMEOUT;		signalGameOver( "Timeout for you! I win!");	    }	    if( "timeout black".equals( command)) {		System.out.println( "Black timeout!");		_gameState = GameState.TIMEOUT;		signalGameOver( "Timeout for me! You win!");	    }	}    }    /**     * Signal a input error to the user.     *     * @param errorMessage More information on the error.     */    public final void signalUserInputError( String errorMessage) {	System.out.print( (char)7);	JOptionPane.showMessageDialog( null, errorMessage, "Error", JOptionPane.ERROR_MESSAGE);    }    /**     * Signal the end if the game.     *     * @param gameOverMessage Some info how and why the game has ended.     */    public final void signalGameOver( String gameOverMessage) {	System.out.print( (char)7);	JOptionPane.showMessageDialog( null, gameOverMessage, "Game over", JOptionPane.INFORMATION_MESSAGE);    }}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩一区精品视频| 日韩av电影免费观看高清完整版在线观看| 欧美日韩国产综合视频在线观看| 91麻豆免费视频| 91免费国产在线| 色哟哟国产精品| 精品视频在线看| 欧美一卡二卡三卡四卡| 666欧美在线视频| 日韩欧美中文字幕一区| 久久综合色鬼综合色| 久久―日本道色综合久久| 欧美成人精品福利| 欧美精品一区二区三区在线播放 | 精品国产乱码久久久久久浪潮 | 日韩一区欧美一区| 日韩美女视频一区| 亚洲成人精品影院| 日韩成人午夜电影| 国产91精品精华液一区二区三区| av中文字幕在线不卡| 欧美午夜一区二区三区免费大片| 51精品国自产在线| 国产人伦精品一区二区| 亚洲综合成人网| 韩国v欧美v亚洲v日本v| 91麻豆精品一区二区三区| 欧美精品色一区二区三区| 国产欧美精品一区| 亚洲成a人在线观看| 国产电影一区二区三区| 日本大香伊一区二区三区| 日韩一级完整毛片| 亚洲日本丝袜连裤袜办公室| 日韩vs国产vs欧美| 91麻豆免费视频| 2014亚洲片线观看视频免费| 亚洲天堂2016| 精久久久久久久久久久| 99国产精品久久久久久久久久久| 欧美男男青年gay1069videost| 欧美不卡在线视频| 亚洲国产视频一区二区| 国产成人日日夜夜| 日韩欧美国产午夜精品| 尤物在线观看一区| 风流少妇一区二区| 精品少妇一区二区三区视频免付费| 亚洲视频你懂的| 国产精品一区二区男女羞羞无遮挡| 在线免费观看日本一区| 国产日产欧美精品一区二区三区| 日本成人在线电影网| 欧美视频一区二区三区在线观看| 久久久久久久网| 久久99热狠狠色一区二区| 欧美色爱综合网| 日韩理论电影院| gogo大胆日本视频一区| 欧美国产日产图区| 国产精品主播直播| 精品国产一区二区国模嫣然| 日本色综合中文字幕| 欧美三级视频在线观看| 亚洲激情五月婷婷| 色哟哟欧美精品| 日韩理论电影院| 91女人视频在线观看| 亚洲欧美综合在线精品| 懂色av一区二区三区蜜臀 | 国产精品一区二区黑丝| 日韩精品一区二区三区视频| 午夜私人影院久久久久| 欧美日韩免费不卡视频一区二区三区| 亚洲色图都市小说| 91视视频在线直接观看在线看网页在线看| 欧美国产在线观看| 国产精品影视网| 激情综合五月天| 91美女在线看| 欧美不卡一二三| 精品成人一区二区三区| 免费观看久久久4p| 欧美一区二区日韩| 久久精品国产一区二区| 久久亚洲综合av| 成人免费av网站| 亚洲人成精品久久久久久| 91国偷自产一区二区开放时间 | 日日摸夜夜添夜夜添亚洲女人| 欧美色中文字幕| 男人的天堂亚洲一区| 精品国产欧美一区二区| 高清不卡一区二区| 亚洲免费观看高清完整版在线 | 国产精品私房写真福利视频| 成人午夜av在线| 一区二区三区.www| 91精品国产手机| 成人午夜短视频| 亚洲一区二区三区四区五区中文| 欧美日韩一卡二卡三卡 | 亚洲专区一二三| 日韩精品一区二| 国产成人精品www牛牛影视| 亚洲男人电影天堂| 日韩免费一区二区| 99国产精品久久| 琪琪一区二区三区| 亚洲视频免费观看| 精品日韩99亚洲| 欧美影院一区二区三区| 激情文学综合丁香| 亚洲精品欧美二区三区中文字幕| 欧美一区二区三区在线看| 不卡av免费在线观看| 日本vs亚洲vs韩国一区三区二区 | 久久久久久久久久美女| 色综合av在线| 国产风韵犹存在线视精品| 调教+趴+乳夹+国产+精品| 亚洲国产成人在线| 精品国产一区二区在线观看| 在线观看91视频| 不卡的av网站| 国产不卡高清在线观看视频| 五月婷婷综合在线| 亚洲日本乱码在线观看| 中文字幕乱码久久午夜不卡| 欧美精品自拍偷拍动漫精品| 91小视频免费观看| 国产在线不卡视频| 丝袜美腿亚洲色图| 亚洲色图制服丝袜| 国产精品成人免费精品自在线观看| 日韩免费看网站| 88在线观看91蜜桃国自产| 欧美自拍偷拍一区| 色国产精品一区在线观看| 成人av电影免费观看| 国产精品99久| 国产一区二区三区在线观看免费| 偷窥少妇高潮呻吟av久久免费| 亚洲精品国产精华液| 1000精品久久久久久久久| 国产精品乱子久久久久| 国产喷白浆一区二区三区| 久久先锋资源网| 久久先锋影音av鲁色资源网| 欧美精品一区视频| 久久综合精品国产一区二区三区 | 国产视频视频一区| 欧美精品一区在线观看| 久久亚洲私人国产精品va媚药| 日韩免费观看高清完整版| 日韩精品自拍偷拍| 欧美大黄免费观看| 久久久久久影视| 国产精品理伦片| 一区二区不卡在线播放 | 亚洲电影中文字幕在线观看| 亚洲国产综合色| 偷拍日韩校园综合在线| 久久国产福利国产秒拍| 韩国精品一区二区| 国产成人啪午夜精品网站男同| 成人性色生活片| 在线区一区二视频| 日韩一级完整毛片| 国产色爱av资源综合区| 国产精品福利影院| 亚洲综合小说图片| 男男视频亚洲欧美| jizz一区二区| 欧洲精品在线观看| 欧美一区二区私人影院日本| 国产午夜精品理论片a级大结局| 国产精品久久免费看| 亚洲成人动漫av| 狠狠色伊人亚洲综合成人| 成人高清伦理免费影院在线观看| 欧美中文一区二区三区| 欧美电视剧在线观看完整版| 一区在线中文字幕| 日韩 欧美一区二区三区| 国产乱码精品一区二区三区忘忧草| 日本道精品一区二区三区| 91精品一区二区三区久久久久久 | 欧美另类一区二区三区| 久久久久国产一区二区三区四区 | 欧美欧美午夜aⅴ在线观看| 久久精品一区二区三区不卡| 亚洲免费电影在线| 极品销魂美女一区二区三区| 一道本成人在线| 国产日韩精品一区| 毛片av一区二区三区| 91精品1区2区| 国产女人aaa级久久久级| 日韩电影免费一区|