added PickTrumpsuit Menu
Some checks failed
Build and Test (KnockOutWhist) TeamCity build failed

This commit is contained in:
LQ63
2024-12-13 11:07:53 +01:00
parent 085002a35a
commit ed8356577c
3 changed files with 157 additions and 6 deletions

View File

@@ -2,8 +2,10 @@ package de.knockoutwhist.ui.gui
import atlantafx.base.theme.PrimerDark import atlantafx.base.theme.PrimerDark
import de.knockoutwhist.events.PLAYER_STATUS.SHOW_TURN import de.knockoutwhist.events.PLAYER_STATUS.SHOW_TURN
import de.knockoutwhist.events.{ShowGlobalStatus, ShowPlayerStatus} import de.knockoutwhist.events.ROUND_STATUS.WON_ROUND
import de.knockoutwhist.events.directional.RequestPlayersEvent import de.knockoutwhist.events.{ShowGlobalStatus, ShowPlayerStatus, ShowRoundStatus}
import de.knockoutwhist.events.directional.{RequestCardEvent, RequestPickTrumpsuitEvent, RequestPlayersEvent}
import de.knockoutwhist.events.round.ShowCurrentTrickEvent
import de.knockoutwhist.events.ui.GameState.{INGAME, MAIN_MENU} import de.knockoutwhist.events.ui.GameState.{INGAME, MAIN_MENU}
import de.knockoutwhist.events.ui.GameStateUpdateEvent import de.knockoutwhist.events.ui.GameStateUpdateEvent
import de.knockoutwhist.ui.UI import de.knockoutwhist.ui.UI
@@ -43,7 +45,17 @@ object GUIMain extends JFXApp3 with EventListener with UI {
Game.updateStatus(event.player) Game.updateStatus(event.player)
Game.updatePlayerCards(event.player.hand.get) Game.updatePlayerCards(event.player.hand.get)
case _ => case _ =>
case event: ShowCurrentTrickEvent =>
Game.updatePlayedCards(event.trick)
case event: ShowRoundStatus =>
event.status match
case WON_ROUND =>
Game.showWon(event.currentRound)
case _ =>
case event: RequestCardEvent =>
Game.requestCard = Some(event)
case event: RequestPickTrumpsuitEvent =>
PickTrumsuit.showPickTrumpsuit(event)
case event: SimpleEvent => case event: SimpleEvent =>
println(s"Event ${event.id} not handled") println(s"Event ${event.id} not handled")
} }

View File

@@ -191,8 +191,8 @@ object Game {
private[gui] var requestCard: Option[RequestCardEvent] = None private[gui] var requestCard: Option[RequestCardEvent] = None
def showWon(round: Round): Unit = {
def matchcard(card: Card): Boolean = { val playerwon = round.winner
true statusLabel.text = s"${playerwon.name} won the round!"
} }
} }

View File

@@ -0,0 +1,139 @@
package de.knockoutwhist.ui.gui
import de.knockoutwhist.cards.Suit
import de.knockoutwhist.control.{ControlHandler, ControlThread, PlayerLogic}
import de.knockoutwhist.events.directional.RequestPickTrumpsuitEvent
import de.knockoutwhist.events.ui.GameState.{INGAME, MAIN_MENU}
import de.knockoutwhist.events.ui.GameStateUpdateEvent
import de.knockoutwhist.utils.gui.Animations
import scalafx.geometry.Insets
import scalafx.geometry.Pos.{BottomCenter, TopCenter}
import scalafx.scene.control.Label
import scalafx.scene.image.{Image, ImageView}
import scalafx.scene.layout.Priority.Always
import scalafx.scene.layout.{HBox, StackPane, VBox}
import scalafx.scene.text.Font
import scalafx.util.Duration
import scala.util.Try
object PickTrumsuit {
def showPickTrumpsuit(event: RequestPickTrumpsuitEvent): Unit = {
MainMenu.changeChild(
new StackPane {
children = Seq(
new VBox {
alignment = TopCenter
spacing = 10
margin = Insets(20, 0, 0, 0)
hgrow = Always
children = Seq(
new Label {
alignment = TopCenter
text = "Pick your trumpsuit"
font = Font.font(30)
},
new HBox {
alignment = BottomCenter
spacing = 10
margin = Insets(200, 0, 20, 0)
children = Seq(
new ImageView {
alignment = BottomCenter
image = new Image("cards/AS.png")
fitWidth = 170
fitHeight = 250
onMouseClicked = _ => {
val slideOut = Animations.slideOutUp(children.head.asInstanceOf[javafx.scene.image.ImageView], Duration(400), -350)
slideOut.onFinished = _ => {
visible = false
}
slideOut.play()
ControlThread.runLater {
PlayerLogic.trumpSuitSelected(event.matchImpl, Try {
Suit.Spades
}, event.remaining_players, event.firstRound, event.player)
}
}
},
new ImageView {
alignment = BottomCenter
image = new Image("cards/AC.png")
fitWidth = 170
fitHeight = 250
onMouseClicked = _ => {
val slideOut = Animations.slideOutUp(children.head.asInstanceOf[javafx.scene.image.ImageView], Duration(400), -350)
slideOut.onFinished = _ => {
visible = false
}
slideOut.play()
ControlThread.runLater {
PlayerLogic.trumpSuitSelected(event.matchImpl, Try {
Suit.Clubs
}, event.remaining_players, event.firstRound, event.player)
}
}
},new ImageView {
alignment = BottomCenter
image = new Image("cards/AH.png")
fitWidth = 170
fitHeight = 250
onMouseClicked = _ => {
val slideOut = Animations.slideOutUp(children.head.asInstanceOf[javafx.scene.image.ImageView], Duration(400), -350)
slideOut.onFinished = _ => {
visible = false
}
slideOut.play()
ControlThread.runLater {
PlayerLogic.trumpSuitSelected(event.matchImpl, Try {
Suit.Hearts
}, event.remaining_players, event.firstRound, event.player)
}
}
},
new ImageView {
alignment = BottomCenter
image = new Image("cards/AD.png")
fitWidth = 170
fitHeight = 250
onMouseClicked = _ => {
val slideOut = Animations.slideOutUp(children.head.asInstanceOf[javafx.scene.image.ImageView], Duration(400), -350)
slideOut.onFinished = _ => {
visible = false
}
slideOut.play()
ControlThread.runLater {
PlayerLogic.trumpSuitSelected(event.matchImpl, Try{Suit.Diamonds}, event.remaining_players, event.firstRound, event.player)
}
}
},
)
},
new Label {
alignment = TopCenter
text = "Your Cards"
font = Font.font(20)
},
new HBox {
alignment = TopCenter
alignment = BottomCenter
spacing = 10
margin = Insets(200, 0, 20, 0)
children = event.player.currentHand().get.cards.map( i => new ImageView {
image = CardUtils.cardtoImage(i)
fitWidth = 170
fitHeight = 250
})
}
)
},
)
})
}
}