Added link to click for player pov, started rendering with images
@@ -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
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
33
knockoutwhistweb/app/util/WebUIUtils.scala
Normal 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")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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>
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
knockoutwhistweb/public/images/cards/1B.png
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
BIN
knockoutwhistweb/public/images/cards/1J.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
knockoutwhistweb/public/images/cards/2B.png
Normal file
|
After Width: | Height: | Size: 4.0 KiB |
BIN
knockoutwhistweb/public/images/cards/2C.png
Normal file
|
After Width: | Height: | Size: 8.4 KiB |
BIN
knockoutwhistweb/public/images/cards/2D.png
Normal file
|
After Width: | Height: | Size: 6.2 KiB |
BIN
knockoutwhistweb/public/images/cards/2H.png
Normal file
|
After Width: | Height: | Size: 6.5 KiB |
BIN
knockoutwhistweb/public/images/cards/2J.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
knockoutwhistweb/public/images/cards/2S.png
Normal file
|
After Width: | Height: | Size: 7.7 KiB |
BIN
knockoutwhistweb/public/images/cards/3C.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
knockoutwhistweb/public/images/cards/3D.png
Normal file
|
After Width: | Height: | Size: 7.3 KiB |
BIN
knockoutwhistweb/public/images/cards/3H.png
Normal file
|
After Width: | Height: | Size: 7.6 KiB |
BIN
knockoutwhistweb/public/images/cards/3S.png
Normal file
|
After Width: | Height: | Size: 9.1 KiB |
BIN
knockoutwhistweb/public/images/cards/4C.png
Normal file
|
After Width: | Height: | Size: 9.1 KiB |
BIN
knockoutwhistweb/public/images/cards/4D.png
Normal file
|
After Width: | Height: | Size: 6.6 KiB |
BIN
knockoutwhistweb/public/images/cards/4H.png
Normal file
|
After Width: | Height: | Size: 7.0 KiB |
BIN
knockoutwhistweb/public/images/cards/4S.png
Normal file
|
After Width: | Height: | Size: 8.6 KiB |
BIN
knockoutwhistweb/public/images/cards/5C.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
knockoutwhistweb/public/images/cards/5D.png
Normal file
|
After Width: | Height: | Size: 7.9 KiB |
BIN
knockoutwhistweb/public/images/cards/5H.png
Normal file
|
After Width: | Height: | Size: 8.4 KiB |
BIN
knockoutwhistweb/public/images/cards/5S.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
knockoutwhistweb/public/images/cards/6C.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
knockoutwhistweb/public/images/cards/6D.png
Normal file
|
After Width: | Height: | Size: 8.6 KiB |
BIN
knockoutwhistweb/public/images/cards/6H.png
Normal file
|
After Width: | Height: | Size: 9.2 KiB |
BIN
knockoutwhistweb/public/images/cards/6S.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
knockoutwhistweb/public/images/cards/7C.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
knockoutwhistweb/public/images/cards/7D.png
Normal file
|
After Width: | Height: | Size: 9.0 KiB |
BIN
knockoutwhistweb/public/images/cards/7H.png
Normal file
|
After Width: | Height: | Size: 9.6 KiB |
BIN
knockoutwhistweb/public/images/cards/7S.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
knockoutwhistweb/public/images/cards/8C.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
knockoutwhistweb/public/images/cards/8D.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
knockoutwhistweb/public/images/cards/8H.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
knockoutwhistweb/public/images/cards/8S.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
knockoutwhistweb/public/images/cards/9C.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
knockoutwhistweb/public/images/cards/9D.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
knockoutwhistweb/public/images/cards/9H.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
knockoutwhistweb/public/images/cards/9S.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
knockoutwhistweb/public/images/cards/AC.png
Normal file
|
After Width: | Height: | Size: 6.6 KiB |
BIN
knockoutwhistweb/public/images/cards/ACB.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
knockoutwhistweb/public/images/cards/AD.png
Normal file
|
After Width: | Height: | Size: 5.2 KiB |
BIN
knockoutwhistweb/public/images/cards/ADB.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
knockoutwhistweb/public/images/cards/AH.png
Normal file
|
After Width: | Height: | Size: 5.3 KiB |
BIN
knockoutwhistweb/public/images/cards/AHB.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
knockoutwhistweb/public/images/cards/AS.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
knockoutwhistweb/public/images/cards/ASB.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
knockoutwhistweb/public/images/cards/JC.png
Normal file
|
After Width: | Height: | Size: 68 KiB |
BIN
knockoutwhistweb/public/images/cards/JD.png
Normal file
|
After Width: | Height: | Size: 72 KiB |
BIN
knockoutwhistweb/public/images/cards/JH.png
Normal file
|
After Width: | Height: | Size: 66 KiB |
BIN
knockoutwhistweb/public/images/cards/JS.png
Normal file
|
After Width: | Height: | Size: 67 KiB |
BIN
knockoutwhistweb/public/images/cards/KC.png
Normal file
|
After Width: | Height: | Size: 60 KiB |
BIN
knockoutwhistweb/public/images/cards/KD.png
Normal file
|
After Width: | Height: | Size: 61 KiB |
BIN
knockoutwhistweb/public/images/cards/KH.png
Normal file
|
After Width: | Height: | Size: 68 KiB |
BIN
knockoutwhistweb/public/images/cards/KS.png
Normal file
|
After Width: | Height: | Size: 68 KiB |
BIN
knockoutwhistweb/public/images/cards/QC.png
Normal file
|
After Width: | Height: | Size: 64 KiB |
BIN
knockoutwhistweb/public/images/cards/QD.png
Normal file
|
After Width: | Height: | Size: 73 KiB |
BIN
knockoutwhistweb/public/images/cards/QH.png
Normal file
|
After Width: | Height: | Size: 73 KiB |
BIN
knockoutwhistweb/public/images/cards/QS.png
Normal file
|
After Width: | Height: | Size: 72 KiB |
BIN
knockoutwhistweb/public/images/cards/TC.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
knockoutwhistweb/public/images/cards/TD.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
knockoutwhistweb/public/images/cards/TH.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
knockoutwhistweb/public/images/cards/TS.png
Normal file
|
After Width: | Height: | Size: 14 KiB |