Skip to content

Commit 14f23f7

Browse files
committed
refactor(plugin25): rename HuIMove to Move to fix player template
1 parent 298043c commit 14f23f7

File tree

9 files changed

+17
-17
lines changed

9 files changed

+17
-17
lines changed

plugin/src/main/kotlin/sc/plugin2025/Advance.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import sc.shared.IMoveMistake
1313
* Der Wert der Karottentauschkarte spielt dann keine Rolle.
1414
*/
1515
@XStreamAlias(value = "advance")
16-
class Advance(@XStreamAsAttribute val distance: Int, vararg val cards: Card): HuIMove {
16+
class Advance(@XStreamAsAttribute val distance: Int, vararg val cards: Card): Move {
1717

1818
override fun perform(state: GameState): IMoveMistake? {
1919
val player = state.currentPlayer

plugin/src/main/kotlin/sc/plugin2025/Card.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import sc.shared.IMoveMistake
55

66
/** Mögliche Aktionen, die durch das Ausspielen einer Karte ausgelöst werden können. */
77
@XStreamAlias(value = "card")
8-
enum class Card(val moves: Boolean, val playable: (GameState) -> HuIMoveMistake?, val play: (GameState) -> Unit): HuIMove {
8+
enum class Card(val moves: Boolean, val playable: (GameState) -> HuIMoveMistake?, val play: (GameState) -> Unit): Move {
99
/** Falle hinter den Gegenspieler. */
1010
FALL_BACK(true,
1111
{ state ->

plugin/src/main/kotlin/sc/plugin2025/EatSalad.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import sc.shared.IMoveMistake
1111
* und es werden je nachdem ob der Spieler führt oder nicht 10 oder 30 Karotten aufgenommen.
1212
*/
1313
@XStreamAlias(value = "EatSalad")
14-
object EatSalad: HuIMove {
14+
object EatSalad: Move {
1515
override fun perform(state: GameState): IMoveMistake? {
1616
if(state.mustEatSalad()) {
1717
state.currentPlayer.saladEaten = true

plugin/src/main/kotlin/sc/plugin2025/ExchangeCarrots.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import sc.shared.IMoveMistake
99
* Dies kann beliebig oft hintereinander ausgeführt werden.
1010
*/
1111
@XStreamAlias(value = "ExchangeCarrots")
12-
data class ExchangeCarrots(val value: Int): HuIMove {
12+
data class ExchangeCarrots(val value: Int): Move {
1313
override fun perform(state: GameState): IMoveMistake? {
1414
if(state.mayExchangeCarrots(this.value)) {
1515
state.currentPlayer.carrots += value

plugin/src/main/kotlin/sc/plugin2025/FallBack.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import com.thoughtworks.xstream.annotations.XStreamAlias
99
* Dabei werden die zurückgezogene Distanz * 10 Karotten aufgenommen.
1010
*/
1111
@XStreamAlias(value = "fallBack")
12-
object FallBack: HuIMove {
12+
object FallBack: Move {
1313
override fun perform(state: GameState): HuIMoveMistake? {
1414
val previousFieldIndex = state.nextFallBack()
1515
if(previousFieldIndex != null) {

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ data class GameState @JvmOverloads constructor(
2727
@XStreamAsAttribute override var turn: Int = 0,
2828
@XStreamImplicit val players: List<Hare> = Team.values().map { Hare(it) },
2929
/** Der zuletzt gespielte Zug. */
30-
override var lastMove: HuIMove? = null,
31-
): TwoPlayerGameState<HuIMove>(players.first().team) {
30+
override var lastMove: Move? = null,
31+
): TwoPlayerGameState<Move>(players.first().team) {
3232

3333
val currentPlayer
3434
get() = getHare(currentTeam)
@@ -70,9 +70,9 @@ data class GameState @JvmOverloads constructor(
7070
override fun getPointsForTeam(team: ITeam): IntArray =
7171
getHare(team).let { intArrayOf(if(it.inGoal) 1 else 0, it.position, it.salads) }
7272

73-
override fun getSensibleMoves(): List<HuIMove> = getSensibleMoves(currentPlayer)
73+
override fun getSensibleMoves(): List<Move> = getSensibleMoves(currentPlayer)
7474

75-
fun getSensibleMoves(player: Hare): List<HuIMove> {
75+
fun getSensibleMoves(player: Hare): List<Move> {
7676
if(mustEatSalad(player))
7777
return listOf(EatSalad)
7878
return (1..calculateMoveableFields(player.carrots).coerceAtMost(board.size - player.position)).flatMap { distance ->
@@ -127,9 +127,9 @@ data class GameState @JvmOverloads constructor(
127127
else -> null
128128
}
129129

130-
override fun moveIterator(): Iterator<HuIMove> = getSensibleMoves().iterator()
130+
override fun moveIterator(): Iterator<Move> = getSensibleMoves().iterator()
131131

132-
override fun performMoveDirectly(move: HuIMove) {
132+
override fun performMoveDirectly(move: Move) {
133133
val mist =
134134
HuIMoveMistake.MUST_EAT_SALAD.takeIf {
135135
mustEatSalad() && move != EatSalad

plugin/src/main/kotlin/sc/plugin2025/HuIMove.kt renamed to plugin/src/main/kotlin/sc/plugin2025/Move.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import sc.api.plugins.IMove
55
import sc.shared.IMoveMistake
66

77
@XStreamAlias(value = "action")
8-
interface HuIMove: IMove {
8+
interface Move: IMove {
99
fun perform(state: GameState): IMoveMistake?
1010
}
1111

plugin/src/main/kotlin/sc/plugin2025/util/GamePlugin.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import sc.api.plugins.IGamePlugin
66
import sc.api.plugins.IGameState
77
import sc.framework.plugins.TwoPlayerGame
88
import sc.plugin2025.GameState
9-
import sc.plugin2025.HuIMove
9+
import sc.plugin2025.Move
1010
import sc.shared.*
1111

1212
@XStreamAlias(value = "winreason")
@@ -16,7 +16,7 @@ enum class HuIWinReason(override val message: String, override val isRegular: Bo
1616
GOAL("%s hat das Ziel zuerst erreicht."),
1717
}
1818

19-
class GamePlugin: IGamePlugin<HuIMove> {
19+
class GamePlugin: IGamePlugin<Move> {
2020
companion object {
2121
const val PLUGIN_ID = "swc_2025_hase_und_igel"
2222
val scoreDefinition: ScoreDefinition =
@@ -36,7 +36,7 @@ class GamePlugin: IGamePlugin<HuIMove> {
3636
override val turnLimit: Int =
3737
HuIConstants.ROUND_LIMIT * 2
3838

39-
override val moveClass = HuIMove::class.java
39+
override val moveClass = Move::class.java
4040

4141
override fun createGame(): IGameInstance =
4242
TwoPlayerGame(this, GameState())
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package sc.plugin2025.util
22

33
import sc.networking.XStreamProvider
4-
import sc.plugin2025.*
4+
import sc.plugin2025.Move
55

66
class XStreamClasses: XStreamProvider {
77

88
override val classesToRegister =
99
listOf(
10-
HuIMove::class.java
10+
Move::class.java
1111
)
1212

1313
}

0 commit comments

Comments
 (0)