Folge dem Video um zu sehen, wie unsere Website als Web-App auf dem Startbildschirm installiert werden kann.
Anmerkung: Diese Funktion ist in einigen Browsern möglicherweise nicht verfügbar.
private void checkForCheck() {
Address kingAddress = null;
Vector targetVector = new Vector();
for (int i=0; i<content.length; i++) {
for (int k=0; k<content[i].length; k++) {
AbstractChessPiece figur = content[i][k].getFigur();
if (figur!=null) {
if (figur instanceof King && figur.getTeam()!=this.turn)
kingAddress = content[i][k].getAddress();
if (figur.getTeam()==this.turn)
targetVector.addAll(this.collectPossibleTargets(content[i][k]));
}
}
}
for (int i=0; i<targetVector.size(); i++) {
//System.out.println(">>" + targetVector.get(i) + " : " + kingAddress);
if (((Address)targetVector.get(i)).equals(kingAddress)){
System.out.println(content[kingAddress.getRow()][kingAddress.getColumn()].getFigur().getName() + " ist im Schach!");
break;
}
}
}
public void takeStartPosition() {
movesCount = 0;
resetTargets();
rochade.clear();
enPassant.clear();
if (activeSquare!=null) {
activeSquare.setSelected(false);
activeSquare = null;
}
turn = WHITE;
content[0][0].occupyBy(new Rook(AbstractChessPiece.BLACK_TEAM));
content[0][1].occupyBy(new Knight(AbstractChessPiece.BLACK_TEAM));
content[0][2].occupyBy(new Bishop(AbstractChessPiece.BLACK_TEAM));
content[0][3].occupyBy(new Queen(AbstractChessPiece.BLACK_TEAM));
content[0][4].occupyBy(new King(AbstractChessPiece.BLACK_TEAM));
content[0][5].occupyBy(new Bishop(AbstractChessPiece.BLACK_TEAM));
content[0][6].occupyBy(new Knight(AbstractChessPiece.BLACK_TEAM));
content[0][7].occupyBy(new Rook(AbstractChessPiece.BLACK_TEAM));
content[7][0].occupyBy(new Rook(AbstractChessPiece.WHITE_TEAM));
content[7][1].occupyBy(new Knight(AbstractChessPiece.WHITE_TEAM));
content[7][2].occupyBy(new Bishop(AbstractChessPiece.WHITE_TEAM));
content[7][3].occupyBy(new Queen(AbstractChessPiece.WHITE_TEAM));
content[7][4].occupyBy(new King(AbstractChessPiece.WHITE_TEAM));
content[7][5].occupyBy(new Bishop(AbstractChessPiece.WHITE_TEAM));
content[7][6].occupyBy(new Knight(AbstractChessPiece.WHITE_TEAM));
content[7][7].occupyBy(new Rook(AbstractChessPiece.WHITE_TEAM));
for (int column=0; column<8; column++) {
content[1][column].occupyBy(new Pawn(AbstractChessPiece.BLACK_TEAM));
content[2][column].clear();
content[3][column].clear();
content[4][column].clear();
content[5][column].clear();
content[6][column].occupyBy(new Pawn(AbstractChessPiece.WHITE_TEAM));
}
}
private void checkForEnPassent(Address address) {
Square target;
Pawn opponentPawn;
if (address.isValid()) {
target = content[address.getRow()][address.getColumn()];
if (target.isOccupied()) {
if (target.getFigur() instanceof Pawn) {
opponentPawn = (Pawn)target.getFigur();
address.move(opponentPawn.getTeam()==AbstractChessPiece.WHITE_TEAM?1:-1,0);
if (opponentPawn.isEnPassantPossible(this.movesCount)
&& !content[address.getRow()][address.getColumn()].isOccupied()){
this.possibleTarget.add(address);
this.enPassant.add(address);
}
}
}
}
}