diff options
Diffstat (limited to 'sw-engine')
4 files changed, 9 insertions, 31 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 -} diff --git a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/boards/BoardTest.kt b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/boards/BoardTest.kt index 0b514e5f..165fbaa1 100644 --- a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/boards/BoardTest.kt +++ b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/boards/BoardTest.kt @@ -9,13 +9,10 @@ import org.junit.experimental.theories.Theories import org.junit.experimental.theories.Theory import org.junit.runner.RunWith import org.luxons.sevenwonders.engine.boards.Board.InsufficientFundsException -import org.luxons.sevenwonders.model.cards.Color import org.luxons.sevenwonders.engine.effects.RawPointsIncrease import org.luxons.sevenwonders.engine.effects.SpecialAbility import org.luxons.sevenwonders.engine.effects.SpecialAbilityActivation -import org.luxons.sevenwonders.model.resources.ResourceType import org.luxons.sevenwonders.engine.resources.resourcesOf -import org.luxons.sevenwonders.engine.score.ScoreCategory import org.luxons.sevenwonders.engine.test.addCards import org.luxons.sevenwonders.engine.test.getDifferentColorFrom import org.luxons.sevenwonders.engine.test.playCardWithEffect @@ -24,6 +21,9 @@ import org.luxons.sevenwonders.engine.test.testBoard import org.luxons.sevenwonders.engine.test.testCard import org.luxons.sevenwonders.engine.test.testSettings import org.luxons.sevenwonders.engine.test.testWonder +import org.luxons.sevenwonders.model.cards.Color +import org.luxons.sevenwonders.model.resources.ResourceType +import org.luxons.sevenwonders.model.score.ScoreCategory import kotlin.test.assertFailsWith import kotlin.test.assertFalse import kotlin.test.assertSame @@ -173,7 +173,7 @@ class BoardTest { } @Theory - fun computePoints_(@FromDataPoints("gold") gold: Int) { + fun computePoints_goldAndPoints(@FromDataPoints("gold") gold: Int) { assumeTrue(gold >= 0) val board = testBoard(initialGold = gold) |