Skip to content

Commit ccf7410

Browse files
committed
fix(sdk): turn GameResult into data class
Previously it didn't have an equals method, making proper testing almost impossible. Also removes isRegular from the XML. # Conflicts: # server/src/sc/server/Lobby.kt # server/src/sc/server/network/ClientManager.java # server/src/sc/server/network/NewClientListener.java
1 parent 85a5487 commit ccf7410

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

socha-sdk/src/framework/sc/shared/GameResult.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@ import sc.framework.plugins.Player
66
import sc.protocol.responses.ProtocolMessage
77

88
@XStreamAlias(value = "result")
9-
class GameResult(
9+
data class GameResult(
1010
val definition: ScoreDefinition,
1111
@XStreamImplicit(itemFieldName = "score")
1212
val scores: List<PlayerScore>,
1313
@XStreamImplicit(itemFieldName = "winner")
1414
val winners: List<Player>?
1515
): ProtocolMessage {
1616

17+
val isRegular: Boolean
18+
get() = scores.all { it.cause == ScoreCause.REGULAR }
19+
1720
override fun toString(): String {
1821
val builder = StringBuilder("Winner: ").append(winners)
1922
scores.forEachIndexed { playerIndex, score ->
@@ -24,8 +27,4 @@ class GameResult(
2427
return builder.toString()
2528
}
2629

27-
val isRegular: Boolean by lazy {
28-
scores.all { it.cause == ScoreCause.REGULAR }
29-
}
30-
3130
}

0 commit comments

Comments
 (0)