merge the new developmentbranch into the test branch #39
@@ -68,19 +68,28 @@ public void received(ActivePlayerMessage msg) {
|
||||
@Override
|
||||
public void received(MoveMessage msg) {
|
||||
Piece piece = logic.getGame().getPieceThroughUUID(msg.getPiece().getUuid());
|
||||
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant();
|
||||
//logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant();
|
||||
if (msg.isHomeMove()) {
|
||||
logic.addNotification(new HomeMoveNotification(piece.getUuid(), msg.getTargetIndex()));
|
||||
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant();
|
||||
logic.getGame().getPlayerByColor(piece.getColor()).setPieceInHome(msg.getTargetIndex(), piece);
|
||||
} else {
|
||||
int i = logic.getGame().getBoard().getInfieldIndexOfPiece(piece);
|
||||
this.LOGGER.log(System.Logger.Level.INFO, "Received MoveMessage with start index: " + i);
|
||||
logic.addNotification(new MovePieceNotification(msg.getPiece().getUuid(), logic.getGame().getBoard().getInfieldIndexOfPiece(piece), msg.getTargetIndex()));
|
||||
Piece occ = logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].moveOccupant(piece);
|
||||
if (occ != null){
|
||||
logic.getGame().getPlayerByColor(occ.getColor()).addWaitingPiece(occ);
|
||||
int oldIndex = logic.getGame().getBoard().getInfieldIndexOfPiece(piece);
|
||||
|
||||
Piece occ = logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant();
|
||||
//logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].moveOccupant(piece);
|
||||
if (occ != null) {
|
||||
//TODO: MoveThrowNotification
|
||||
logic.addNotification(new ThrowPieceNotification(occ.getUuid(), piece.getColor()));
|
||||
//set occ to waiting
|
||||
logic.getGame().getPlayerByColor(occ.getColor()).addWaitingPiece(occ);
|
||||
}
|
||||
logic.addNotification(new MovePieceNotification(msg.getPiece().getUuid(), oldIndex, msg.getTargetIndex()));
|
||||
|
||||
//clear old node
|
||||
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant();
|
||||
//set new node
|
||||
logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(piece);
|
||||
}
|
||||
parent.setState(parent.getAnimation());
|
||||
}
|
||||
|
||||
@@ -78,6 +78,7 @@ private StartNode createStartNode(int i) {
|
||||
* @return the index of the piece
|
||||
*/
|
||||
public int getInfieldIndexOfPiece(Piece piece) {
|
||||
System.out.println("Get uuid of: "+ piece.getUuid());
|
||||
for (int i = 0; i < infield.length; i++) {
|
||||
System.out.println(infield[i].getOccupant());
|
||||
if(infield[i].isOccupied()) {
|
||||
|
||||
Reference in New Issue
Block a user