PlayedCards implemented
Some checks failed
Build and Test (KnockOutWhist) TeamCity build failed

This commit is contained in:
2024-12-13 09:33:59 +01:00
parent 4e43e25437
commit c3dcca6bde
3 changed files with 41 additions and 25 deletions

View File

@@ -73,6 +73,11 @@ object GUIMain extends JFXApp3 with EventListener with UI {
stage.show()
platformReady = true
}
override def stopApp(): Unit = {
System.exit(0)
}
}
object GUIThread extends CustomThread {

View File

@@ -124,11 +124,11 @@ object Game {
def updateStatus(player: AbstractPlayer): Unit = {
statusLabel.text = s"It's ${player.name}s turn:"
}
def visibilityPlayerCards(visible: Boolean): Unit = {
playerCards.visible = visible
}
def updatePlayerCards(hand: Hand): Unit = {
val cards = ListBuffer[Node]()
for (card <- hand.cards) {
@@ -148,29 +148,35 @@ object Game {
}
playerCards.children = cards
}
def visibilityPlayedCards(visible: Boolean): Unit = {
playedCards.visible = visible
}
def updatePlayedCards(trick: Trick): Unit = {
val cards = ListBuffer[Node]()
for (card <- trick.cards) {
cards += new VBox {
children = new ImageView {
children = Seq(
new Label {
text = card._2.toString
font = Font.font(10)
margin = Insets(0, 0, 0, 0)
},
new ImageView {
alignmentInParent = BottomCenter
image = CardUtils.cardtoImage(card._1)
fitWidth = 102
fitHeight = 150
onMouseClicked = _ => System.exit(0)
}
})
}
}
playedCards.children = cards
}
def matchcard(card: Card): Boolean = {
true

View File

@@ -1,7 +1,9 @@
package de.knockoutwhist.ui.gui
import atlantafx.base.theme.Styles
import de.knockoutwhist.control.{ControlThread, MainLogic}
import de.knockoutwhist.control.{ControlHandler, ControlThread, MainLogic}
import de.knockoutwhist.events.ui.GameState.MAIN_MENU
import de.knockoutwhist.events.ui.GameStateUpdateEvent
import de.knockoutwhist.player.Playertype.HUMAN
import de.knockoutwhist.player.{AbstractPlayer, PlayerFactory}
import de.knockoutwhist.ui.tui.TUIMain
@@ -103,7 +105,9 @@ object MainMenu {
fitHeight = 20
}
onMouseClicked = _ => {
createMainMenu
ControlThread.runLater {
ControlHandler.invoke(GameStateUpdateEvent(MAIN_MENU))
}
}
},
new Button {
@@ -147,8 +151,12 @@ object MainMenu {
maxWidth = 450
maxHeight = 30
value.onChange((_, oldvalue, newvalue) => {
players.children.clear()
for (i <- 1 to newvalue.intValue()) {
if(oldvalue.intValue() > newvalue.intValue()) {
for (i <- oldvalue.intValue()-1 to(newvalue.intValue(), -1)) {
players.children.remove(i)
}
}else if(oldvalue.intValue() < newvalue.intValue()) {
for (i <- oldvalue.intValue() + 1 to newvalue.intValue()) {
players.children.add(new TextField {
promptText = s"Enter Player $i"
visible = true
@@ -156,23 +164,20 @@ object MainMenu {
maxHeight = 30
})
}
}
})
},
players
// new VBox {
// alignment = BottomCenter
// spacing = 20
// margin = Insets(0, 0, 50, 0)
// for (i <- 1 to 5) {
// children.add(new TextField {
// promptText = "Enter Player 1"
// visible = true
// })
// }
// }
)
for (i <- 1 to 2) {
players.children.add(new TextField {
promptText = s"Enter Player $i"
visible = true
maxWidth = 450
maxHeight = 30
})
}
})
}