我真的很抱歉让我烦恼,但我对此感到有些恐慌和压力。请不要仇恨,因为这篇文章可以被视为“请帮助调试”的帖子,但我很绝望。我不明白我做错了什么,我花了很长时间试图弄清楚。它运行但只是不断给出非法移动消息。我真的很感激对此的任何见解。
游戏...
public class Game {
private static String WHITEPLAYS_MSG = "White plays. Enter move:";
private static String BLACKPLAYS_MSG = "Black plays. Enter move:";
private static String ILLEGALMOVE_MSG = "Illegal move!";
private static String WHITEWINS_MSG = "White wins!";
private static String BLACKWINS_MSG = "Black wins!";
private Board gameBoard;
// Minimal constructor. Expand as needed (kt54)
public Game() {
gameBoard = new Board();
}
// Build on this method to implement game logic.
public void play() {
Player player1 = new Player("white"); //player one plays white
Player player2 = new Player("black"); //player two plays black
Piece piece1 = new Piece();
Piece piece2 = new Piece();
EasyIn2 reader = new EasyIn2();
gameBoard = new Board(); //initializes the board so dont need to do so in main
boolean done = false; //2 while loops within large while loop?
while (!done) { //keeps looping when no one has won yet
gameBoard.printBoard();
System.out.println(WHITEPLAYS_MSG);
String Player1Pos1 = reader.getString(); //gets user input ... move from... to.... temporary variables
int x1From = Player1Pos1.charAt(0) - 'a'; //to transform the letter ASCII values
int y1From = 8 - (Player1Pos1.charAt(1) - '1') - 1; // to transform the number
String Player1Pos2 = reader.getString();
int x1To = Player1Pos2.charAt(0) - 'a'; //to transform the letter
int y1To = 8 - (Player1Pos2.charAt(1) - '1') - 1; // to transform the number
胡子哥哥
小唯快跑啊
相关分类