fixed bugs in MoveMessage
This commit is contained in:
@@ -61,6 +61,8 @@ public void update() {
|
|||||||
case NONE:
|
case NONE:
|
||||||
throw new RuntimeException("no notification expected: " + n.getClass().getName());
|
throw new RuntimeException("no notification expected: " + n.getClass().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delay = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,8 @@ protected void controlUpdate(float tpf) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Stop rolling when angular velocity is close to zero
|
// Stop rolling when angular velocity is close to zero
|
||||||
if (angularVelocity.lengthSquared() < 3f) {
|
// if (angularVelocity.lengthSquared() < 3f) {
|
||||||
|
if(true){
|
||||||
slerp = true;
|
slerp = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -65,7 +66,8 @@ protected void controlUpdate(float tpf) {
|
|||||||
spatial.setLocalRotation(interpolated);
|
spatial.setLocalRotation(interpolated);
|
||||||
|
|
||||||
// Stop rolling once duration is complete
|
// Stop rolling once duration is complete
|
||||||
if (timeElapsed >= 1.0f) {
|
// if (timeElapsed >= 1.0f) {
|
||||||
|
if(true){
|
||||||
isRolling = false;
|
isRolling = false;
|
||||||
slerp = false;
|
slerp = false;
|
||||||
actionAfter.run();
|
actionAfter.run();
|
||||||
|
|||||||
@@ -152,7 +152,6 @@ public void received(RankingResponseMessage msg){
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(SelectPieceMessage msg){
|
public void received(SelectPieceMessage msg){
|
||||||
System.out.println("SelectPieceMessage received in GameState");
|
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -70,7 +70,6 @@ public void selectAnimationEnd(){
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(SelectPieceMessage msg){
|
public void received(SelectPieceMessage msg){
|
||||||
System.out.println("SelectPieceMessage received in TurnState");
|
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,6 @@ public void selectPiece(Piece piece){
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(SelectPieceMessage msg){
|
public void received(SelectPieceMessage msg){
|
||||||
System.out.println("SelectPieceMessage received in ChoosePieceState");
|
|
||||||
currentState.received(msg);
|
currentState.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,12 +26,11 @@ public SelectPieceState(ClientState parent, ClientGameLogic logic) {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enter() {
|
public void enter() {
|
||||||
possiblePieces = new ArrayList<>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void exit() {
|
public void exit() {
|
||||||
|
possiblePieces = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPossiblePieces(ArrayList<Piece> possiblePieces) {
|
public void setPossiblePieces(ArrayList<Piece> possiblePieces) {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
import pp.mdga.client.ClientGameLogic;
|
import pp.mdga.client.ClientGameLogic;
|
||||||
import pp.mdga.client.ClientState;
|
import pp.mdga.client.ClientState;
|
||||||
import pp.mdga.client.gamestate.turnstate.ChoosePieceState;
|
import pp.mdga.client.gamestate.turnstate.ChoosePieceState;
|
||||||
|
import pp.mdga.game.Node;
|
||||||
import pp.mdga.game.Piece;
|
import pp.mdga.game.Piece;
|
||||||
import pp.mdga.message.client.RequestMoveMessage;
|
import pp.mdga.message.client.RequestMoveMessage;
|
||||||
import pp.mdga.message.client.SelectedPiecesMessage;
|
import pp.mdga.message.client.SelectedPiecesMessage;
|
||||||
@@ -49,17 +50,21 @@ public void selectPiece(Piece piece){
|
|||||||
@Override
|
@Override
|
||||||
public void received(MoveMessage msg){
|
public void received(MoveMessage msg){
|
||||||
Piece piece = logic.getGame().getPieceThroughUUID(msg.getPiece().getUuid());
|
Piece piece = logic.getGame().getPieceThroughUUID(msg.getPiece().getUuid());
|
||||||
int i = logic.getGame().getBoard().getInfieldIndexOfPiece(piece);
|
int oldIndex = logic.getGame().getBoard().getInfieldIndexOfPiece(piece);
|
||||||
LOGGER.log(System.Logger.Level.INFO, "Received MoveMessage with start index: " + i);
|
int targetIndex = msg.getTargetIndex();
|
||||||
|
Node targetNode = logic.getGame().getBoard().getInfield()[targetIndex];
|
||||||
|
//clear old Node
|
||||||
|
logic.getGame().getBoard().getInfield()[oldIndex].clearOccupant();
|
||||||
|
|
||||||
Piece occ = logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant();
|
//get Occupant
|
||||||
|
Piece occ = targetNode.getOccupant();
|
||||||
if (occ != null){
|
if (occ != null){
|
||||||
logic.getGame().getPlayerByColor(occ.getColor()).addWaitingPiece(occ);
|
logic.getGame().getPlayerByColor(occ.getColor()).addWaitingPiece(occ);
|
||||||
logic.addNotification(new ThrowPieceNotification(occ.getUuid(), piece.getColor()));
|
logic.addNotification(new ThrowPieceNotification(occ.getUuid(), piece.getColor()));
|
||||||
}
|
}
|
||||||
|
|
||||||
logic.addNotification(new MovePieceNotification(msg.getPiece().getUuid(), i, msg.getTargetIndex()));
|
targetNode.setOccupant(msg.getPiece());
|
||||||
logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(msg.getPiece());
|
logic.addNotification(new MovePieceNotification(msg.getPiece().getUuid(), oldIndex, targetIndex));
|
||||||
|
|
||||||
parent.getParent().setState(parent.getParent().getMovePiece());
|
parent.getParent().setState(parent.getParent().getMovePiece());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,28 +63,33 @@ public void received(RequestMoveMessage msg, int from){
|
|||||||
}
|
}
|
||||||
|
|
||||||
int indexOfPiece = moveablePieces.indexOf(msg.getPiece());
|
int indexOfPiece = moveablePieces.indexOf(msg.getPiece());
|
||||||
logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(moveablePieces.get(indexOfPiece))].clearOccupant();
|
Piece movePiece = moveablePieces.get(indexOfPiece);
|
||||||
if (isHomeMove.get(indexOfPiece)) {
|
boolean homeMove = isHomeMove.get(indexOfPiece);
|
||||||
logic.getGame().getPlayerByColor(msg.getPiece().getColor()).setPieceInHome(targetIndex.get(indexOfPiece), logic.getGame().getPieceThroughUUID(msg.getPiece().getUuid()));
|
int targIdx = targetIndex.get(indexOfPiece);
|
||||||
|
|
||||||
|
Node oldNode = logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(movePiece)];
|
||||||
|
oldNode.clearOccupant();
|
||||||
|
if (homeMove) {
|
||||||
|
//setPieceInHome
|
||||||
|
logic.getGame().getPlayerByColor(msg.getPiece().getColor()).setPieceInHome(targIdx, movePiece);
|
||||||
|
|
||||||
if (logic.getGame().getPlayerByColor(msg.getPiece().getColor()).isHomeFinished(logic.getGame().getPieceThroughUUID(msg.getPiece().getUuid()))) {
|
if (logic.getGame().getPlayerByColor(msg.getPiece().getColor()).isHomeFinished(logic.getGame().getPieceThroughUUID(msg.getPiece().getUuid()))) {
|
||||||
logic.getGame().getPieceThroughUUID(msg.getPiece().getUuid()).setState(PieceState.HOMEFINISHED);
|
movePiece.setState(PieceState.HOMEFINISHED);
|
||||||
} else {
|
|
||||||
logic.getGame().getPieceThroughUUID(msg.getPiece().getUuid()).setState(PieceState.HOME);
|
|
||||||
}
|
}
|
||||||
logic.getGame().getPieceThroughUUID(msg.getPiece().getUuid()).setShield(ShieldState.NONE);
|
else {
|
||||||
|
movePiece.setState(PieceState.HOME);
|
||||||
|
}
|
||||||
|
movePiece.setShield(ShieldState.NONE);
|
||||||
} else {
|
} else {
|
||||||
Node targetNode = logic.getGame().getBoard().getInfield()[targetIndex.get(indexOfPiece)];
|
Node targetNode = logic.getGame().getBoard().getInfield()[targIdx];
|
||||||
Piece occ = targetNode.getOccupant();
|
Piece occ = targetNode.getOccupant();
|
||||||
// Piece occ = logic.getGame().getBoard().getInfield()[targetIndex.get(indexOfPiece)].moveOccupant(moveablePieces.get(indexOfPiece));
|
|
||||||
if (occ != null) {
|
if (occ != null) {
|
||||||
logic.getGame().getPlayerByColor(occ.getColor()).addWaitingPiece(occ);
|
logic.getGame().getPlayerByColor(occ.getColor()).addWaitingPiece(occ);
|
||||||
}
|
}
|
||||||
|
|
||||||
targetNode.setOccupant(msg.getPiece());
|
targetNode.setOccupant(msg.getPiece());
|
||||||
}
|
}
|
||||||
logic.getServerSender().broadcast(new MoveMessage(moveablePieces.get(indexOfPiece), isHomeMove.get(indexOfPiece), targetIndex.get(indexOfPiece)));
|
logic.getServerSender().broadcast(new MoveMessage(movePiece, homeMove, targIdx));
|
||||||
this.choosePieceAutomaton.getTurnAutomaton().setCurrentState(this.choosePieceAutomaton.getTurnAutomaton().getMovePieceState());
|
this.choosePieceAutomaton.getTurnAutomaton().setCurrentState(this.choosePieceAutomaton.getTurnAutomaton().getMovePieceState());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user