merge the new developmentbranch into the test branch #39
@@ -2,37 +2,45 @@
|
|||||||
|
|
||||||
import com.jme3.network.serializing.Serializable;
|
import com.jme3.network.serializing.Serializable;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A message sent by the server to all client to inform them about the current ranking. (only in DetermineStartPlayer)
|
* A message sent by the server to all client to inform them about the current ranking. (only in DetermineStartPlayer)
|
||||||
*/
|
*/
|
||||||
@Serializable
|
@Serializable
|
||||||
public class RankingResponseMessage extends ServerMessage {
|
public class RankingResponseMessage extends ServerMessage {
|
||||||
|
|
||||||
private final int startingPlayerId;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new RankingResponse instance.
|
* Create RankingResponseMessage attributes.
|
||||||
*/
|
*/
|
||||||
public RankingResponseMessage(int startingPlayerId) {
|
private final Map<Integer, Integer> rankingResults;
|
||||||
super();
|
|
||||||
this.startingPlayerId = startingPlayerId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new RankingResponse instance.
|
* Constructor.
|
||||||
*/
|
*/
|
||||||
public RankingResponseMessage() {
|
public RankingResponseMessage() {
|
||||||
super();
|
super();
|
||||||
this.startingPlayerId = 0;
|
this.rankingResults = new HashMap<Integer, Integer>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The id of the starting Player.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @return the id of the starting player as an int
|
* @param rankingResults as the results of all players after the start player was determined as a Map combining
|
||||||
|
* Integers and Integers.
|
||||||
*/
|
*/
|
||||||
public int getStartingPlayerId() {
|
public RankingResponseMessage(Map<Integer, Integer> rankingResults) {
|
||||||
return startingPlayerId;
|
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<Integer, Integer> getRankingResults() {
|
||||||
|
return this.rankingResults;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -52,6 +60,14 @@ public void accept(ServerInterpreter interpreter) {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "RankingResponseMessage{" + "startingPlayerId=" + startingPlayerId + '}';
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
stringBuilder.append("RankingResponseMessage{");
|
||||||
|
for (Map.Entry<Integer, Integer> entry : this.rankingResults.entrySet()) {
|
||||||
|
stringBuilder.append("Player with ID: ").append(entry.getKey()).append(" rolled: ").append(entry.getValue()).append(", ");
|
||||||
|
}
|
||||||
|
stringBuilder.deleteCharAt(stringBuilder.length() - 1);
|
||||||
|
stringBuilder.deleteCharAt(stringBuilder.length() - 1);
|
||||||
|
stringBuilder.append("}");
|
||||||
|
return stringBuilder.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user