File tree Expand file tree Collapse file tree 3 files changed +12
-16
lines changed
plugin/src/main/kotlin/sc/plugin2023
sdk/src/main/server-api/sc/api/plugins Expand file tree Collapse file tree 3 files changed +12
-16
lines changed Original file line number Diff line number Diff line change @@ -9,9 +9,6 @@ import sc.plugin2023.util.PluginConstants
9
9
import sc.shared.MoveMistake
10
10
import sc.shared.InvalidMoveException
11
11
12
- val ITeam .color
13
- get() = if (index == 0 ) " Rot" else " Blau"
14
-
15
12
/* *
16
13
* Der aktuelle Spielstand.
17
14
*
Original file line number Diff line number Diff line change @@ -53,17 +53,12 @@ open class RectangularBoard<FIELD: IField<FIELD>>(
53
53
null
54
54
55
55
/* * 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
+ }
67
62
68
63
override fun toString () =
69
64
gameField.joinToString(separator = " \n " ) { row ->
@@ -83,9 +78,8 @@ open class RectangularBoard<FIELD: IField<FIELD>>(
83
78
}
84
79
}.toSet()
85
80
86
- // TODO proper xstream post-init for empty gameField, becomes null now
87
81
override val size: Int
88
- get() = gameField? .sumOf { it.size } ? : 0
82
+ get() = gameField.sumOf { it.size }
89
83
90
84
override fun iterator (): Iterator <FIELD > = object : AbstractIterator <FIELD >() {
91
85
var index = 0
Original file line number Diff line number Diff line change @@ -8,12 +8,17 @@ enum class Team(override val index: Int): ITeam {
8
8
ONE (0 ) {
9
9
override fun opponent (): Team = TWO
10
10
override val letter = ' R'
11
+ override val color = " Rot"
11
12
},
12
13
13
14
TWO (1 ) {
14
15
override fun opponent (): Team = ONE
15
16
override val letter = ' B'
17
+ override val color = " Blau"
16
18
};
19
+
20
+ abstract val color: String
21
+
17
22
override fun opponent (): Team = throw IllegalArgumentException ()
18
23
}
19
24
You can’t perform that action at this time.
0 commit comments