Added link to click for player pov, started rendering with images

This commit is contained in:
LQ63
2025-10-13 22:39:21 +02:00
parent 2b89f3d161
commit 9aa447f2f6
64 changed files with 59 additions and 23 deletions

View File

@@ -1,7 +1,7 @@
package components package components
import controllers.WebUI
import de.knockoutwhist.components.DefaultConfiguration import de.knockoutwhist.components.DefaultConfiguration
import controllers.WebUI
import de.knockoutwhist.ui.UI import de.knockoutwhist.ui.UI
import de.knockoutwhist.utils.events.EventListener import de.knockoutwhist.utils.events.EventListener

View File

@@ -10,6 +10,8 @@ import de.knockoutwhist.events.cards.{RenderHandEvent, ShowTieCardsEvent}
import de.knockoutwhist.events.round.ShowCurrentTrickEvent import de.knockoutwhist.events.round.ShowCurrentTrickEvent
import de.knockoutwhist.player.AbstractPlayer import de.knockoutwhist.player.AbstractPlayer
import de.knockoutwhist.utils.events.SimpleEvent import de.knockoutwhist.utils.events.SimpleEvent
import scalafx.scene.image.Image
import util.WebUIUtils
import java.util.UUID import java.util.UUID
@@ -17,6 +19,7 @@ case class SimpleSession(id: UUID, private var output: String) extends PlayerSes
def get(): String = { def get(): String = {
output output
} }
override def updatePlayer(event: SimpleEvent): Unit = { override def updatePlayer(event: SimpleEvent): Unit = {
event match { event match {
case event: RenderHandEvent => case event: RenderHandEvent =>
@@ -41,7 +44,7 @@ case class SimpleSession(id: UUID, private var output: String) extends PlayerSes
} }
private def renderHand(event: RenderHandEvent): Unit = { private def renderHand(event: RenderHandEvent): Unit = {
WebUICards.renderHandEvent(event.hand, event.showNumbers).foreach(addToOutput) output += WebUICards.renderHandEvent(event.hand, event.showNumbers).map(_.toString).mkString
} }
private def showtiecardseventmethod(event: ShowTieCardsEvent): Option[Boolean] = { private def showtiecardseventmethod(event: ShowTieCardsEvent): Option[Boolean] = {
@@ -49,14 +52,14 @@ case class SimpleSession(id: UUID, private var output: String) extends PlayerSes
for ((player, card) <- event.card) { for ((player, card) <- event.card) {
val playerNameLength = player.name.length val playerNameLength = player.name.length
a(0) += " " + player.name + ":" + (" " * (playerNameLength - 1)) a(0) += " " + player.name + ":" + (" " * (playerNameLength - 1))
val rendered = WebUICards.renderCardAsString(card) val rendered = WebUIUtils.cardtoImage(card)
a(1) += " " + rendered(0) //a(1) += " " + rendered(0)
a(2) += " " + rendered(1) //a(2) += " " + rendered(1)
a(3) += " " + rendered(2) //a(3) += " " + rendered(2)
a(4) += " " + rendered(3) //a(4) += " " + rendered(3)
a(5) += " " + rendered(4) //a(5) += " " + rendered(4)
a(6) += " " + rendered(5) //a(6) += " " + rendered(5)
a(7) += " " + rendered(6) //a(7) += " " + rendered(6)
} }
a.foreach(addToOutput) a.foreach(addToOutput)
Some(true) Some(true)
@@ -253,16 +256,16 @@ case class SimpleSession(id: UUID, private var output: String) extends PlayerSes
) )
} }
def renderHandEvent(hand: Hand, showNumbers: Boolean): Vector[String] = { def renderHandEvent(hand: Hand, showNumbers: Boolean): List[Image] = {
val cardStrings = hand.cards.map(renderCardAsString) hand.cards.map(WebUIUtils.cardtoImage)
var zipped = cardStrings.transpose //var zipped = cardStrings.transpose
if (showNumbers) zipped = { //if (showNumbers) zipped = {
List.tabulate(hand.cards.length) { i => // List.tabulate(hand.cards.length) { i =>
s" ${i + 1} " // s" ${i + 1} "
} // }
} :: zipped // } :: zipped
zipped.map(_.mkString(" ")).toVector // zipped.map(_.mkString(" ")).toVector
// }
} }
} }
} }

View File

@@ -0,0 +1,33 @@
package util
import de.knockoutwhist.cards.Card
import de.knockoutwhist.cards.CardValue.{Ace, Eight, Five, Four, Jack, King, Nine, Queen, Seven, Six, Ten, Three, Two}
import de.knockoutwhist.cards.Suit.{Clubs, Diamonds, Hearts, Spades}
import scalafx.scene.image.Image
object WebUIUtils {
def cardtoImage(card: Card): Image = {
val s = card.suit match {
case Spades => "S"
case Hearts => "H"
case Clubs => "C"
case Diamonds => "D"
}
val cv = card.cardValue match {
case Ace => "A"
case King => "K"
case Queen => "Q"
case Jack => "J"
case Ten => "T"
case Nine => "9"
case Eight => "8"
case Seven => "7"
case Six => "6"
case Five => "5"
case Four => "4"
case Three => "3"
case Two => "2"
}
new Image(f"public/images/cards/$cv$s.png")
}
}

View File

@@ -3,7 +3,7 @@
@main("Tui") { @main("Tui") {
<div id="tui"> <div id="tui">
@for(line <- toRender.split('\n')) { @for(line <- toRender.split('\n')) {
<p>@line</p> <a href="@routes.Relative.ingame(line)">@line</a>
} }
</div> </div>
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB