summaryrefslogtreecommitdiff
path: root/sw-engine/src/main/kotlin/org
diff options
context:
space:
mode:
authorJoffrey Bion <joffrey.bion@booking.com>2020-05-05 17:43:41 +0200
committerJoffrey Bion <joffrey.bion@booking.com>2020-05-12 09:15:07 +0200
commit47b33a1f3726a5b0ce9c60ec843ee66ee3689104 (patch)
treef3cb3541a9346cea44b9075b9fa610b094466233 /sw-engine/src/main/kotlin/org
parentMove tests to their proper place (diff)
downloadseven-wonders-47b33a1f3726a5b0ce9c60ec843ee66ee3689104.tar.gz
seven-wonders-47b33a1f3726a5b0ce9c60ec843ee66ee3689104.tar.bz2
seven-wonders-47b33a1f3726a5b0ce9c60ec843ee66ee3689104.zip
Move score to common model (to enable passing it to client)
Diffstat (limited to 'sw-engine/src/main/kotlin/org')
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/Game.kt5
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/boards/Board.kt4
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/score/Score.kt23
3 files changed, 5 insertions, 27 deletions
diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/Game.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/Game.kt
index 25f1de6d..c6c6c546 100644
--- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/Game.kt
+++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/Game.kt
@@ -12,7 +12,7 @@ import org.luxons.sevenwonders.engine.data.LAST_AGE
import org.luxons.sevenwonders.engine.effects.SpecialAbility
import org.luxons.sevenwonders.engine.moves.Move
import org.luxons.sevenwonders.engine.moves.resolve
-import org.luxons.sevenwonders.engine.score.ScoreBoard
+import org.luxons.sevenwonders.model.score.ScoreBoard
import org.luxons.sevenwonders.model.Action
import org.luxons.sevenwonders.model.TableState
import org.luxons.sevenwonders.model.PlayerMove
@@ -184,7 +184,8 @@ class Game internal constructor(
/**
* Computes the score for all players.
*/
- fun computeScore(): ScoreBoard = ScoreBoard(table.boards.map { it.computeScore(players[it.playerIndex]) })
+ fun computeScore(): ScoreBoard =
+ ScoreBoard(table.boards.map { it.computeScore(players[it.playerIndex]) }.sortedDescending())
private class MissingPreparedMoveException(playerIndex: Int) :
IllegalStateException("Player $playerIndex has not prepared his move")
diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/boards/Board.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/boards/Board.kt
index a98da0bf..dc02b080 100644
--- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/boards/Board.kt
+++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/boards/Board.kt
@@ -7,11 +7,11 @@ import org.luxons.sevenwonders.engine.effects.SpecialAbility
import org.luxons.sevenwonders.engine.resources.Production
import org.luxons.sevenwonders.engine.resources.TradingRules
import org.luxons.sevenwonders.engine.resources.mutableResourcesOf
-import org.luxons.sevenwonders.engine.score.PlayerScore
-import org.luxons.sevenwonders.engine.score.ScoreCategory
import org.luxons.sevenwonders.engine.wonders.Wonder
import org.luxons.sevenwonders.model.Age
import org.luxons.sevenwonders.model.cards.Color
+import org.luxons.sevenwonders.model.score.PlayerScore
+import org.luxons.sevenwonders.model.score.ScoreCategory
internal class Board(val wonder: Wonder, val playerIndex: Int, settings: Settings) {
diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/score/Score.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/score/Score.kt
deleted file mode 100644
index 4da27a59..00000000
--- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/score/Score.kt
+++ /dev/null
@@ -1,23 +0,0 @@
-package org.luxons.sevenwonders.engine.score
-
-class ScoreBoard(scores: Collection<PlayerScore>) {
-
- val scores: Collection<PlayerScore> = scores.sortedDescending()
-}
-
-data class PlayerScore(val boardGold: Int, val pointsByCategory: Map<ScoreCategory, Int>) : Comparable<PlayerScore> {
-
- val totalPoints = pointsByCategory.map { it.value }.sum()
-
- override fun compareTo(other: PlayerScore) = compareValuesBy(this, other, { it.totalPoints }, { it.boardGold })
-}
-
-enum class ScoreCategory {
- CIVIL,
- SCIENCE,
- MILITARY,
- TRADE,
- GUILD,
- WONDER,
- GOLD
-}
bgstack15