Files
KnockOutWhist/src/main/scala/de/knockoutwhist/undo/commands/SelectTrumpSuitCommand.scala
Janis c5895f094b fix(base): fixed persistence logic (#48)
Fixed persistence logic for Trump Selection and Save File Loading

Reviewed-on: #48
Co-authored-by: Janis <janis.e.20@gmx.de>
Co-committed-by: Janis <janis.e.20@gmx.de>
2025-10-26 18:03:20 +01:00

33 lines
1.0 KiB
Scala

package de.knockoutwhist.undo.commands
import de.knockoutwhist.cards.Suit
import de.knockoutwhist.control.sublogic.PlayerTieLogic
import de.knockoutwhist.control.{ControlThread, GameLogic, LogicSnapshot}
import de.knockoutwhist.undo.Command
case class SelectTrumpSuitCommand[
GL <: GameLogic,
PT <: PlayerTieLogic
] (
gameLogicSnapshot: LogicSnapshot[? <: GL],
playerTieLogicSnapShot: LogicSnapshot[? <: PT],
suit: Suit
) extends Command {
override def doStep(gameLogic: GameLogic): Unit = {
ControlThread.runLater {
gameLogic.playerInputLogic.receivedTrumpSuit(suit)
}
}
override def undoStep(gameLogic: GameLogic): Unit = {
val glSnapshot = gameLogicSnapshot.asInstanceOf[LogicSnapshot[GL]]
val ptlSnapshot = playerTieLogicSnapShot.asInstanceOf[LogicSnapshot[PT]]
glSnapshot.restore(gameLogic.asInstanceOf[GL])
ptlSnapshot.restore(gameLogic.playerTieLogic.asInstanceOf[PT])
ControlThread.runLater {
gameLogic.controlPreRound()
}
}
}