From d72b60390dd9c75a91bb21f413f7b59fb8ef8d51 Mon Sep 17 00:00:00 2001 From: jbion Date: Mon, 18 Feb 2019 17:04:59 +0100 Subject: Reduce visibility where appropriate --- .../main/kotlin/org/luxons/sevenwonders/game/api/Table.kt | 5 +++-- .../kotlin/org/luxons/sevenwonders/game/boards/Board.kt | 14 ++++++++------ .../kotlin/org/luxons/sevenwonders/game/boards/Military.kt | 6 +++--- .../kotlin/org/luxons/sevenwonders/game/cards/Cards.kt | 2 +- .../org/luxons/sevenwonders/game/resources/Resources.kt | 2 +- 5 files changed, 16 insertions(+), 13 deletions(-) (limited to 'game-engine/src') diff --git a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/api/Table.kt b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/api/Table.kt index 9775b5ee..c4dbeb21 100644 --- a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/api/Table.kt +++ b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/api/Table.kt @@ -24,10 +24,11 @@ class Table internal constructor(val boards: List) { get() = HandRotationDirection.forAge(currentAge) var lastPlayedMoves: List = emptyList() + internal set - fun getBoard(playerIndex: Int): Board = boards[playerIndex] + internal fun getBoard(playerIndex: Int): Board = boards[playerIndex] - fun getBoard(playerIndex: Int, position: RelativeBoardPosition): Board = + internal fun getBoard(playerIndex: Int, position: RelativeBoardPosition): Board = boards[position.getIndexFrom(playerIndex, nbPlayers)] internal fun increaseCurrentAge() { diff --git a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/boards/Board.kt b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/boards/Board.kt index 64db9f41..00de0239 100644 --- a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/boards/Board.kt +++ b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/boards/Board.kt @@ -26,9 +26,10 @@ class Board internal constructor(val wonder: Wonder, val playerIndex: Int, setti private val consumedFreeCards: MutableMap = mutableMapOf() var gold: Int = settings.initialGold + private set var copiedGuild: Card? = null - set(copiedGuild) { + internal set(copiedGuild) { if (copiedGuild!!.color !== Color.PURPLE) { throw IllegalArgumentException("The given card '$copiedGuild' is not a Guild card") } @@ -42,7 +43,7 @@ class Board internal constructor(val wonder: Wonder, val playerIndex: Int, setti fun getPlayedCards(): List = playedCards - fun addCard(card: Card) { + internal fun addCard(card: Card) { playedCards.add(card) } @@ -50,18 +51,18 @@ class Board internal constructor(val wonder: Wonder, val playerIndex: Int, setti fun isPlayed(cardName: String): Boolean = playedCards.count { it.name == cardName } > 0 - fun addGold(amount: Int) { + internal fun addGold(amount: Int) { this.gold += amount } - fun removeGold(amount: Int) { + internal fun removeGold(amount: Int) { if (gold < amount) { throw InsufficientFundsException(gold, amount) } this.gold -= amount } - fun addSpecial(specialAbility: SpecialAbility) { + internal fun addSpecial(specialAbility: SpecialAbility) { specialAbilities.add(specialAbility) } @@ -75,7 +76,8 @@ class Board internal constructor(val wonder: Wonder, val playerIndex: Int, setti } internal fun computeScore(player: Player): PlayerScore = PlayerScore( - gold, mapOf( + boardGold = gold, + pointsByCategory = mapOf( ScoreCategory.CIVIL to computePointsForCards(player, Color.BLUE), ScoreCategory.MILITARY to military.totalPoints, ScoreCategory.SCIENCE to science.computePoints(), diff --git a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/boards/Military.kt b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/boards/Military.kt index c00d1ace..593716fd 100644 --- a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/boards/Military.kt +++ b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/boards/Military.kt @@ -15,16 +15,16 @@ class Military internal constructor( var nbDefeatTokens = 0 private set - fun addShields(nbShields: Int) { + internal fun addShields(nbShields: Int) { this.nbShields += nbShields } - fun victory(age: Age) { + internal fun victory(age: Age) { val wonPoints = wonPointsPerVictoryPerAge[age] ?: throw UnknownAgeException(age) totalPoints += wonPoints } - fun defeat() { + internal fun defeat() { totalPoints -= lostPointsPerDefeat nbDefeatTokens++ } diff --git a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/cards/Cards.kt b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/cards/Cards.kt index 56dc7077..83865c74 100644 --- a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/cards/Cards.kt +++ b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/cards/Cards.kt @@ -11,7 +11,7 @@ data class Card internal constructor( val name: String, val color: Color, val requirements: Requirements, - val effects: List, + internal val effects: List, val chainParent: String?, val chainChildren: List, val image: String, diff --git a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/resources/Resources.kt b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/resources/Resources.kt index 476ffea8..333c8edb 100644 --- a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/resources/Resources.kt +++ b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/resources/Resources.kt @@ -62,7 +62,7 @@ interface Resources { fun toList(): List = quantities.flatMap { (type, quantity) -> List(quantity) { type } } } -data class MutableResources( +internal data class MutableResources( override val quantities: MutableMap = mutableMapOf() ) : Resources { -- cgit