mirror of
https://github.com/lov3b/Schack.git
synced 2025-01-18 21:00:11 +01:00
undvika att kopiera points
This commit is contained in:
parent
40f67ca725
commit
ab6f9980e5
@ -154,19 +154,19 @@ public abstract class Piece {
|
|||||||
Point previousPosition = new Point(this.position);
|
Point previousPosition = new Point(this.position);
|
||||||
|
|
||||||
// Kom ihåg motståndarpjäs
|
// Kom ihåg motståndarpjäs
|
||||||
Piece opponentPiece = pieces[pos.x][pos.y];
|
Piece guyThatsAlreadyHere = pieces[pos.x][pos.y];
|
||||||
|
|
||||||
// Testa att flytta
|
// Testa att flytta
|
||||||
pieces[pos.x][pos.y] = this;
|
pieces[pos.x][pos.y] = this;
|
||||||
pieces[previousPosition.x][previousPosition.y] = null;
|
pieces[previousPosition.x][previousPosition.y] = null;
|
||||||
this.position = new Point(pos);
|
this.position = pos;
|
||||||
|
|
||||||
boolean inSchack = isInSchack(pieces);
|
boolean inSchack = isInSchack(pieces);
|
||||||
|
|
||||||
// Flytta tillbaka
|
// Flytta tillbaka
|
||||||
pieces[previousPosition.x][previousPosition.y] = this;
|
pieces[previousPosition.x][previousPosition.y] = this;
|
||||||
pieces[pos.x][pos.y] = opponentPiece;
|
pieces[pos.x][pos.y] = guyThatsAlreadyHere;
|
||||||
this.position = new Point(previousPosition);
|
this.position = previousPosition;
|
||||||
|
|
||||||
return inSchack;
|
return inSchack;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user