Skip to content

Commit b20b0fd

Browse files
committed
fix: add Team color to sdk
1 parent 1aaf295 commit b20b0fd

File tree

3 files changed

+12
-16
lines changed

3 files changed

+12
-16
lines changed

plugin/src/main/kotlin/sc/plugin2023/GameState.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ import sc.plugin2023.util.PluginConstants
99
import sc.shared.MoveMistake
1010
import sc.shared.InvalidMoveException
1111

12-
val ITeam.color
13-
get() = if(index == 0) "Rot" else "Blau"
14-
1512
/**
1613
* Der aktuelle Spielstand.
1714
*

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

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,12 @@ open class RectangularBoard<FIELD: IField<FIELD>>(
5353
null
5454

5555
/** Vergleicht zwei Spielfelder und gibt eine Liste aller Felder zurück, die sich unterscheiden. */
56-
//fun compare(other: Board): Set<Field> {
57-
// val changedFields = mutableSetOf<Field>()
58-
// for (y in 0 until Constants.BOARD_SIZE) {
59-
// for (x in 0 until Constants.BOARD_SIZE) {
60-
// if (gameField[y][x] != other.gameField[y][x]) {
61-
// changedFields += Field(Coordinates(x, y), other.gameField[y][x])
62-
// }
63-
// }
64-
// }
65-
// return changedFields
66-
//}
56+
fun compare(other: RectangularBoard<FIELD>): Collection<FIELD> {
57+
val entries = this.entries
58+
return other.entries.filter {
59+
it !in entries
60+
}.map { it.value }
61+
}
6762

6863
override fun toString() =
6964
gameField.joinToString(separator = "\n") { row ->
@@ -83,9 +78,8 @@ open class RectangularBoard<FIELD: IField<FIELD>>(
8378
}
8479
}.toSet()
8580

86-
// TODO proper xstream post-init for empty gameField, becomes null now
8781
override val size: Int
88-
get() = gameField?.sumOf { it.size } ?: 0
82+
get() = gameField.sumOf { it.size }
8983

9084
override fun iterator(): Iterator<FIELD> = object: AbstractIterator<FIELD>() {
9185
var index = 0

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,17 @@ enum class Team(override val index: Int): ITeam {
88
ONE(0) {
99
override fun opponent(): Team = TWO
1010
override val letter = 'R'
11+
override val color = "Rot"
1112
},
1213

1314
TWO(1) {
1415
override fun opponent(): Team = ONE
1516
override val letter = 'B'
17+
override val color = "Blau"
1618
};
19+
20+
abstract val color: String
21+
1722
override fun opponent(): Team = throw IllegalArgumentException()
1823
}
1924

0 commit comments

Comments
 (0)