-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c369a02
commit 406980d
Showing
10 changed files
with
135 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,125 @@ | ||
package domain.Logic; | ||
|
||
|
||
import domain.Pieces.Piece; | ||
|
||
// | ||
|
||
public class Move { | ||
|
||
import domain.Pieces.*; | ||
|
||
/* | ||
* Container class for every type of move so far... should i include validation in here> and do castling, promotion checking here... | ||
* would be creating a lot of objs in memory that would be removed | ||
*/ | ||
public class Move { | ||
|
||
public enum MoveType{ | ||
STANDARD, | ||
CASTLE, | ||
EN_PASSANT, | ||
PAWN_CAPTURE, | ||
PROMOTION; | ||
} | ||
|
||
private Square start; | ||
private Square end; | ||
|
||
private Piece piecemoved; | ||
private Piece piecekilled; | ||
|
||
public Move(Square start, Square end, Piece piecemoved, Piece piecekilled) { | ||
private Piece pieceMoved; | ||
private Piece pieceKilled; | ||
|
||
private MoveType type; | ||
|
||
|
||
public Move(Square start, Square end) { | ||
this.start = start; | ||
this.end = end; | ||
} | ||
|
||
public Move(Square start, Square end, Piece pieceMoved, Piece pieceKilled){ | ||
this.start = start; | ||
this.end = end; | ||
this.pieceMoved = pieceMoved; | ||
this.pieceKilled = pieceKilled; | ||
move(0); | ||
} | ||
|
||
public Move(Square start, Square end, Pawn pPawn, Piece pieceKilled){ | ||
this.start = start; | ||
this.end = end; | ||
this.piecemoved = piecemoved; | ||
this.piecekilled = piecekilled; | ||
setPieces(); | ||
this.pieceMoved = pPawn; | ||
this.pieceKilled = pieceKilled; | ||
} | ||
|
||
public void move(int code) { | ||
if (code == 0) { | ||
setStandardMove(); | ||
} else if (code == 1) { | ||
setPawnCapture(); | ||
} else if (code == 2) { | ||
setCastling(); | ||
} else if (code == 3){ | ||
setEnPassant(); | ||
} else if (code == 4) { | ||
setPromotion(); | ||
} | ||
|
||
public Move(Square start, Square end, Piece piecemoved){ | ||
this(start,end,piecemoved,null); | ||
} | ||
|
||
//refactor | ||
public void move() { | ||
setPieces(); | ||
private void setStandardMove() { | ||
end.setPiece(this.pieceMoved); | ||
start.setPiece(null); | ||
} | ||
|
||
private void setPawnCapture(){ | ||
|
||
} | ||
|
||
private void setCastling(){ | ||
|
||
} | ||
|
||
private void setEnPassant(){ | ||
|
||
} | ||
|
||
private void setPieces(){ | ||
end.setPiece(piecemoved); | ||
start.setPiece(null); | ||
private void setPromotion(){ | ||
|
||
} | ||
|
||
public boolean isCapture(){ | ||
return piecekilled != null; | ||
public boolean isCapture() { | ||
return pieceKilled != null; | ||
} | ||
|
||
public Piece getPieceMoved() { | ||
return this.piecemoved; | ||
} | ||
return this.pieceMoved; | ||
} | ||
|
||
public Piece getPieceKilled(){ | ||
return this.piecekilled; | ||
public Piece getPieceKilled() { | ||
return this.pieceKilled; | ||
} | ||
|
||
public Pair getStartingPair(){ | ||
public Pair getStartingPair() { | ||
return getStartingSquare().getCoord(); | ||
} | ||
|
||
public Pair getEndingPair(){ | ||
public Pair getEndingPair() { | ||
return getEndingSquare().getCoord(); | ||
} | ||
public Square getStartingSquare(){ | ||
|
||
public Square getStartingSquare() { | ||
return this.start; | ||
} | ||
public Square getEndingSquare(){ | ||
|
||
public Square getEndingSquare() { | ||
return this.end; | ||
} | ||
|
||
@Override | ||
public String toString(){ | ||
if(piecekilled == null) | ||
return this.piecemoved.getColor()+" "+this.piecemoved.getReadablePiece() + ", " + this.getStartingPair() + " -> " + this.getEndingPair(); | ||
@Override | ||
public String toString() { | ||
if (pieceKilled == null) | ||
return this.pieceMoved.getColor() + " " + this.pieceMoved.getReadablePiece() + ", " + this.getStartingPair() | ||
+ " -> " + this.getEndingPair(); | ||
|
||
return this.piecemoved.getColor()+" "+this.piecemoved.getReadablePiece() + ", " + this.getStartingPair() + " -> " + this.getEndingPair() +", captures " +piecekilled.getColor() + " " + piecekilled.getReadablePiece(); | ||
return this.pieceMoved.getColor() + " " + this.pieceMoved.getReadablePiece() + ", " + this.getStartingPair() | ||
+ " -> " + this.getEndingPair() + ", captures " + pieceKilled.getColor() + " " | ||
+ pieceKilled.getReadablePiece(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.