diff options
author | joffrey-bion <joffrey.bion@gmail.com> | 2020-11-26 00:44:23 +0100 |
---|---|---|
committer | joffrey-bion <joffrey.bion@gmail.com> | 2020-11-26 00:44:23 +0100 |
commit | d0642d2a98bae64e566a6893174c1a6e95b07b6d (patch) | |
tree | 278903dce2c2ec5b4f70437370ad30ec7139d2aa /sw-engine | |
parent | Fix resource transactions calculations (diff) | |
download | seven-wonders-d0642d2a98bae64e566a6893174c1a6e95b07b6d.tar.gz seven-wonders-d0642d2a98bae64e566a6893174c1a6e95b07b6d.tar.bz2 seven-wonders-d0642d2a98bae64e566a6893174c1a6e95b07b6d.zip |
Distinguish wonder fully built and card already played
Diffstat (limited to 'sw-engine')
-rw-r--r-- | sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/cards/Cards.kt | 8 | ||||
-rw-r--r-- | sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/wonders/Wonder.kt | 6 |
2 files changed, 8 insertions, 6 deletions
diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/cards/Cards.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/cards/Cards.kt index 438798bf..d5468283 100644 --- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/cards/Cards.kt +++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/cards/Cards.kt @@ -21,7 +21,7 @@ internal data class Card( val back: CardBack, ) { fun computePlayabilityBy(player: Player, forceSpecialFree: Boolean = false): CardPlayability = when { - isAlreadyOnBoard(player.board) -> Playability.incompatibleWithBoard() // cannot play twice the same card + isAlreadyOnBoard(player.board) -> Playability.alreadyPlayed() // cannot play twice the same card forceSpecialFree -> Playability.specialFree() isParentOnBoard(player.board) -> Playability.chainable() else -> Playability.requirementDependent(requirements.assess(player)) @@ -46,8 +46,10 @@ internal data class Card( private object Playability { - fun incompatibleWithBoard(): CardPlayability = - CardPlayability(isPlayable = false, playabilityLevel = PlayabilityLevel.INCOMPATIBLE_WITH_BOARD) + fun alreadyPlayed(): CardPlayability = CardPlayability( + isPlayable = false, + playabilityLevel = PlayabilityLevel.ALREADY_PLAYED, + ) fun chainable(): CardPlayability = CardPlayability( isPlayable = true, 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 81c23160..4a99b9e9 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 @@ -31,7 +31,7 @@ internal class Wonder( fun computeBuildabilityBy(player: Player): WonderBuildability { if (nbBuiltStages == stages.size) { - return Buildability.alreadyBuilt() + return Buildability.wonderFullyBuilt() } return Buildability.requirementDependent(nextStage.requirements.assess(player)) } @@ -50,11 +50,11 @@ internal class Wonder( private object Buildability { - fun alreadyBuilt() = WonderBuildability( + fun wonderFullyBuilt() = WonderBuildability( isBuildable = false, minPrice = Int.MAX_VALUE, cheapestTransactions = emptySet(), - playabilityLevel = PlayabilityLevel.INCOMPATIBLE_WITH_BOARD, + playabilityLevel = PlayabilityLevel.WONDER_FULLY_BUILT, ) fun requirementDependent(satisfaction: RequirementsSatisfaction) = WonderBuildability( |