Identify hero results by seat
This commit is contained in:
@@ -11,16 +11,19 @@ import com.jsjdesigns.poker.game.HandResult
|
||||
*/
|
||||
data class HandSummary(
|
||||
val handNumber: Int,
|
||||
val winnerNames: List<String>,
|
||||
/** Display labels in the engine's winner order; the human seat is always "You". */
|
||||
val winnerLabels: List<String>,
|
||||
/** Derived from winner seat indices, never from a player-controlled name. */
|
||||
val heroWon: Boolean,
|
||||
val potSize: Int,
|
||||
val heroNet: Int,
|
||||
val wentToShowdown: Boolean,
|
||||
) {
|
||||
val title: String
|
||||
get() = when {
|
||||
winnerNames.size == 1 && winnerNames.single() == "You" -> "You win"
|
||||
winnerNames.size == 1 -> "${winnerNames.single()} wins"
|
||||
else -> "${winnerNames.joinToString(" & ")} win"
|
||||
winnerLabels.size == 1 && heroWon -> "You win"
|
||||
winnerLabels.size == 1 -> "${winnerLabels.single()} wins"
|
||||
else -> "${winnerLabels.joinToString(" & ")} win"
|
||||
}
|
||||
|
||||
val detail: String
|
||||
@@ -47,7 +50,10 @@ fun handSummaryFor(
|
||||
|
||||
return HandSummary(
|
||||
handNumber = handNumber,
|
||||
winnerNames = result.winners.map(seatNames::get),
|
||||
winnerLabels = result.winners.map { winner ->
|
||||
if (winner == heroSeat) "You" else seatNames[winner]
|
||||
},
|
||||
heroWon = heroSeat in result.winners,
|
||||
potSize = result.potSize,
|
||||
heroNet = result.net[heroSeat],
|
||||
wentToShowdown = result.wentToShowdown,
|
||||
|
||||
Reference in New Issue
Block a user