summaryrefslogtreecommitdiff
path: root/sw-engine
diff options
context:
space:
mode:
authorJoffrey Bion <joffrey.bion@gmail.com>2023-04-30 03:16:57 +0200
committerJoffrey Bion <joffrey.bion@gmail.com>2023-04-30 03:16:57 +0200
commitaeedbc5b8679ca8ff8571c029996aba1a01e53a3 (patch)
tree023a490070ee266ff2984d4b5d254ec2c0df3c49 /sw-engine
parentFix hand rotation indicator's placement (out of view) (diff)
downloadseven-wonders-aeedbc5b8679ca8ff8571c029996aba1a01e53a3.tar.gz
seven-wonders-aeedbc5b8679ca8ff8571c029996aba1a01e53a3.tar.bz2
seven-wonders-aeedbc5b8679ca8ff8571c029996aba1a01e53a3.zip
Fix missing West Trading Post as parent for Forum
Resolves: https://github.com/joffrey-bion/seven-wonders/issues/163
Diffstat (limited to 'sw-engine')
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/cards/Cards.kt8
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/converters/Cards.kt4
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/data/definitions/CardDefinition.kt5
-rw-r--r--sw-engine/src/main/resources/org/luxons/sevenwonders/engine/data/cards.json101
-rw-r--r--sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/GameTest.kt2
-rw-r--r--sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/test/TestUtils.kt2
6 files changed, 87 insertions, 35 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 b097734a..a20f37a0 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
@@ -15,7 +15,7 @@ internal data class Card(
val color: Color,
val requirements: Requirements,
val effects: List<Effect>,
- val chainParent: String?,
+ val chainParents: List<String>,
val chainChildren: List<String>,
val image: String,
val back: CardBack,
@@ -23,18 +23,18 @@ internal data class Card(
fun computePlayabilityBy(player: Player, forceSpecialFree: Boolean = false): CardPlayability = when {
isAlreadyOnBoard(player.board) -> Playability.alreadyPlayed() // cannot play twice the same card
forceSpecialFree -> Playability.specialFree()
- isParentOnBoard(player.board) -> Playability.chainable()
+ isAnyParentOnBoard(player.board) -> Playability.chainable()
else -> Playability.requirementDependent(requirements.assess(player))
}
fun isPlayableOnBoardWith(board: Board, transactions: ResourceTransactions) =
isChainableOn(board) || requirements.areMetWithHelpBy(board, transactions)
- private fun isChainableOn(board: Board): Boolean = !isAlreadyOnBoard(board) && isParentOnBoard(board)
+ private fun isChainableOn(board: Board): Boolean = !isAlreadyOnBoard(board) && isAnyParentOnBoard(board)
private fun isAlreadyOnBoard(board: Board): Boolean = board.isPlayed(name)
- private fun isParentOnBoard(board: Board): Boolean = chainParent != null && board.isPlayed(chainParent)
+ private fun isAnyParentOnBoard(board: Board): Boolean = chainParents.any { board.isPlayed(it) }
fun applyTo(player: Player, transactions: ResourceTransactions) {
if (!isChainableOn(player.board)) {
diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/converters/Cards.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/converters/Cards.kt
index 40c2c2b2..b3b696fb 100644
--- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/converters/Cards.kt
+++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/converters/Cards.kt
@@ -10,7 +10,7 @@ internal fun Card.toTableCard(lastMove: Move? = null): TableCard = TableCard(
name = name,
color = color,
requirements = requirements.toApiRequirements(),
- chainParent = chainParent,
+ chainParents = chainParents,
chainChildren = chainChildren,
image = image,
back = back,
@@ -24,7 +24,7 @@ private fun Card.toHandCard(player: Player, forceSpecialFree: Boolean): HandCard
name = name,
color = color,
requirements = requirements.toApiRequirements(),
- chainParent = chainParent,
+ chainParents = chainParents,
chainChildren = chainChildren,
image = image,
back = back,
diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/data/definitions/CardDefinition.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/data/definitions/CardDefinition.kt
index 0b9fbb7d..58031bea 100644
--- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/data/definitions/CardDefinition.kt
+++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/data/definitions/CardDefinition.kt
@@ -12,7 +12,7 @@ internal class CardDefinition(
private val color: Color,
private val effect: EffectsDefinition,
private val requirements: Requirements? = null,
- private val chainParent: String? = null,
+ private val chainParents: List<String>? = null,
private val chainChildren: List<String>? = null,
private val countPerNbPlayer: Map<Int, Int>? = null,
private val image: String,
@@ -21,7 +21,8 @@ internal class CardDefinition(
fun create(back: CardBack): Card {
val reqs = requirements ?: Requirements()
+ val parents = chainParents ?: emptyList()
val children = chainChildren ?: emptyList()
- return Card(name, color, reqs, effect.create(), chainParent, children, image, back)
+ return Card(name, color, reqs, effect.create(), parents, children, image, back)
}
}
diff --git a/sw-engine/src/main/resources/org/luxons/sevenwonders/engine/data/cards.json b/sw-engine/src/main/resources/org/luxons/sevenwonders/engine/data/cards.json
index 3a7e2dd2..b36640a9 100644
--- a/sw-engine/src/main/resources/org/luxons/sevenwonders/engine/data/cards.json
+++ b/sw-engine/src/main/resources/org/luxons/sevenwonders/engine/data/cards.json
@@ -713,7 +713,9 @@
"requirements": {
"resources": "WW"
},
- "chainParent": "Marketplace",
+ "chainParents": [
+ "Marketplace"
+ ],
"chainChildren": [
"Lighthouse"
],
@@ -738,7 +740,10 @@
"requirements": {
"resources": "CC"
},
- "chainParent": "East Trading Post",
+ "chainParents": [
+ "East Trading Post",
+ "West Trading Post"
+ ],
"chainChildren": [
"Haven"
],
@@ -786,7 +791,9 @@
"requirements": {
"resources": "SSS"
},
- "chainParent": "Baths",
+ "chainParents": [
+ "Baths"
+ ],
"countPerNbPlayer": {
"3": 1,
"4": 1,
@@ -805,7 +812,9 @@
"requirements": {
"resources": "CCL"
},
- "chainParent": "Scriptorium",
+ "chainParents": [
+ "Scriptorium"
+ ],
"countPerNbPlayer": {
"3": 1,
"4": 1,
@@ -824,7 +833,9 @@
"requirements": {
"resources": "WOO"
},
- "chainParent": "Theater",
+ "chainParents": [
+ "Theater"
+ ],
"chainChildren": [
"Gardens"
],
@@ -846,7 +857,9 @@
"requirements": {
"resources": "WCG"
},
- "chainParent": "Altar",
+ "chainParents": [
+ "Altar"
+ ],
"chainChildren": [
"Pantheon"
],
@@ -868,7 +881,9 @@
"requirements": {
"resources": "OOG"
},
- "chainParent": "Apothecary",
+ "chainParents": [
+ "Apothecary"
+ ],
"chainChildren": [
"Arena",
"Lodge"
@@ -891,7 +906,9 @@
"requirements": {
"resources": "CCP"
},
- "chainParent": "Workshop",
+ "chainParents": [
+ "Workshop"
+ ],
"chainChildren": [
"Siege Workshop",
"Observatory"
@@ -914,7 +931,9 @@
"requirements": {
"resources": "SSL"
},
- "chainParent": "Scriptorium",
+ "chainParents": [
+ "Scriptorium"
+ ],
"chainChildren": [
"Senate",
"University"
@@ -959,7 +978,9 @@
"requirements": {
"resources": "WWO"
},
- "chainParent": "Workshop",
+ "chainParents": [
+ "Workshop"
+ ],
"countPerNbPlayer": {
"3": 1,
"4": 1,
@@ -978,7 +999,9 @@
"requirements": {
"resources": "WOC"
},
- "chainParent": "Apothecary",
+ "chainParents": [
+ "Apothecary"
+ ],
"countPerNbPlayer": {
"3": 1,
"4": 1,
@@ -1051,7 +1074,9 @@
"requirements": {
"resources": "SSO"
},
- "chainParent": "Dispensary",
+ "chainParents": [
+ "Dispensary"
+ ],
"countPerNbPlayer": {
"3": 1,
"4": 1,
@@ -1108,7 +1133,9 @@
"requirements": {
"resources": "WOL"
},
- "chainParent": "Forum",
+ "chainParents": [
+ "Forum"
+ ],
"countPerNbPlayer": {
"3": 1,
"4": 2,
@@ -1137,7 +1164,9 @@
"requirements": {
"resources": "SG"
},
- "chainParent": "Caravansery",
+ "chainParents": [
+ "Caravansery"
+ ],
"countPerNbPlayer": {
"3": 1,
"4": 1,
@@ -1156,7 +1185,9 @@
"requirements": {
"resources": "WCC"
},
- "chainParent": "Statue",
+ "chainParents": [
+ "Statue"
+ ],
"countPerNbPlayer": {
"3": 1,
"4": 2,
@@ -1193,7 +1224,9 @@
"requirements": {
"resources": "OCCGPL"
},
- "chainParent": "Temple",
+ "chainParents": [
+ "Temple"
+ ],
"countPerNbPlayer": {
"3": 1,
"4": 1,
@@ -1212,7 +1245,9 @@
"requirements": {
"resources": "WWSO"
},
- "chainParent": "Library",
+ "chainParents": [
+ "Library"
+ ],
"countPerNbPlayer": {
"3": 1,
"4": 1,
@@ -1249,7 +1284,9 @@
"requirements": {
"resources": "SSSG"
},
- "chainParent": "School",
+ "chainParents": [
+ "School"
+ ],
"countPerNbPlayer": {
"3": 1,
"4": 1,
@@ -1268,7 +1305,9 @@
"requirements": {
"resources": "CCPL"
},
- "chainParent": "Dispensary",
+ "chainParents": [
+ "Dispensary"
+ ],
"countPerNbPlayer": {
"3": 1,
"4": 1,
@@ -1287,7 +1326,9 @@
"requirements": {
"resources": "OOGL"
},
- "chainParent": "Laboratory",
+ "chainParents": [
+ "Laboratory"
+ ],
"countPerNbPlayer": {
"3": 1,
"4": 1,
@@ -1306,7 +1347,9 @@
"requirements": {
"resources": "WPL"
},
- "chainParent": "School",
+ "chainParents": [
+ "School"
+ ],
"countPerNbPlayer": {
"3": 1,
"4": 1,
@@ -1325,7 +1368,9 @@
"requirements": {
"resources": "WWGP"
},
- "chainParent": "Library",
+ "chainParents": [
+ "Library"
+ ],
"countPerNbPlayer": {
"3": 1,
"4": 2,
@@ -1362,7 +1407,9 @@
"requirements": {
"resources": "SSSO"
},
- "chainParent": "Training Ground",
+ "chainParents": [
+ "Training Ground"
+ ],
"countPerNbPlayer": {
"3": 0,
"4": 1,
@@ -1381,7 +1428,9 @@
"requirements": {
"resources": "SOOO"
},
- "chainParent": "Walls",
+ "chainParents": [
+ "Walls"
+ ],
"countPerNbPlayer": {
"3": 1,
"4": 1,
@@ -1400,7 +1449,9 @@
"requirements": {
"resources": "WCCC"
},
- "chainParent": "Laboratory",
+ "chainParents": [
+ "Laboratory"
+ ],
"countPerNbPlayer": {
"3": 1,
"4": 1,
diff --git a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/GameTest.kt b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/GameTest.kt
index 5368fbc0..62cc2907 100644
--- a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/GameTest.kt
+++ b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/GameTest.kt
@@ -129,5 +129,5 @@ class GameTest {
data class MoveExpectation(val playerIndex: Int, val moveToSend: PlayerMove, val expectedPlayedMove: PlayedMove)
private fun HandCard.toPlayedCard(): TableCard =
- TableCard(name, color, requirements, chainParent, chainChildren, image, back, true)
+ TableCard(name, color, requirements, chainParents, chainChildren, image, back, true)
}
diff --git a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/test/TestUtils.kt b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/test/TestUtils.kt
index 7a13eccd..4cad3f66 100644
--- a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/test/TestUtils.kt
+++ b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/test/TestUtils.kt
@@ -98,7 +98,7 @@ internal fun testCard(
effect: Effect? = null,
): Card {
val effects = if (effect == null) emptyList() else listOf(effect)
- return Card(name, color, requirements, effects, null, emptyList(), "path/to/card/image", CardBack("image-III"))
+ return Card(name, color, requirements, effects, emptyList(), emptyList(), "path/to/card/image", CardBack("image-III"))
}
internal fun addCards(board: Board, nbCardsOfColor: Int, nbOtherCards: Int, color: Color) {
bgstack15