File tree Expand file tree Collapse file tree 2 files changed +15
-11
lines changed
plugin2026/src/main/kotlin/sc/plugin2026 Expand file tree Collapse file tree 2 files changed +15
-11
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ import sc.api.plugins.Team
99import sc.plugin2026.util.*
1010import kotlin.math.floor
1111
12- typealias FieldS = Field
12+ typealias FieldS = FieldState
1313
1414/* * Spielbrett für Piranhas mit [PiranhaConstants.BOARD_LENGTH]² Feldern. */
1515@XStreamAlias(value = " board" )
@@ -34,10 +34,10 @@ class Board(gameField: MutableTwoDBoard<FieldS> = randomFields()): RectangularBo
3434 Board (Array (gameField.size) { column -> this .gameField[column].clone() })
3535
3636 fun getTeam (pos : Coordinates ): Team ? =
37- this [pos].state. team
37+ this [pos].team
3838
3939 fun fieldsForTeam (team : ITeam ): Collection <Coordinates > =
40- filterValues { field -> field.state. team == team }.map { it.key }
40+ filterValues { field -> field.team == team }.map { it.key }
4141
4242 companion object {
4343 /* * Erstellt ein zufälliges Spielbrett. */
Original file line number Diff line number Diff line change 11package sc.plugin2026
22
3+ import sc.api.plugins.IField
34import sc.api.plugins.Team
45
5- enum class FieldState (val size : Int ) {
6+ enum class FieldState (val size : Int ): IField<FieldState> {
67 ONE_S (1 ),
78 ONE_M (2 ),
89 ONE_L (3 ),
@@ -12,6 +13,16 @@ enum class FieldState(val size: Int) {
1213 OBSTRUCTED (0 ),
1314 EMPTY (0 );
1415
16+ override val isEmpty: Boolean
17+ get() = this == EMPTY
18+
19+ val team: Team ?
20+ get() = when (this ) {
21+ ONE_S , ONE_M , ONE_L -> Team .ONE
22+ TWO_S , TWO_M , TWO_L -> Team .TWO
23+ OBSTRUCTED , EMPTY -> null
24+ }
25+
1526 override fun toString () =
1627 when (this ) {
1728 OBSTRUCTED -> " Krake"
@@ -26,11 +37,4 @@ enum class FieldState(val size: Int) {
2637 else -> team?.letter.toString() + size.toString()
2738 }
2839
29- val team: Team ?
30- get() = when (this ) {
31- ONE_S , ONE_M , ONE_L -> Team .ONE
32- TWO_S , TWO_M , TWO_L -> Team .TWO
33- OBSTRUCTED , EMPTY -> null
34- }
35-
3640}
You can’t perform that action at this time.
0 commit comments