Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/main/kotlin/sc/gui/controller/BlokusController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import javafx.beans.property.Property
import javafx.beans.value.ObservableValue
import org.slf4j.LoggerFactory
import sc.api.plugins.Coordinates
import sc.api.plugins.IMove
import sc.api.plugins.Team
import sc.gui.GameOverEvent
import sc.gui.GameReadyEvent
Expand Down Expand Up @@ -254,6 +255,12 @@ class BlokusController : Controller() {
fun scroll(deltaY: Double) {
currentPiece.get().scroll(deltaY)
}

fun sendHumanMove(move: IMove) {
fire(HumanMoveAction(move.also {
logger.debug("Human Move: {}", it)
}))
}

companion object {
private val logger = LoggerFactory.getLogger(BlokusController::class.java)
Expand Down
2 changes: 2 additions & 0 deletions src/main/kotlin/sc/gui/view/PlayerOneView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import javafx.geometry.Pos
import sc.api.plugins.Team
import sc.gui.controller.BlokusController
import sc.gui.model.GameModel
import sc.gui.view.game.SkipMoveButton
import sc.plugin2027.Color
import tornadofx.*

Expand All @@ -29,6 +30,7 @@ class PlayerOneView(gameController: BlokusController, gridSize: DoubleBinding):
gameController.validPieces.getValue(Color.RED),
gridSize
))
add(SkipMoveButton(gameController, gridSize, Team.ONE))
// Run this later since scene is not ready yet
runLater {
this.padding = Insets(0.0, 0.0, 0.0, 0.0)
Expand Down
2 changes: 2 additions & 0 deletions src/main/kotlin/sc/gui/view/PlayerTwoView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import javafx.geometry.Pos
import sc.api.plugins.Team
import sc.gui.controller.BlokusController
import sc.gui.model.GameModel
import sc.gui.view.game.SkipMoveButton
import sc.plugin2027.Color
import tornadofx.*

Expand All @@ -29,6 +30,7 @@ class PlayerTwoView(gameController: BlokusController, gridSize: DoubleBinding):
gameController.validPieces.getValue(Color.GREEN),
gridSize
))
add(SkipMoveButton(gameController, gridSize, Team.TWO))
// Run this later since scene is not ready yet
runLater {
this.padding = Insets(0.0, 0.0, 0.0, 0.0)
Expand Down
32 changes: 32 additions & 0 deletions src/main/kotlin/sc/gui/view/game/SkipMoveButton.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package sc.gui.view.game

import javafx.beans.binding.Bindings
import javafx.beans.binding.DoubleBinding
import javafx.scene.control.Button
import sc.api.plugins.Team
import sc.gui.controller.BlokusController
import sc.plugin2027.SkipMove
import tornadofx.onLeftClick

class SkipMoveButton(
private val gameController: BlokusController,
gridSize: DoubleBinding,
team: Team
) : Button("Aussetzen") {

init {
prefWidthProperty().bind(gridSize.multiply(5))
// Disable button if the current turn is not from a human player,
// we cannot skip (i.e. the first round),
// or if it is not our turn.
disableProperty().bind(Bindings.createBooleanBinding(
{ !(gameController.isHumanTurn.value && gameController.canSkip.value && gameController.currentColor.value.team == team) },
gameController.isHumanTurn,
gameController.canSkip,
gameController.currentColor
))
onLeftClick {
gameController.sendHumanMove(SkipMove(gameController.currentColor.value))
}
}
}
Loading