This commit is contained in:
Benjamin Feyer
2024-12-10 14:06:25 +01:00
3 changed files with 44 additions and 1 deletions

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

@@ -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;
}
}