200 iq move
This commit is contained in:
@@ -83,7 +83,7 @@ public List<Integer> getTargetIndex() {
|
||||
*/
|
||||
@Override
|
||||
public void accept(ServerInterpreter interpreter) {
|
||||
|
||||
interpreter.received(this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package pp.mdga.server.automaton.game.turn.choosepiece;
|
||||
|
||||
import pp.mdga.game.Node;
|
||||
import pp.mdga.game.Piece;
|
||||
import pp.mdga.message.client.RequestMoveMessage;
|
||||
import pp.mdga.message.server.MoveMessage;
|
||||
@@ -39,14 +40,21 @@ public void enter() {
|
||||
public void received(RequestMoveMessage msg, int from){
|
||||
LOGGER.log(System.Logger.Level.INFO, "Received RequestMoveMessage message. is piece equals: " + piece.equals(msg.getPiece()));
|
||||
if (piece.equals(msg.getPiece())) {
|
||||
int targetIndex = calculateTargetIndex(piece);
|
||||
Node targetNode = logic.getGame().getBoard().getInfield()[targetIndex];
|
||||
//send MoveMessage
|
||||
logic.getServerSender().broadcast(new MoveMessage(piece, false, targetIndex));
|
||||
|
||||
logic.getServerSender().broadcast(new MoveMessage(piece, false, calculateTargetIndex(piece)));
|
||||
//clear old piece from node
|
||||
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant();
|
||||
Piece occ = logic.getGame().getBoard().getInfield()[calculateTargetIndex(piece)].getOccupant();
|
||||
|
||||
Piece occ = targetNode.getOccupant();
|
||||
if (occ != null){
|
||||
//move occ to waiting
|
||||
logic.getGame().getPlayerByColor(occ.getColor()).addWaitingPiece(occ);
|
||||
}
|
||||
logic.getGame().getBoard().getInfield()[calculateTargetIndex(piece)].setOccupant(piece);
|
||||
//move piece to targetNode
|
||||
targetNode.setOccupant(piece);
|
||||
|
||||
this.choosePieceAutomaton.getTurnAutomaton().setCurrentState(this.choosePieceAutomaton.getTurnAutomaton().getMovePieceState());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user