You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
1.5 KiB
77 lines
1.5 KiB
package Game.ChessObj;
|
|
|
|
public class ChessFigure {
|
|
|
|
public enum Type {
|
|
KING,
|
|
QUEEN,
|
|
CASTLE,
|
|
BISHOP,
|
|
KNIGHT,
|
|
PAWN
|
|
}
|
|
|
|
public enum Team {
|
|
WHITE,
|
|
BLACK
|
|
}
|
|
|
|
private final Type type;
|
|
private final Team team;
|
|
|
|
public ChessFigure(Type type, Team team) {
|
|
this.type = type;
|
|
this.team = team;
|
|
}
|
|
|
|
public Type getType() {
|
|
return this.type;
|
|
}
|
|
|
|
public Team getTeam() {
|
|
return this.team;
|
|
}
|
|
|
|
public String getSymbol() {
|
|
String symbol = "";
|
|
switch (getType()) {
|
|
case KING:
|
|
symbol = "K";
|
|
break;
|
|
case QUEEN:
|
|
symbol = "Q";
|
|
break;
|
|
case CASTLE:
|
|
symbol = "T";
|
|
break;
|
|
case BISHOP:
|
|
symbol = "I";
|
|
break;
|
|
case KNIGHT:
|
|
symbol = "Z";
|
|
break;
|
|
case PAWN:
|
|
symbol = "o";
|
|
break;
|
|
default:
|
|
}
|
|
|
|
symbol = ((this.getTeam() == Team.WHITE) ? " " : "|") + symbol + ((this.getTeam() == Team.WHITE) ? " " : "|");
|
|
|
|
return symbol;
|
|
}
|
|
|
|
@Override
|
|
public boolean equals(Object o) {
|
|
if (!(o instanceof ChessFigure)) {
|
|
return false;
|
|
}
|
|
|
|
ChessFigure x = (ChessFigure) o;
|
|
if (this.getType() != x.getType() || this.getTeam() != x.getTeam())
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
}
|