Various fixes
This commit is contained in:
@@ -9,4 +9,5 @@ object ControlThread extends CustomThread {
|
||||
def isControlThread: Boolean = Thread.currentThread().equals(ControlThread)
|
||||
|
||||
override def instance: CustomThread = ControlThread
|
||||
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ import de.knockoutwhist.rounds.{Round, Trick}
|
||||
object PlayerUtil {
|
||||
|
||||
def canPlayCard(card: Card, round: Round, trick: Trick, player: AbstractPlayer): Boolean = {
|
||||
if (trick.firstCard.isEmpty)
|
||||
return true
|
||||
val alternatives = alternativeCards(card, round, trick, player)
|
||||
if (alternatives.nonEmpty) {
|
||||
return false
|
||||
|
||||
@@ -3,6 +3,10 @@ package de.knockoutwhist.events.player
|
||||
import de.knockoutwhist.player.AbstractPlayer
|
||||
import de.knockoutwhist.utils.events.SimpleEvent
|
||||
|
||||
import java.util.UUID
|
||||
|
||||
abstract class PlayerEvent(player: AbstractPlayer) extends SimpleEvent {
|
||||
|
||||
def playerId: UUID = player.id
|
||||
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@ package de.knockoutwhist.persistence.formats
|
||||
|
||||
import de.knockoutwhist.KnockOutWhist
|
||||
import de.knockoutwhist.cards.*
|
||||
import de.knockoutwhist.control.{GameLogic, GameState, LogicSnapshot}
|
||||
import de.knockoutwhist.control.controllerBaseImpl.BaseGameLogicSnapshot
|
||||
import de.knockoutwhist.control.controllerBaseImpl.sublogic.{BasePlayerTieLogic, BasePlayerTieLogicSnapshot}
|
||||
import de.knockoutwhist.control.{GameLogic, GameState, LogicSnapshot}
|
||||
import de.knockoutwhist.persistence.{MatchSnapshot, MethodEntryPoint}
|
||||
import de.knockoutwhist.player.{AbstractPlayer, PlayerData, PlayerFactory, Playertype}
|
||||
import de.knockoutwhist.rounds.{Match, Round, Trick}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
package de.knockoutwhist.player
|
||||
|
||||
import de.knockoutwhist.cards.{Card, Hand, Suit}
|
||||
import de.knockoutwhist.cards.{Card, Hand}
|
||||
|
||||
import java.util.UUID
|
||||
import scala.collection.immutable
|
||||
import scala.util.Try
|
||||
|
||||
//If you get an uuid conflict, go play the lottery!!!
|
||||
abstract case class AbstractPlayer private[player](name: String, id: UUID = UUID.randomUUID()) {
|
||||
|
||||
@@ -3,8 +3,8 @@ package de.knockoutwhist.ui.gui
|
||||
import atlantafx.base.theme.PrimerDark
|
||||
import de.knockoutwhist.control.GameLogic
|
||||
import de.knockoutwhist.control.GameState.{InGame, Lobby, MainMenu, TieBreak}
|
||||
import de.knockoutwhist.events.global.{CardPlayedEvent, GameStateChangeEvent, MatchEndEvent, NewRoundEvent, RoundEndEvent, TrickEndEvent, TrumpSelectEvent, TrumpSelectedEvent, TurnEvent}
|
||||
import de.knockoutwhist.events.global.tie.{TieShowPlayerCardsEvent, TieTieEvent, TieTurnEvent, TieWinningPlayersEvent}
|
||||
import de.knockoutwhist.events.global.*
|
||||
import de.knockoutwhist.events.player.{RequestCardEvent, RequestTieChoiceEvent}
|
||||
import de.knockoutwhist.player.AbstractPlayer
|
||||
import de.knockoutwhist.ui.UI
|
||||
|
||||
@@ -256,10 +256,10 @@ class Game(gui: GUIMain) {
|
||||
if (logic.getCurrentPlayer.isDefined && logic.isWaitingForInput) {
|
||||
val currentPlayer = logic.getCurrentPlayer.get
|
||||
if (!currentPlayer.isInDogLife) {
|
||||
if (PlayerUtil.canPlayCard(card, currentRound, currentTrick, currentPlayer)) {
|
||||
if (!PlayerUtil.canPlayCard(card, currentRound, currentTrick, currentPlayer)) {
|
||||
val pulse = Animations.pulse(this, Duration(400))
|
||||
pulse.play()
|
||||
}
|
||||
} else {
|
||||
hideCards(this)
|
||||
val slideOut = Animations.slideOutUp(this, Duration(400), -350)
|
||||
slideOut.onFinished = _ => {
|
||||
@@ -275,23 +275,8 @@ class Game(gui: GUIMain) {
|
||||
}
|
||||
}
|
||||
slideOut.play()
|
||||
} else {
|
||||
hideCards(this)
|
||||
val slideOutDog = Animations.slideOutUp(this, Duration(400), -350)
|
||||
slideOutDog.onFinished = _ => {
|
||||
visible = false
|
||||
ControlThread.runLater {
|
||||
logic.undoManager.doStep(
|
||||
PlayDogCardCommand(
|
||||
logic.createSnapshot(),
|
||||
logic.playerTieLogic.createSnapshot(),
|
||||
Some(card)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
slideOutDog.play()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@ package de.knockoutwhist.ui.gui
|
||||
|
||||
import atlantafx.base.theme.Styles
|
||||
import de.knockoutwhist.KnockOutWhist
|
||||
import de.knockoutwhist.control.controllerBaseImpl.sublogic.BasePersistenceManager
|
||||
import de.knockoutwhist.control.ControlThread
|
||||
import de.knockoutwhist.control.controllerBaseImpl.sublogic.BasePersistenceManager
|
||||
import de.knockoutwhist.player.Playertype.HUMAN
|
||||
import de.knockoutwhist.player.{AbstractPlayer, PlayerFactory}
|
||||
import de.knockoutwhist.ui.tui.TUIMain
|
||||
@@ -13,8 +13,8 @@ import scalafx.animation.Timeline
|
||||
import scalafx.geometry.Insets
|
||||
import scalafx.geometry.Pos.{BottomCenter, Center, TopCenter, TopLeft, TopRight}
|
||||
import scalafx.scene.Parent
|
||||
import scalafx.scene.control.Alert.AlertType
|
||||
import scalafx.scene.control.*
|
||||
import scalafx.scene.control.Alert.AlertType
|
||||
import scalafx.scene.image.{Image, ImageView}
|
||||
import scalafx.scene.layout.Priority.Always
|
||||
import scalafx.scene.layout.{BorderPane, HBox, StackPane, VBox}
|
||||
@@ -70,7 +70,7 @@ class MainMenu(gui: GUIMain) {
|
||||
text = "Load Game"
|
||||
font = Font.font(20)
|
||||
styleClass += Styles.ACCENT
|
||||
disable = gui.logic.isEmpty || gui.logic.get.persistenceManager.canLoadfile("currentSnapshot")
|
||||
disable = gui.logic.isDefined && !gui.logic.get.persistenceManager.canLoadfile("currentSnapshot")
|
||||
onMouseClicked = _ => gui.logic.get.persistenceManager.loadFile("currentSnapshot")
|
||||
}
|
||||
)
|
||||
|
||||
@@ -15,8 +15,8 @@ import scalafx.geometry.Insets
|
||||
import scalafx.geometry.Pos.{BottomCenter, Center, TopCenter}
|
||||
import scalafx.scene.control.{Button, Label, Slider}
|
||||
import scalafx.scene.image.{Image, ImageView}
|
||||
import scalafx.scene.layout.Priority.Always
|
||||
import scalafx.scene.layout.*
|
||||
import scalafx.scene.layout.Priority.Always
|
||||
import scalafx.scene.text.Font
|
||||
import scalafx.scene.{Node, Parent, layout}
|
||||
import scalafx.util.Duration
|
||||
|
||||
@@ -5,7 +5,7 @@ import de.knockoutwhist.utils.events.{EventListener, SimpleEvent}
|
||||
|
||||
object DelayHandler extends EventListener {
|
||||
|
||||
private[knockoutwhist] var activateDelay: Boolean = true
|
||||
private[knockoutwhist] var activateDelay: Boolean = false
|
||||
|
||||
override def listen(event: SimpleEvent): Unit = {
|
||||
event match {
|
||||
|
||||
Reference in New Issue
Block a user