dev #12
@@ -104,7 +104,7 @@ public class DDDView extends GameAdaptator {
|
||||
@Override
|
||||
public void onMove(Move move) {
|
||||
// update world internal positions
|
||||
this.world.movePiece(this.world.getPiece(move.getStart()), move.getFinish());
|
||||
this.world.movePiece(this.world.getPiece(move.getStart()), move);
|
||||
}
|
||||
|
||||
public void run() {
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import chess.model.Coordinate;
|
||||
import chess.model.Move;
|
||||
import chess.model.Piece;
|
||||
|
||||
public class World {
|
||||
@@ -30,11 +31,16 @@ public class World {
|
||||
|
||||
public void addPiece(PieceEntity entity, Coordinate coordinate) {
|
||||
addEntity(entity);
|
||||
movePiece(entity, coordinate);
|
||||
setPieceCoords(entity, coordinate);
|
||||
}
|
||||
|
||||
private void setPieceCoords(PieceEntity entity, Coordinate coordinate) {
|
||||
pieces[coordinate.toIndex()] = entity;
|
||||
}
|
||||
|
||||
public void movePiece(PieceEntity entity, Coordinate coordinate) {
|
||||
pieces[coordinate.toIndex()] = entity;
|
||||
public void movePiece(PieceEntity entity, Move move) {
|
||||
setPieceCoords(entity, move.getFinish());
|
||||
setPieceCoords(null, move.getStart());
|
||||
}
|
||||
|
||||
public PieceEntity getPiece(Coordinate coordinate) {
|
||||
|
||||
Reference in New Issue
Block a user