Skip to content

Commit 3e8b3ba

Browse files
committed
fix(sdk): remove confusing round numbers
1 parent 8f18737 commit 3e8b3ba

File tree

6 files changed

+8
-27
lines changed

6 files changed

+8
-27
lines changed

plugin/src/test/kotlin/sc/plugin2023/GameStateTest.kt

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,6 @@ class GameStateTest: FunSpec({
3838
// TODO
3939
}
4040
}
41-
context("state detection") {
42-
test("isOver") {
43-
val state = GameState()
44-
state.round shouldBe 0
45-
state.isOver shouldBe false
46-
val state60 = GameState(turn = 58)
47-
state60.round shouldBe 29
48-
state60.isOver shouldBe false
49-
state60.turn++
50-
state60.round shouldBe 30
51-
state60.isOver shouldBe false
52-
state60.turn++
53-
state60.round shouldBe 30
54-
state60.isOver shouldBe false
55-
//state60.isOver shouldBe true
56-
}
57-
}
5841
context("move calculation") {
5942
context("initial placement") {
6043
val emptyBoard = makeBoard()

plugin2025/src/main/kotlin/sc/plugin2025/GameState.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ data class GameState @JvmOverloads constructor(
6666
get() = currentTeamFromTurn()
6767

6868
override val isOver: Boolean
69-
get() = players.any { it.inGoal } && turn.mod(2) == 0 || round >= HuIConstants.ROUND_LIMIT
69+
get() = players.any { it.inGoal } && turn.mod(2) == 0 || turn / 2 >= HuIConstants.ROUND_LIMIT
7070

7171
override val winCondition: WinCondition?
7272
get() = players.singleOrNull { it.inGoal }?.team?.let { WinCondition(it, HuIWinReason.GOAL) }

plugin2025/src/test/kotlin/sc/plugin2025/GameStateTest.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ class GameStateTest: FunSpec({
6363
state.isOver shouldBe true
6464
state.winCondition shouldBe null
6565
}
66+
test("round limit") {
67+
state.turn = 59
68+
state.isOver shouldBe false
69+
state.turn++
70+
state.isOver shouldBe true
71+
}
6672
}
6773
test("produce nice XML") {
6874
Hare(Team.TWO, lastAction = EatSalad) shouldSerializeTo """

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,9 @@ import sc.shared.WinCondition
3030
* Teilinformationen abgefragt werden.
3131
*/
3232
interface IGameState: RoomMessage, PublicCloneable<IGameState> {
33-
/** Aktuelle Zugzahl */
33+
/** Aktuelle Zugzahl. */
3434
val turn: Int
3535

36-
/** Aktuelle Rundenzahl */
37-
val round: Int
38-
3936
/** Das Team am Zug. */
4037
val currentTeam: ITeam
4138

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ abstract class TwoPlayerGameState<M: IMove>(
99

1010
abstract val board: IBoard
1111

12-
override val round: Int
13-
get() = (turn+1)/2
14-
1512
/** @return das Team, das am Zug ist. */
1613
override val currentTeam
1714
get() = currentTeamFromTurn()

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ data class TestGameState(
3030
override fun teamStats(team: ITeam) =
3131
throw NotImplementedError("TestGame has no teamStats")
3232

33-
override val round get() = turn / 2
34-
3533
val red = Player(Team.ONE, "Fred")
3634
val blue = Player(Team.TWO, "Marta")
3735

0 commit comments

Comments
 (0)