Implement game summary calculation
This commit is contained in:
parent
c9e331a24e
commit
fad1c38b65
|
@ -34,4 +34,9 @@ fun determineOutcome(first: Move, second: Move): Outcome = when {
|
||||||
else -> Outcome.LOSS
|
else -> Outcome.LOSS
|
||||||
}
|
}
|
||||||
|
|
||||||
fun calculateGameSummary(turns: List<Outcome>): GameSummary = TODO()
|
// Note: This would be slightly more efficient (but a lot less elegant) with an imperative loop and three mutable integers.
|
||||||
|
fun calculateGameSummary(turns: List<Outcome>) = GameSummary(
|
||||||
|
wins = turns.count { it == Outcome.WIN },
|
||||||
|
draws = turns.count { it == Outcome.DRAW },
|
||||||
|
losses = turns.count { it == Outcome.LOSS },
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user