This commit is contained in:
Cedric Beck
2024-12-10 14:29:02 +01:00
5 changed files with 48 additions and 3 deletions

View File

@@ -119,6 +119,10 @@ private void handleGame(Notification notification) {
guiHandler.addCardOwn(n.getBonusCard());
app.getAcousticHandler().playSound(MdgaSound.BONUS);
delay = STANDARD_DELAY;
} else if(notification instanceof RankingResponceNotification n) {
n.getRankingResults().forEach((c, i) -> {
guiHandler.rollRankingResult(c, i);
});
} else if (notification instanceof ActivePlayerNotification n) {
gameView.getGuiHandler().setActivePlayer(n.getColor());
boardHandler.hideDice();

View File

@@ -3,9 +3,14 @@
import pp.mdga.client.ClientGameLogic;
import pp.mdga.client.ClientState;
import pp.mdga.client.gamestate.DetermineStartPlayerState;
import pp.mdga.game.Color;
import pp.mdga.message.client.AnimationEndMessage;
import pp.mdga.message.server.*;
import pp.mdga.notification.ActivePlayerNotification;
import pp.mdga.notification.RankingResponceNotification;
import java.util.HashMap;
import java.util.Map;
public class WaitRankingState extends DetermineStartPlayerStates {
@@ -45,7 +50,11 @@ public void received(DiceNowMessage msg){
@Override
public void received(RankingResponseMessage msg){
Map<Color, Integer> rankingResults = new HashMap<>();
for (var entry : msg.getRankingResults().entrySet()) {
rankingResults.put(logic.getGame().getPlayerById(entry.getKey()).getColor(), entry.getValue());
}
logic.addNotification(new RankingResponceNotification(rankingResults));
}
@Override

View File

@@ -37,6 +37,8 @@ public void enter() {
ArrayList<UUID> ownPieces = new ArrayList<>(possibleOwnPieces.stream().map(Piece::getUuid).toList());
ArrayList<UUID> enemyPieces = new ArrayList<>(possibleEnemyPieces.stream().map(Piece::getUuid).toList());
logic.addNotification(new SelectableSwapNotification(ownPieces, enemyPieces));
possibleOwnPieces = null;
possibleEnemyPieces = null;
}
@Override
@@ -55,7 +57,7 @@ public void setPossibleEnemyPieces(ArrayList<Piece> possibleEnemyPieces) {
}
@Override
public void selectPiece(Piece piece) {
public void selectPiece(Piece piece){
if (possibleOwnPieces.contains(piece)){
selectedOwnPiece = piece;
} else if (possibleEnemyPieces.contains(piece)){

View File

@@ -88,7 +88,7 @@ public Game() {
initializeDrawPile();
board = new Board();
die = new Die(1,2,
1,1,6,1
1,1,6,1,6
);
}

View File

@@ -0,0 +1,30 @@
package pp.mdga.notification;
import pp.mdga.game.Color;
import pp.mdga.message.server.ServerMessage;
import java.util.HashMap;
import java.util.Map;
public class RankingResponceNotification extends Notification {
private final Map<Color, Integer> rankingResults;
/**
* Constructor.
*
* @param rankingResults as the results of all players after the start player was determined as a Map combining
* Integers and Integers.
*/
public RankingResponceNotification(Map<Color, Integer> rankingResults) {
super();
this.rankingResults = rankingResults;
}
/**
* This method will be used to return rankingResults attribute of RankingResponseMessage class.
*
* @return rankingResults as a Map combining Integers and Integers.
*/
public Map<Color, Integer> getRankingResults() {
return this.rankingResults;
}
}