Skip to content

Commit

Permalink
cleaned up
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexWang18 committed Dec 21, 2020
1 parent 25f40b6 commit bb1373e
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 12 deletions.
2 changes: 2 additions & 0 deletions src/main/java/domain/Logic/Errors.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,10 @@ public static void pathIsBlocked(Message m){
Piece startPiece = m.startPiece;
Piece blockingPiece = m.blockPiece;
Pair atHere = m.whereXY;

StringBuilder sb = new StringBuilder(startPiece.getReadablePiece() + " cannot hop over the "
+ blockingPiece.getReadablePiece() + " at " + atHere);

System.out.println(sb.toString());
}

Expand Down
16 changes: 5 additions & 11 deletions src/main/java/domain/Logic/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private Game() {
current = 0;
}

public static Game getGame() { // Implementation of Singleton Pattern, Only one game will occur at a time
public static Game getGame() { // Implementation of Singleton Pattern, Only one game will occur at a time
return g;
}

Expand Down Expand Up @@ -81,8 +81,7 @@ public boolean tryMove(int startx, int starty, int endx, int endy) throws IOExce
return false;
}

// Special case for pawns, method handles enpasssant, promotion and regular
// moves
// Special case for pawns, method handles enpasssant, promotion and regular moves
if (isPawn(startPiece)) {
return checkPawnMove(start, end, startPiece, killedPiece);
}
Expand Down Expand Up @@ -113,22 +112,17 @@ private boolean checkPawnMove(Square start, Square end, Piece pawn, Piece killed
}
Pawn pPawn = (Pawn) pawn;

if (isValidPromotion(pPawn, start, end)) { //not funct properly
if (isValidPromotion(pPawn, start, end)) {
/*
// how do i get the users response after reaching end of board, should i have a
// two way relationship b/tw UI and Game or keep it has a unidirectional
*/
executeMove(start, end, pawn, killedPiece);
return promote(pawn.getColor(), end, start.getCoord());
}
// maybe put valid pawn capture here if keep getting issues in Pawn valid or nah
// method


boolean test = pPawn.validOrNah(start.getCoord(), end.getCoord(), killedPiece)
&& checkPiecesPath(pawn.getPiecePath(start.getCoord(), end.getCoord()), start.getCoord(),
&& checkPiecesPath(pawn.getPiecePath(start.getCoord(), end.getCoord()), start.getCoord(),
end.getCoord()).value;

if (test) {
Expand All @@ -143,7 +137,7 @@ && checkPiecesPath(pawn.getPiecePath(start.getCoord(), end.getCoord()), start.ge

private boolean promote(ColorType color, Square end, Pair readableXY) throws IOException {

String pChoice = UI.parsePieceChoice(readableXY.toString()); //idk abt this static method and this implementation in general
String pChoice = UI.parsePieceChoice(readableXY.toString()); //idk abt this static method association and this implementation in general

//B B. B..... b bishop matches

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/domain/Logic/Move.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public Move(Square start, Square end, Piece piecemoved, Piece piecekilled) {
this.end = end;
this.piecemoved = piecemoved;
this.piecekilled = piecekilled;
move();
setPieces();
}

public Move(Square start, Square end, Piece piecemoved){
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/domain/UserInterface/UI.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,10 @@ public void getMoves() throws IOException {
game.printBoard();
}
}

game.getMoves();
gameIsOver();

}

//If they reach end of the board prompt them with choice
Expand Down
Binary file modified target/classes/domain/Logic/Errors.class
Binary file not shown.
Binary file modified target/classes/domain/Logic/Game$1.class
Binary file not shown.
Binary file modified target/classes/domain/Logic/Game$Tuple2.class
Binary file not shown.
Binary file modified target/classes/domain/Logic/Game.class
Binary file not shown.
Binary file modified target/classes/domain/Logic/Move.class
Binary file not shown.
Binary file modified target/classes/domain/UserInterface/UI.class
Binary file not shown.

0 comments on commit bb1373e

Please sign in to comment.