Skip to content

Commit fb1b49c

Browse files
committed
feat(sdk): create RoomOrchestrationMessage marker interface
1 parent 6613487 commit fb1b49c

File tree

8 files changed

+15
-9
lines changed

8 files changed

+15
-9
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package sc.shared
33
import com.thoughtworks.xstream.annotations.XStreamAlias
44
import com.thoughtworks.xstream.annotations.XStreamImplicit
55
import sc.framework.plugins.Player
6-
import sc.protocol.room.RoomMessage
6+
import sc.protocol.room.RoomOrchestrationMessage
77

88
/**
99
* Das Endergebnis eines Spiels.
@@ -17,7 +17,7 @@ data class GameResult(
1717
val scores: List<PlayerScore>,
1818
@XStreamImplicit(itemFieldName = "winner")
1919
val winners: List<Player>?
20-
): RoomMessage {
20+
): RoomOrchestrationMessage {
2121

2222
val isRegular: Boolean
2323
get() = scores.all { it.cause == ScoreCause.REGULAR }

sdk/src/framework/sc/shared/WelcomeMessage.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ package sc.shared
33
import com.thoughtworks.xstream.annotations.XStreamAlias
44
import com.thoughtworks.xstream.annotations.XStreamAsAttribute
55
import sc.api.plugins.ITeam
6-
import sc.protocol.room.RoomMessage
6+
import sc.protocol.room.RoomOrchestrationMessage
77

88
/** Nachricht, die zu Beginn eines Spiels an einen Client geschickt wird, um ihm seine Spielerfarbe mitzuteilen. */
99
@Suppress("DataClassPrivateConstructor")
1010
@XStreamAlias(value = "welcomeMessage")
1111
data class WelcomeMessage private constructor(
12-
@XStreamAsAttribute val color: String
13-
): RoomMessage {
12+
@XStreamAsAttribute val color: String,
13+
): RoomOrchestrationMessage {
1414
constructor(color: ITeam): this(color.name)
1515
}

sdk/src/server-api/sc/api/plugins/IGameState.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,6 @@ interface IGameState : RoomMessage, Cloneable {
3131

3232
/** Aktuelle Rundenzahl */
3333
val round: Int
34+
35+
public override fun clone(): IGameState
3436
}

sdk/src/server-api/sc/api/plugins/TwoPlayerGameState.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,4 @@ abstract class TwoPlayerGameState<P : Player>(
5757
override fun toString() =
5858
"GameState(turn=$turn,currentPlayer=${currentPlayer.color})"
5959

60-
public abstract override fun clone(): IGameState
61-
6260
}

sdk/src/server-api/sc/protocol/room/ErrorMessage.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ data class ErrorMessage(
99
val originalMessage: RoomMessage,
1010
@XStreamAsAttribute
1111
val message: String,
12-
): RoomMessage {
12+
): RoomOrchestrationMessage {
1313
val logMessage
1414
get() = "$originalMessage caused an error: $message"
1515
}

sdk/src/server-api/sc/protocol/room/GamePaused.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ import sc.framework.plugins.Player
1414
data class GamePaused(
1515
@XStreamAsAttribute
1616
val nextPlayer: Player
17-
): RoomMessage
17+
): RoomOrchestrationMessage
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
package sc.protocol.room
22

3+
/** Implemented by any message sent within a GameRoom. */
34
interface RoomMessage
5+
6+
/** Implemented by any message within a room
7+
* that does not concern the progress of the game. */
8+
interface RoomOrchestrationMessage: RoomMessage

server/test/sc/server/plugins/TestGameState.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ data class TestGameState(
1919
currentPlayer = TestTeam.values()[(turn + startPlayer.index) % 2]
2020
}
2121

22+
override fun clone() = throw NotImplementedError()
2223
}

0 commit comments

Comments
 (0)