Modified Ternary Operator
Some checks failed
Build and Test (KnockOutWhist) TeamCity build failed

This commit is contained in:
2024-11-02 10:49:46 +01:00
parent 7f97779579
commit 7bf77d5d26
2 changed files with 6 additions and 6 deletions

View File

@@ -13,7 +13,7 @@ case class Match(totalplayers: List[Player], private[rounds] var number_of_cards
private[rounds] var dogLife = false
def create_round(): Round = {
val remainingPlayer = (roundlist.isEmpty ? totalplayers |: roundlist.last.remainingPlayers()).toOption.get
val remainingPlayer = roundlist.isEmpty ? totalplayers |: roundlist.last.remainingPlayers()
provideCards(remainingPlayer)
if (roundlist.isEmpty) {
val random_trumpsuit = CardManager.nextCard().suit

View File

@@ -3,18 +3,18 @@ package de.knockoutwhist.utils
import scala.annotation.targetName
object Implicits {
implicit class Ternable(condition: Boolean) {
def ?[T](ifTrue: => T): Option[T] = {
if (condition) Some(ifTrue) else None
}
}
implicit class Colonable[T, F](ifFalse: => F) {
def |:(intermediate: Option[T]): Either[T, F] =
implicit class Colonable[T](ifFalse: => T) {
def |:(intermediate: Option[T]): T =
intermediate match {
case Some(ifTrue) => Left(ifTrue)
case None => Right(ifFalse)
case Some(ifTrue) => ifTrue
case None => ifFalse
}
}