Skip to content

Commit 6d54216

Browse files
committed
refactor(plugin): give getPossibleMoves the actual gameState
also, add another function to get startMoves only
1 parent 371668e commit 6d54216

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

player/src/sc/player2021/logic/Logic.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class Logic(private val client: SimpleClient): IGameHandler{
3535
override fun onRequestAction() {
3636
val startTime = System.currentTimeMillis()
3737
logger.info("Es wurde ein Zug angefordert.")
38-
val possibleMoves = GameRuleLogic.getPossibleMoves()
38+
val possibleMoves = GameRuleLogic.getPossibleMoves(gameState)
3939
sendAction(
4040
if (possibleMoves.isEmpty()) PassMove(gameState.currentColor)
4141
else possibleMoves.random())

plugin/src/shared/sc/plugin2021/util/GameRuleLogic.kt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import org.slf4j.LoggerFactory
44
import sc.api.plugins.exceptions.GameLogicException
55
import sc.plugin2021.*
66
import sc.shared.InvalidMoveException
7+
import kotlin.properties.Delegates
78

89
object GameRuleLogic {
910
val logger = LoggerFactory.getLogger(GameLogicException::class.java)
@@ -141,7 +142,18 @@ object GameRuleLogic {
141142

142143
/** Returns a list of all possible SetMoves. */
143144
@JvmStatic
144-
fun getPossibleMoves(): List<SetMove> {
145-
return emptyList()
145+
fun getPossibleMoves(gameState: GameState): Set<SetMove> {
146+
if (gameState.round == 1) return getPossibleStartMoves(gameState)
147+
val color = gameState.currentColor
148+
149+
return emptySet()
150+
}
151+
152+
/** Returns a list of possible SetMoves if it's the first round. */
153+
@JvmStatic
154+
fun getPossibleStartMoves(gameState: GameState): Set<SetMove> {
155+
val color = gameState.currentColor
156+
157+
return emptySet()
146158
}
147159
}

0 commit comments

Comments
 (0)