Moves are now intuitive.
Don't have to tell what piece to move and what piece to capture. Big code cleanup as well.
This commit is contained in:
@ -1,6 +1,10 @@
|
||||
package suicideChess;
|
||||
|
||||
import tests.TestMoves;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
import suicideChess.Move.NotAValidMoveException;
|
||||
import suicideChess.Square.NotAValidSquare;
|
||||
|
||||
/**
|
||||
* @author djib
|
||||
@ -24,13 +28,61 @@ public class SuicideChess {
|
||||
//does Square.class checks if the strings are valid (is "z9" a valid square ?
|
||||
public static final boolean SQUARE_CHECK_INVALID = true;
|
||||
|
||||
|
||||
public static final int MAIN_VERSION_NUMBER = 0;
|
||||
public static final int REVISION_NUMBER = 15;
|
||||
|
||||
/*****************
|
||||
* MAIN FUNCTION *
|
||||
*****************/
|
||||
public static void main(String[] args) {
|
||||
TestMoves.main(args);
|
||||
System.out.println("Welcome to SuicideChess v"+MAIN_VERSION_NUMBER+"."+REVISION_NUMBER+"!");
|
||||
BufferedReader moveInput = new BufferedReader(new InputStreamReader(System.in));
|
||||
|
||||
try {
|
||||
Board bitboard = new Board();
|
||||
bitboard.display();
|
||||
|
||||
/*int playerColor = Piece.WHITE;
|
||||
System.out.println("White: ");*/
|
||||
|
||||
while (true) {
|
||||
try {
|
||||
String whatMove= moveInput.readLine();
|
||||
|
||||
if (whatMove.startsWith("quit")) {
|
||||
System.out.println("Goodbye!");
|
||||
break;
|
||||
}
|
||||
|
||||
Move theMove = new Move(whatMove, bitboard);
|
||||
|
||||
theMove.display();
|
||||
bitboard.doMove(theMove);
|
||||
bitboard.display();
|
||||
|
||||
/*if (playerColor == Piece.WHITE) {
|
||||
playerColor = Piece.BLACK;
|
||||
System.out.println("Black: ");
|
||||
} else {
|
||||
playerColor = Piece.WHITE;
|
||||
System.out.println("White: ");
|
||||
}*/
|
||||
|
||||
|
||||
} catch (NotAValidMoveException err) {
|
||||
System.out.println(err);
|
||||
continue;
|
||||
} catch (NotAValidSquare err) {
|
||||
System.out.println(err);
|
||||
continue;
|
||||
} catch (Exception err) {
|
||||
System.out.println(err);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (NotAValidSquare e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user