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
9
9
import sc.plugin2026.util.*
10
10
import kotlin.math.floor
11
11
12
- typealias FieldS = Field
12
+ typealias FieldS = FieldState
13
13
14
14
/* * Spielbrett für Piranhas mit [PiranhaConstants.BOARD_LENGTH]² Feldern. */
15
15
@XStreamAlias(value = " board" )
@@ -34,10 +34,10 @@ class Board(gameField: MutableTwoDBoard<FieldS> = randomFields()): RectangularBo
34
34
Board (Array (gameField.size) { column -> this .gameField[column].clone() })
35
35
36
36
fun getTeam (pos : Coordinates ): Team ? =
37
- this [pos].state. team
37
+ this [pos].team
38
38
39
39
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 }
41
41
42
42
companion object {
43
43
/* * Erstellt ein zufälliges Spielbrett. */
Original file line number Diff line number Diff line change 1
1
package sc.plugin2026
2
2
3
+ import sc.api.plugins.IField
3
4
import sc.api.plugins.Team
4
5
5
- enum class FieldState (val size : Int ) {
6
+ enum class FieldState (val size : Int ): IField<FieldState> {
6
7
ONE_S (1 ),
7
8
ONE_M (2 ),
8
9
ONE_L (3 ),
@@ -12,6 +13,16 @@ enum class FieldState(val size: Int) {
12
13
OBSTRUCTED (0 ),
13
14
EMPTY (0 );
14
15
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
+
15
26
override fun toString () =
16
27
when (this ) {
17
28
OBSTRUCTED -> " Krake"
@@ -26,11 +37,4 @@ enum class FieldState(val size: Int) {
26
37
else -> team?.letter.toString() + size.toString()
27
38
}
28
39
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
-
36
40
}
You can’t perform that action at this time.
0 commit comments