summaryrefslogtreecommitdiff
path: root/sw-engine
diff options
context:
space:
mode:
Diffstat (limited to 'sw-engine')
-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/boards/Science.kt2
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/converters/Boards.kt2
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/effects/BonusPerBoardElement.kt2
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/effects/SpecialAbility.kt2
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/resources/TradingRules.kt2
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/wonders/Wonder.kt2
-rw-r--r--sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/effects/SpecialAbilityActivationTest.kt2
8 files changed, 9 insertions, 9 deletions
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 2fb5e36c..e1160e38 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
@@ -94,11 +94,11 @@ internal class Board(
)
private fun computePointsForCards(player: Player, color: Color): Int =
- playedCards.filter { it.color === color }.flatMap { it.effects }.sumBy { it.computePoints(player) }
+ playedCards.filter { it.color === color }.flatMap { it.effects }.sumOf { it.computePoints(player) }
private fun copiedGuildPoints(player: Player): Int = copiedGuild?.computePoints(player) ?: 0
- private fun Card.computePoints(player: Player): Int = effects.sumBy { it.computePoints(player) }
+ private fun Card.computePoints(player: Player): Int = effects.sumOf { it.computePoints(player) }
private fun computeGoldPoints(): Int = gold / 3 * pointsPer3Gold
diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/boards/Science.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/boards/Science.kt
index 681f1c27..1c599616 100644
--- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/boards/Science.kt
+++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/boards/Science.kt
@@ -49,7 +49,7 @@ internal class Science {
}
private fun computePointsNoJoker(values: List<Int>): Int {
- val independentSquaresSum = values.sumBy { it * it }
+ val independentSquaresSum = values.sumOf { it * it }
val nbGroupsOfAll = values.minOrNull() ?: 0
return independentSquaresSum + nbGroupsOfAll * 7
}
diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/converters/Boards.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/converters/Boards.kt
index 2ddce8a8..0ca331e7 100644
--- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/converters/Boards.kt
+++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/converters/Boards.kt
@@ -36,7 +36,7 @@ internal fun InternalBoard.toApiBoard(player: Player, lastMove: Move?, currentAg
gold = gold,
bluePoints = getPlayedCards().filter { it.color == Color.BLUE }
.flatMap { it.effects.filterIsInstance<RawPointsIncrease>() }
- .sumBy { it.points },
+ .sumOf { it.points },
canPlayAnyCardForFree = canPlayFreeCard(currentAge),
)
diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/effects/BonusPerBoardElement.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/effects/BonusPerBoardElement.kt
index 6f1cee51..4c2bbb24 100644
--- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/effects/BonusPerBoardElement.kt
+++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/effects/BonusPerBoardElement.kt
@@ -25,7 +25,7 @@ internal data class BonusPerBoardElement(
override fun computePoints(player: Player): Int = points * nbMatchingElementsFor(player)
- private fun nbMatchingElementsFor(player: Player): Int = boards.sumBy { nbMatchingElementsIn(player.getBoard(it)) }
+ private fun nbMatchingElementsFor(player: Player): Int = boards.sumOf { nbMatchingElementsIn(player.getBoard(it)) }
private fun nbMatchingElementsIn(board: Board): Int = when (type) {
BoardElementType.CARD -> board.getNbCardsOfColor(colors!!)
diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/effects/SpecialAbility.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/effects/SpecialAbility.kt
index 82c23a72..746e61c3 100644
--- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/effects/SpecialAbility.kt
+++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/effects/SpecialAbility.kt
@@ -28,7 +28,7 @@ enum class SpecialAbility {
COPY_GUILD {
override fun computePoints(player: Player): Int {
// there can be no copiedGuild if no neighbour had any guild cards
- return player.board.copiedGuild?.effects?.sumBy { it.computePoints(player) } ?: 0
+ return player.board.copiedGuild?.effects?.sumOf { it.computePoints(player) } ?: 0
}
};
diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/resources/TradingRules.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/resources/TradingRules.kt
index bee4b9fe..2e5f7d51 100644
--- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/resources/TradingRules.kt
+++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/resources/TradingRules.kt
@@ -20,7 +20,7 @@ internal class TradingRules(private val defaultCost: Int) {
costs.computeIfAbsent(type) { mutableMapOf() }[provider] = cost
}
- internal fun computeCost(transactions: ResourceTransactions): Int = transactions.sumBy { computeCost(it) }
+ internal fun computeCost(transactions: ResourceTransactions): Int = transactions.sumOf { computeCost(it) }
internal fun computeCost(transact: ResourceTransaction) = computeCost(transact.asResources(), transact.provider)
diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/wonders/Wonder.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/wonders/Wonder.kt
index 03ed2f8f..610a9e6f 100644
--- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/wonders/Wonder.kt
+++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/wonders/Wonder.kt
@@ -46,7 +46,7 @@ internal class Wonder(
lastBuiltStage!!.activate(player, boughtResources)
fun computePoints(player: Player): Int =
- stages.filter { it.isBuilt }.flatMap { it.effects }.sumBy { it.computePoints(player) }
+ stages.filter { it.isBuilt }.flatMap { it.effects }.sumOf { it.computePoints(player) }
}
private object Buildability {
diff --git a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/effects/SpecialAbilityActivationTest.kt b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/effects/SpecialAbilityActivationTest.kt
index 978be53b..da2d7faf 100644
--- a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/effects/SpecialAbilityActivationTest.kt
+++ b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/effects/SpecialAbilityActivationTest.kt
@@ -48,7 +48,7 @@ class SpecialAbilityActivationTest {
player.board.copiedGuild = guildCard
- val directPointsFromGuildCard = guildCard.effects.sumBy { it.computePoints(player) }
+ val directPointsFromGuildCard = guildCard.effects.sumOf { it.computePoints(player) }
assertEquals(directPointsFromGuildCard, effect.computePoints(player))
}
bgstack15