Skip to content

Commit 193fa9d

Browse files
committed
refactor(plugin): give getPossibleMoves the actual gameState
also, add another function to get startMoves only
1 parent 9046c2b commit 193fa9d

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
@@ -3,6 +3,7 @@ package sc.plugin2021.util
33
import org.slf4j.LoggerFactory
44
import sc.plugin2021.*
55
import sc.shared.InvalidMoveException
6+
import kotlin.properties.Delegates
67

78
object GameRuleLogic {
89
val logger = LoggerFactory.getLogger(GameRuleLogic::class.java)
@@ -140,7 +141,18 @@ object GameRuleLogic {
140141

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

0 commit comments

Comments
 (0)