Merge branch 'development2' of https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-01 into development2
This commit is contained in:
		@@ -12,7 +12,8 @@ public ActionControl(Runnable runnable){
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    protected void action(){
 | 
			
		||||
        if(runnable == null) throw new RuntimeException("runnable is null");
 | 
			
		||||
        else runnable.run();
 | 
			
		||||
        if(null != runnable) {
 | 
			
		||||
            runnable.run();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -831,7 +831,7 @@ private void throwBomb(UUID uuid) {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void throwMatrix(UUID uuid) {
 | 
			
		||||
        //app.getAcousticHandler().playSound(MdgaSound.MATRIX);
 | 
			
		||||
        app.getAcousticHandler().playSound(MdgaSound.MATRIX);
 | 
			
		||||
        Spatial piece = pieces.get(uuid).getSpatial();
 | 
			
		||||
        piece.addControl(new MatrixAnimation(app, radarPos,()-> {
 | 
			
		||||
            piece.addControl(new FadeControl(1,1,0,
 | 
			
		||||
 
 | 
			
		||||
@@ -4,11 +4,9 @@
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
import pp.mdga.client.GameState;
 | 
			
		||||
import pp.mdga.game.Piece;
 | 
			
		||||
import pp.mdga.game.PieceState;
 | 
			
		||||
import pp.mdga.message.server.*;
 | 
			
		||||
import pp.mdga.notification.ActivePlayerNotification;
 | 
			
		||||
import pp.mdga.notification.HomeMoveNotification;
 | 
			
		||||
import pp.mdga.notification.MovePieceNotification;
 | 
			
		||||
import pp.mdga.notification.PlayCardNotification;
 | 
			
		||||
import pp.mdga.notification.*;
 | 
			
		||||
 | 
			
		||||
public class SpectatorState extends GameStates {
 | 
			
		||||
 | 
			
		||||
@@ -62,24 +60,32 @@ public void received(ActivePlayerMessage msg) {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(MoveMessage msg) {
 | 
			
		||||
        Piece pieceToMove = logic.getGame().getPieceThroughUUID(msg.getPiece().getUuid());
 | 
			
		||||
        Piece piece = logic.getGame().getPieceThroughUUID(msg.getPiece().getUuid());
 | 
			
		||||
        if (msg.isHomeMove()) {
 | 
			
		||||
            logic.addNotification(new HomeMoveNotification(pieceToMove.getUuid(), msg.getTargetIndex()));
 | 
			
		||||
            logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)].clearOccupant();
 | 
			
		||||
            logic.getGame().getPlayerByColor(pieceToMove.getColor()).setPieceInHome(msg.getTargetIndex(), pieceToMove);
 | 
			
		||||
            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 {
 | 
			
		||||
            if (logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].isOccupied()) {
 | 
			
		||||
                throwPiece(logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant());
 | 
			
		||||
                logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increasePiecesThrown();
 | 
			
		||||
                logic.getGame().getGameStatistics().increasePiecesThrown();
 | 
			
		||||
            int oldIndex = logic.getGame().getBoard().getInfieldIndexOfPiece(piece);
 | 
			
		||||
 | 
			
		||||
            Piece occ = logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant();
 | 
			
		||||
            if (occ != null) {
 | 
			
		||||
                //TODO: MoveThrowNotification
 | 
			
		||||
                logic.addNotification(new ThrowPieceNotification(occ.getUuid(), piece.getColor()));
 | 
			
		||||
                //set occ to waiting
 | 
			
		||||
                logic.getGame().getPlayerByColor(occ.getColor()).addWaitingPiece(occ);
 | 
			
		||||
            }
 | 
			
		||||
            if (logic.getGame().getPlayerByColor(pieceToMove.getColor()).getStartNodeIndex() == logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)) {
 | 
			
		||||
                logic.addNotification(new MovePieceNotification(pieceToMove.getUuid(), msg.getTargetIndex(), true));
 | 
			
		||||
                logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(pieceToMove);
 | 
			
		||||
            if(msg.getPiece().getState().equals(PieceState.WAITING)){
 | 
			
		||||
                logic.addNotification(new MovePieceNotification(piece.getUuid(), msg.getTargetIndex(), true));
 | 
			
		||||
                logic.getGame().getPlayerByColor(piece.getColor()).removeWaitingPiece(piece);
 | 
			
		||||
                piece.setState(PieceState.ACTIVE);
 | 
			
		||||
            } else {
 | 
			
		||||
                logic.addNotification(new MovePieceNotification(pieceToMove.getUuid(), logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove), msg.getTargetIndex()));
 | 
			
		||||
                logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(pieceToMove);
 | 
			
		||||
                logic.addNotification(new MovePieceNotification(piece.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());
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -70,25 +70,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();
 | 
			
		||||
        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 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();
 | 
			
		||||
            if(oldIndex == -1){
 | 
			
		||||
                logic.addNotification(new MovePieceNotification(piece.getUuid(), msg.getTargetIndex(), true));
 | 
			
		||||
                logic.getGame().getPlayerByColor(piece.getColor()).removeWaitingPiece(piece);
 | 
			
		||||
                piece.setState(PieceState.ACTIVE);
 | 
			
		||||
            } else {
 | 
			
		||||
                logic.addNotification(new MovePieceNotification(piece.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);
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -27,7 +27,6 @@ public WaitingPieceState(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
    @Override
 | 
			
		||||
    public void enter() {
 | 
			
		||||
        moveablePiece = null;
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
 
 | 
			
		||||
@@ -85,7 +85,7 @@ public Game() {
 | 
			
		||||
        gameStatistics = new Statistic();
 | 
			
		||||
        initializeDrawPile();
 | 
			
		||||
        board = new Board();
 | 
			
		||||
        die = new Die(2,1,2,2,1,3);
 | 
			
		||||
        die = new Die(2,5,6,3,6);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -178,7 +178,7 @@ public boolean hasPieceInWaitingArea(){
 | 
			
		||||
 | 
			
		||||
    public int getHomeIndexOfPiece(Piece piece) {
 | 
			
		||||
        for (int i = 0; i < Resources.MAX_PIECES; i++) {
 | 
			
		||||
            if (this.homeNodes[i].getOccupant().equals(piece)) {
 | 
			
		||||
            if (piece.equals(this.homeNodes[i].getOccupant())) {
 | 
			
		||||
                return i;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
@@ -348,4 +348,13 @@ public void setPieceInHome(int index, Piece piece) {
 | 
			
		||||
    public String toString() {
 | 
			
		||||
        return "Player: " + name + " Color: " + color;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void removeWaitingPiece(Piece piece) {
 | 
			
		||||
        for (int i = 0; i < Resources.MAX_PIECES; i++) {
 | 
			
		||||
            if (piece.equals(this.waitingArea[i])) {
 | 
			
		||||
                this.waitingArea[i] = null;
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -40,6 +40,7 @@ public void enter() {
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(RequestMoveMessage msg, int from){
 | 
			
		||||
        if (msg.getPiece().equals(this.piece)) {
 | 
			
		||||
            logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).removeWaitingPiece(this.piece);
 | 
			
		||||
            piece.setState(PieceState.ACTIVE);
 | 
			
		||||
            Piece thrownOcc = logic.getGame().getBoard().getInfield()[logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getStartNodeIndex()].getOccupant();
 | 
			
		||||
            if (thrownOcc != null) {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,11 @@
 | 
			
		||||
lobby.deny.join=The lobby is already full.
 | 
			
		||||
server.shutdown=The server has shut down.
 | 
			
		||||
 | 
			
		||||
incorrect.request.0=The selected TSK is already occupied.
 | 
			
		||||
incorrect.request.1=No TSK is available for selection.
 | 
			
		||||
incorrect.request.2=Test
 | 
			
		||||
incorrect.request.3=Test
 | 
			
		||||
incorrect.request.4=Test
 | 
			
		||||
incorrect.request.5=Test
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,8 @@
 | 
			
		||||
lobby.deny.join=Die Lobby ist bereits voll.
 | 
			
		||||
server.shutdown=Der Server wurde heruntergefahren.
 | 
			
		||||
 | 
			
		||||
incorrect.request.1=Die ausgewählte TSK ist bereits belegt.
 | 
			
		||||
incorrect.request.2=Es gibt keine freie TSK mehr, welche ausgewählt werden kann.
 | 
			
		||||
incorrect.request.0=Die ausgewählte TSK ist bereits belegt.
 | 
			
		||||
incorrect.request.1=Es gibt keine freie TSK mehr, welche ausgewählt werden kann.
 | 
			
		||||
incorrect.request.2=Test
 | 
			
		||||
incorrect.request.3=Test
 | 
			
		||||
incorrect.request.4=Test
 | 
			
		||||
incorrect.request.5=Test
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user