File tree Expand file tree Collapse file tree 3 files changed +15
-10
lines changed
plugin/src/server/sc/plugin2021 Expand file tree Collapse file tree 3 files changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -31,15 +31,11 @@ class Game(override val currentState: GameState = GameState()): AbstractGame<Pla
31
31
return player
32
32
}
33
33
34
- override val winners: MutableList <Player >
34
+ override val winners: List <Player >
35
35
get() {
36
- if (players.first().hasViolated()) {
37
- if (players.last().hasViolated())
38
- return mutableListOf ()
39
- return players.subList(1 , 2 )
40
- }
41
- if (players.last().hasViolated())
42
- return players.subList(0 , 1 )
36
+ val compliant = players.filter { ! it.hasViolated() && ! it.hasLeft() }
37
+ if (compliant.size < players.size)
38
+ return compliant
43
39
44
40
val first = currentState.getPointsForPlayer(players.first().color)
45
41
val second = currentState.getPointsForPlayer(players.last().color)
Original file line number Diff line number Diff line change @@ -70,6 +70,12 @@ class GameRoomTest: WordSpec({
70
70
<score cause="REGULAR" reason="Game terminated">
71
71
<part>0</part>
72
72
</score>
73
+ <winner displayName="">
74
+ <color class="sc.server.helpers.TestTeam">RED</color>
75
+ </winner>
76
+ <winner displayName="">
77
+ <color class="sc.server.helpers.TestTeam">BLUE</color>
78
+ </winner>
73
79
</data>
74
80
</room>
75
81
</protocol>
Original file line number Diff line number Diff line change @@ -12,8 +12,11 @@ data class TestGame(
12
12
override val currentState : TestGameState = TestGameState (),
13
13
): AbstractGame<Player>(TestPlugin .TEST_PLUGIN_UUID ) {
14
14
15
- override val playerScores: List <PlayerScore > = emptyList()
16
- override val winners: List <Player > = emptyList()
15
+ override val playerScores: List <PlayerScore >
16
+ get() = players.map { getScoreFor(it) }
17
+
18
+ override val winners: List <Player >
19
+ get() = players.filter { ! it.hasViolated() && ! it.hasLeft() }
17
20
18
21
override fun onRoundBasedAction (fromPlayer : Player , move : IMove ) {
19
22
if (move !is TestMove )
You can’t perform that action at this time.
0 commit comments