summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--game-engine/src/main/java/org/luxons/sevenwonders/game/effects/BonusPerBoardElement.java86
-rw-r--r--game-engine/src/main/java/org/luxons/sevenwonders/game/effects/Discount.java44
-rw-r--r--game-engine/src/main/java/org/luxons/sevenwonders/game/effects/EndGameEffect.java11
-rw-r--r--game-engine/src/main/java/org/luxons/sevenwonders/game/effects/GoldIncrease.java40
-rw-r--r--game-engine/src/main/java/org/luxons/sevenwonders/game/effects/InstantOwnBoardEffect.java20
-rw-r--r--game-engine/src/main/java/org/luxons/sevenwonders/game/effects/MilitaryReinforcements.java40
-rw-r--r--game-engine/src/main/java/org/luxons/sevenwonders/game/effects/ProductionIncrease.java54
-rw-r--r--game-engine/src/main/java/org/luxons/sevenwonders/game/effects/RawPointsIncrease.java40
-rw-r--r--game-engine/src/main/java/org/luxons/sevenwonders/game/effects/ScienceProgress.java22
-rw-r--r--game-engine/src/main/java/org/luxons/sevenwonders/game/effects/SpecialAbility.java47
-rw-r--r--game-engine/src/main/java/org/luxons/sevenwonders/game/effects/SpecialAbilityActivation.java26
-rw-r--r--game-engine/src/main/kotlin/org/luxons/sevenwonders/game/data/serializers/ProductionIncreaseSerializer.kt14
-rw-r--r--game-engine/src/main/kotlin/org/luxons/sevenwonders/game/data/serializers/ResourceTypeSerializer.kt2
-rw-r--r--game-engine/src/main/kotlin/org/luxons/sevenwonders/game/data/serializers/ResourceTypesSerializer.kt2
-rw-r--r--game-engine/src/main/kotlin/org/luxons/sevenwonders/game/data/serializers/ResourcesSerializer.kt2
-rw-r--r--game-engine/src/main/kotlin/org/luxons/sevenwonders/game/data/serializers/ScienceProgressSerializer.kt4
-rw-r--r--game-engine/src/main/kotlin/org/luxons/sevenwonders/game/effects/BonusPerBoardElement.kt33
-rw-r--r--game-engine/src/main/kotlin/org/luxons/sevenwonders/game/effects/Discount.kt19
-rw-r--r--game-engine/src/main/kotlin/org/luxons/sevenwonders/game/effects/Effect.kt (renamed from game-engine/src/main/java/org/luxons/sevenwonders/game/effects/Effect.java)10
-rw-r--r--game-engine/src/main/kotlin/org/luxons/sevenwonders/game/effects/EndGameEffect.kt9
-rw-r--r--game-engine/src/main/kotlin/org/luxons/sevenwonders/game/effects/GoldIncrease.kt8
-rw-r--r--game-engine/src/main/kotlin/org/luxons/sevenwonders/game/effects/InstantOwnBoardEffect.kt14
-rw-r--r--game-engine/src/main/kotlin/org/luxons/sevenwonders/game/effects/MilitaryReinforcements.kt8
-rw-r--r--game-engine/src/main/kotlin/org/luxons/sevenwonders/game/effects/ProductionIncrease.kt14
-rw-r--r--game-engine/src/main/kotlin/org/luxons/sevenwonders/game/effects/RawPointsIncrease.kt8
-rw-r--r--game-engine/src/main/kotlin/org/luxons/sevenwonders/game/effects/ScienceProgress.kt9
-rw-r--r--game-engine/src/main/kotlin/org/luxons/sevenwonders/game/effects/SpecialAbility.kt40
-rw-r--r--game-engine/src/main/kotlin/org/luxons/sevenwonders/game/effects/SpecialAbilityActivation.kt10
-rw-r--r--game-engine/src/test/java/org/luxons/sevenwonders/game/data/serializers/NumericEffectSerializerTest.java3
-rw-r--r--game-engine/src/test/java/org/luxons/sevenwonders/game/data/serializers/ProductionIncreaseSerializerTest.java14
-rw-r--r--game-engine/src/test/java/org/luxons/sevenwonders/game/effects/BonusPerBoardElementTest.java142
-rw-r--r--game-engine/src/test/java/org/luxons/sevenwonders/game/effects/DiscountTest.java72
-rw-r--r--game-engine/src/test/java/org/luxons/sevenwonders/game/effects/GoldIncreaseTest.java80
-rw-r--r--game-engine/src/test/java/org/luxons/sevenwonders/game/effects/MilitaryReinforcementsTest.java81
-rw-r--r--game-engine/src/test/java/org/luxons/sevenwonders/game/effects/ProductionIncreaseTest.java109
-rw-r--r--game-engine/src/test/java/org/luxons/sevenwonders/game/effects/RawPointsIncreaseTest.java63
-rw-r--r--game-engine/src/test/java/org/luxons/sevenwonders/game/effects/ScienceProgressTest.java38
-rw-r--r--game-engine/src/test/java/org/luxons/sevenwonders/game/effects/SpecialAbilityActivationTest.java94
-rw-r--r--game-engine/src/test/kotlin/org/luxons/sevenwonders/game/cards/CardTest.kt6
-rw-r--r--game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/BonusPerBoardElementTest.kt141
-rw-r--r--game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/DiscountTest.kt72
-rw-r--r--game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/GoldIncreaseTest.kt46
-rw-r--r--game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/MilitaryReinforcementsTest.kt47
-rw-r--r--game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/ProductionIncreaseTest.kt72
-rw-r--r--game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/RawPointsIncreaseTest.kt28
-rw-r--r--game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/ScienceProgressTest.kt43
-rw-r--r--game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/SpecialAbilityActivationTest.kt95
-rw-r--r--game-engine/src/test/kotlin/org/luxons/sevenwonders/game/test/TestUtils.kt4
48 files changed, 741 insertions, 1145 deletions
diff --git a/game-engine/src/main/java/org/luxons/sevenwonders/game/effects/BonusPerBoardElement.java b/game-engine/src/main/java/org/luxons/sevenwonders/game/effects/BonusPerBoardElement.java
deleted file mode 100644
index e9f9fe5f..00000000
--- a/game-engine/src/main/java/org/luxons/sevenwonders/game/effects/BonusPerBoardElement.java
+++ /dev/null
@@ -1,86 +0,0 @@
-package org.luxons.sevenwonders.game.effects;
-
-import java.util.List;
-
-import org.luxons.sevenwonders.game.api.Table;
-import org.luxons.sevenwonders.game.boards.Board;
-import org.luxons.sevenwonders.game.boards.BoardElementType;
-import org.luxons.sevenwonders.game.boards.RelativeBoardPosition;
-import org.luxons.sevenwonders.game.cards.Color;
-
-public class BonusPerBoardElement implements Effect {
-
- private List<RelativeBoardPosition> boards;
-
- private int gold;
-
- private int points;
-
- private BoardElementType type;
-
- // only relevant if type=CARD
- private List<Color> colors;
-
- public List<RelativeBoardPosition> getBoards() {
- return boards;
- }
-
- public void setBoards(List<RelativeBoardPosition> boards) {
- this.boards = boards;
- }
-
- public int getGold() {
- return gold;
- }
-
- public void setGold(int gold) {
- this.gold = gold;
- }
-
- public int getPoints() {
- return points;
- }
-
- public void setPoints(int points) {
- this.points = points;
- }
-
- public BoardElementType getType() {
- return type;
- }
-
- public void setType(BoardElementType type) {
- this.type = type;
- }
-
- public List<Color> getColors() {
- return colors;
- }
-
- public void setColors(List<Color> colors) {
- this.colors = colors;
- }
-
- @Override
- public void apply(Table table, int playerIndex) {
- int goldGain = gold * computeNbOfMatchingElementsIn(table, playerIndex);
- Board board = table.getBoard(playerIndex);
- board.addGold(goldGain);
- }
-
- @Override
- public int computePoints(Table table, int playerIndex) {
- return points * computeNbOfMatchingElementsIn(table, playerIndex);
- }
-
- private int computeNbOfMatchingElementsIn(Table table, int playerIndex) {
- return boards.stream()
- .map(pos -> table.getBoard(playerIndex, pos))
- .mapToInt(this::computeNbOfMatchingElementsIn)
- .sum();
- }
-
- private int computeNbOfMatchingElementsIn(Board board) {
- return type.getElementCount(board, colors);
- }
-}
diff --git a/game-engine/src/main/java/org/luxons/sevenwonders/game/effects/Discount.java b/game-engine/src/main/java/org/luxons/sevenwonders/game/effects/Discount.java
deleted file mode 100644
index 976ebf35..00000000
--- a/game-engine/src/main/java/org/luxons/sevenwonders/game/effects/Discount.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package org.luxons.sevenwonders.game.effects;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.luxons.sevenwonders.game.boards.Board;
-import org.luxons.sevenwonders.game.resources.Provider;
-import org.luxons.sevenwonders.game.resources.ResourceType;
-import org.luxons.sevenwonders.game.resources.TradingRules;
-
-public class Discount extends InstantOwnBoardEffect {
-
- private final List<ResourceType> resourceTypes = new ArrayList<>();
-
- private final List<Provider> providers = new ArrayList<>();
-
- private int discountedPrice = 1;
-
- public List<ResourceType> getResourceTypes() {
- return resourceTypes;
- }
-
- public List<Provider> getProviders() {
- return providers;
- }
-
- public int getDiscountedPrice() {
- return discountedPrice;
- }
-
- public void setDiscountedPrice(int discountedPrice) {
- this.discountedPrice = discountedPrice;
- }
-
- @Override
- public void apply(Board board) {
- TradingRules rules = board.getTradingRules();
- for (ResourceType type : resourceTypes) {
- for (Provider provider : providers) {
- rules.setCost(type, provider, discountedPrice);
- }
- }
- }
-}
diff --git a/game-engine/src/main/java/org/luxons/sevenwonders/game/effects/EndGameEffect.java b/game-engine/src/main/java/org/luxons/sevenwonders/game/effects/EndGameEffect.java
deleted file mode 100644
index 1bae16a6..00000000
--- a/game-engine/src/main/java/org/luxons/sevenwonders/game/effects/EndGameEffect.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package org.luxons.sevenwonders.game.effects;
-
-import org.luxons.sevenwonders.game.api.Table;
-
-public abstract class EndGameEffect implements Effect {
-
- @Override
- public void apply(Table table, int playerIndex) {
- // EndGameEffects don't do anything when applied to the board, they simply give more points in the end
- }
-}
diff --git a/game-engine/src/main/java/org/luxons/sevenwonders/game/effects/GoldIncrease.java b/game-engine/src/main/java/org/luxons/sevenwonders/game/effects/GoldIncrease.java
deleted file mode 100644
index 4c1215d4..00000000
--- a/game-engine/src/main/java/org/luxons/sevenwonders/game/effects/GoldIncrease.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package org.luxons.sevenwonders.game.effects;
-
-import java.util.Objects;
-
-import org.luxons.sevenwonders.game.boards.Board;
-
-public class GoldIncrease extends InstantOwnBoardEffect {
-
- private final int amount;
-
- public GoldIncrease(int amount) {
- this.amount = amount;
- }
-
- public int getAmount() {
- return amount;
- }
-
- @Override
- public void apply(Board board) {
- board.addGold(amount);
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- GoldIncrease that = (GoldIncrease) o;
- return amount == that.amount;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(amount);
- }
-}
diff --git a/game-engine/src/main/java/org/luxons/sevenwonders/game/effects/InstantOwnBoardEffect.java b/game-engine/src/main/java/org/luxons/sevenwonders/game/effects/InstantOwnBoardEffect.java
deleted file mode 100644
index 8f4340cf..00000000
--- a/game-engine/src/main/java/org/luxons/sevenwonders/game/effects/InstantOwnBoardEffect.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.luxons.sevenwonders.game.effects;
-
-import org.luxons.sevenwonders.game.api.Table;
-import org.luxons.sevenwonders.game.boards.Board;
-
-public abstract class InstantOwnBoardEffect implements Effect {
-
- @Override
- public void apply(Table table, int playerIndex) {
- apply(table.getBoard(playerIndex));
- }
-
- protected abstract void apply(Board board);
-
- @Override
- public int computePoints(Table table, int playerIndex) {
- // InstantEffects are only important when applied to the board, they don't give extra points in the end
- return 0;
- }
-}
diff --git a/game-engine/src/main/java/org/luxons/sevenwonders/game/effects/MilitaryReinforcements.java b/game-engine/src/main/java/org/luxons/sevenwonders/game/effects/MilitaryReinforcements.java
deleted file mode 100644
index 7da112f5..00000000
--- a/game-engine/src/main/java/org/luxons/sevenwonders/game/effects/MilitaryReinforcements.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package org.luxons.sevenwonders.game.effects;
-
-import java.util.Objects;
-
-import org.luxons.sevenwonders.game.boards.Board;
-
-public class MilitaryReinforcements extends InstantOwnBoardEffect {
-
- private final int count;
-
- public MilitaryReinforcements(int count) {
- this.count = count;
- }
-
- public int getCount() {
- return count;
- }
-
- @Override
- public void apply(Board board) {
- board.getMilitary().addShields(count);
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- MilitaryReinforcements that = (MilitaryReinforcements) o;
- return count == that.count;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(count);
- }
-}
diff --git a/game-engine/src/main/java/org/luxons/sevenwonders/game/effects/ProductionIncrease.java b/game-engine/src/main/java/org/luxons/sevenwonders/game/effects/ProductionIncrease.java
deleted file mode 100644
index 514c65db..00000000
--- a/game-engine/src/main/java/org/luxons/sevenwonders/game/effects/ProductionIncrease.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package org.luxons.sevenwonders.game.effects;
-
-import java.util.Objects;
-
-import org.luxons.sevenwonders.game.boards.Board;
-import org.luxons.sevenwonders.game.resources.Production;
-
-public class ProductionIncrease extends InstantOwnBoardEffect {
-
- private Production production = new Production();
-
- private boolean sellable = true;
-
- public Production getProduction() {
- return production;
- }
-
- public void setProduction(Production production) {
- this.production = production;
- }
-
- public boolean isSellable() {
- return sellable;
- }
-
- public void setSellable(boolean sellable) {
- this.sellable = sellable;
- }
-
- @Override
- public void apply(Board board) {
- board.getProduction().addAll(production);
- if (sellable) {
- board.getPublicProduction().addAll(production);
- }
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- ProductionIncrease that = (ProductionIncrease) o;
- return Objects.equals(production, that.production);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(production);
- }
-}
diff --git a/game-engine/src/main/java/org/luxons/sevenwonders/game/effects/RawPointsIncrease.java b/game-engine/src/main/java/org/luxons/sevenwonders/game/effects/RawPointsIncrease.java
deleted file mode 100644
index 9a5d66ed..00000000
--- a/game-engine/src/main/java/org/luxons/sevenwonders/game/effects/RawPointsIncrease.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package org.luxons.sevenwonders.game.effects;
-
-import java.util.Objects;
-
-import org.luxons.sevenwonders.game.api.Table;
-
-public class RawPointsIncrease extends EndGameEffect {
-
- private final int points;
-
- public RawPointsIncrease(int points) {
- this.points = points;
- }
-
- public int getPoints() {
- return points;
- }
-
- @Override
- public int computePoints(Table table, int playerIndex) {
- return points;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- RawPointsIncrease that = (RawPointsIncrease) o;
- return points == that.points;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(points);
- }
-}
diff --git a/game-engine/src/main/java/org/luxons/sevenwonders/game/effects/ScienceProgress.java b/game-engine/src/main/java/org/luxons/sevenwonders/game/effects/ScienceProgress.java
deleted file mode 100644
index 4e6764ee..00000000
--- a/game-engine/src/main/java/org/luxons/sevenwonders/game/effects/ScienceProgress.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package org.luxons.sevenwonders.game.effects;
-
-import org.luxons.sevenwonders.game.boards.Board;
-import org.luxons.sevenwonders.game.boards.Science;
-
-public class ScienceProgress extends InstantOwnBoardEffect {
-
- private Science science;
-
- public Science getScience() {
- return science;
- }
-
- public void setScience(Science science) {
- this.science = science;
- }
-
- @Override
- public void apply(Board board) {
- board.getScience().addAll(science);
- }
-}
diff --git a/game-engine/src/main/java/org/luxons/sevenwonders/game/effects/SpecialAbility.java b/game-engine/src/main/java/org/luxons/sevenwonders/game/effects/SpecialAbility.java
deleted file mode 100644
index cdf67f20..00000000
--- a/game-engine/src/main/java/org/luxons/sevenwonders/game/effects/SpecialAbility.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package org.luxons.sevenwonders.game.effects;
-
-import org.luxons.sevenwonders.game.api.Table;
-import org.luxons.sevenwonders.game.boards.Board;
-import org.luxons.sevenwonders.game.cards.Card;
-
-public enum SpecialAbility {
-
- /**
- * The player can play the last card of each age instead of discarding it. This card can be played by paying its
- * cost, discarded to gain 3 coins or used in the construction of his or her Wonder.
- */
- PLAY_LAST_CARD,
-
- /**
- * Once per age, a player can construct a building from his or her hand for free.
- */
- ONE_FREE_PER_AGE,
-
- /**
- * The player can look at all cards discarded since the beginning of the game, pick one and build it for free.
- */
- PLAY_DISCARDED,
-
- /**
- * The player can, at the end of the game, "copy" a Guild of his or her choice (purple card), built by one of his or
- * her two neighboring cities.
- */
- COPY_GUILD {
- @Override
- public int computePoints(Table table, int playerIndex) {
- Card copiedGuild = table.getBoard(playerIndex).getCopiedGuild();
- if (copiedGuild == null) {
- throw new IllegalStateException("The copied Guild has not been chosen, cannot compute points");
- }
- return copiedGuild.getEffects().stream().mapToInt(e -> e.computePoints(table, playerIndex)).sum();
- }
- };
-
- protected void apply(Board board) {
- board.addSpecial(this);
- }
-
- public int computePoints(Table table, int playerIndex) {
- return 0;
- }
-}
diff --git a/game-engine/src/main/java/org/luxons/sevenwonders/game/effects/SpecialAbilityActivation.java b/game-engine/src/main/java/org/luxons/sevenwonders/game/effects/SpecialAbilityActivation.java
deleted file mode 100644
index a5953c2f..00000000
--- a/game-engine/src/main/java/org/luxons/sevenwonders/game/effects/SpecialAbilityActivation.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.luxons.sevenwonders.game.effects;
-
-import org.luxons.sevenwonders.game.api.Table;
-
-public class SpecialAbilityActivation implements Effect {
-
- private final SpecialAbility specialAbility;
-
- public SpecialAbilityActivation(SpecialAbility specialAbility) {
- this.specialAbility = specialAbility;
- }
-
- public SpecialAbility getSpecialAbility() {
- return specialAbility;
- }
-
- @Override
- public void apply(Table table, int playerIndex) {
- specialAbility.apply(table.getBoard(playerIndex));
- }
-
- @Override
- public int computePoints(Table table, int playerIndex) {
- return specialAbility.computePoints(table, playerIndex);
- }
-}
diff --git a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/data/serializers/ProductionIncreaseSerializer.kt b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/data/serializers/ProductionIncreaseSerializer.kt
index 578f816b..112c0adc 100644
--- a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/data/serializers/ProductionIncreaseSerializer.kt
+++ b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/data/serializers/ProductionIncreaseSerializer.kt
@@ -29,20 +29,16 @@ class ProductionIncreaseSerializer : JsonSerializer<ProductionIncrease>, JsonDes
typeOfT: Type,
context: JsonDeserializationContext
): ProductionIncrease {
- var json = json
- val productionIncrease = ProductionIncrease()
+ var prodJson = json
- var resourcesStr = json.asString
+ var resourcesStr = prodJson.asString
val isSellable = !resourcesStr.startsWith("(")
if (!isSellable) {
resourcesStr = unwrapBrackets(resourcesStr)
- json = JsonPrimitive(resourcesStr)
+ prodJson = JsonPrimitive(resourcesStr)
}
- productionIncrease.isSellable = isSellable
-
- val production = context.deserialize<Production>(json, Production::class.java)
- productionIncrease.production = production
- return productionIncrease
+ val production = context.deserialize<Production>(prodJson, Production::class.java)
+ return ProductionIncrease(production, isSellable)
}
private fun unwrapBrackets(str: String): String {
diff --git a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/data/serializers/ResourceTypeSerializer.kt b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/data/serializers/ResourceTypeSerializer.kt
index 1de9334a..74dee483 100644
--- a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/data/serializers/ResourceTypeSerializer.kt
+++ b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/data/serializers/ResourceTypeSerializer.kt
@@ -12,7 +12,7 @@ import com.google.gson.JsonPrimitive
import com.google.gson.JsonSerializationContext
import com.google.gson.JsonSerializer
-internal class ResourceTypeSerializer : JsonSerializer<ResourceType>, JsonDeserializer<ResourceType> {
+class ResourceTypeSerializer : JsonSerializer<ResourceType>, JsonDeserializer<ResourceType> {
override fun serialize(type: ResourceType, typeOfSrc: Type, context: JsonSerializationContext): JsonElement {
return JsonPrimitive(type.symbol!!)
diff --git a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/data/serializers/ResourceTypesSerializer.kt b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/data/serializers/ResourceTypesSerializer.kt
index 9ba21043..75fcabf0 100644
--- a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/data/serializers/ResourceTypesSerializer.kt
+++ b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/data/serializers/ResourceTypesSerializer.kt
@@ -12,7 +12,7 @@ import com.google.gson.JsonPrimitive
import com.google.gson.JsonSerializationContext
import com.google.gson.JsonSerializer
-internal class ResourceTypesSerializer : JsonSerializer<List<ResourceType>>, JsonDeserializer<List<ResourceType>> {
+class ResourceTypesSerializer : JsonSerializer<List<ResourceType>>, JsonDeserializer<List<ResourceType>> {
override fun serialize(
resources: List<ResourceType>,
diff --git a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/data/serializers/ResourcesSerializer.kt b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/data/serializers/ResourcesSerializer.kt
index 2baf7a35..0a60e4cf 100644
--- a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/data/serializers/ResourcesSerializer.kt
+++ b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/data/serializers/ResourcesSerializer.kt
@@ -15,7 +15,7 @@ import com.google.gson.JsonPrimitive
import com.google.gson.JsonSerializationContext
import com.google.gson.JsonSerializer
-internal class ResourcesSerializer : JsonSerializer<Resources>, JsonDeserializer<Resources> {
+class ResourcesSerializer : JsonSerializer<Resources>, JsonDeserializer<Resources> {
override fun serialize(resources: Resources, typeOfSrc: Type, context: JsonSerializationContext): JsonElement {
val s = resources.asList().map { it.symbol }.joinToString("")
diff --git a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/data/serializers/ScienceProgressSerializer.kt b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/data/serializers/ScienceProgressSerializer.kt
index ed383d63..46ebeb25 100644
--- a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/data/serializers/ScienceProgressSerializer.kt
+++ b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/data/serializers/ScienceProgressSerializer.kt
@@ -39,15 +39,13 @@ internal class ScienceProgressSerializer : JsonSerializer<ScienceProgress>, Json
@Throws(JsonParseException::class)
override fun deserialize(json: JsonElement, typeOfT: Type, context: JsonDeserializationContext): ScienceProgress {
val s = json.asString
- val scienceProgress = ScienceProgress()
val science = Science()
if ("any" == s) {
science.addJoker(1)
} else {
science.add(deserializeScienceType(json, context), 1)
}
- scienceProgress.science = science
- return scienceProgress
+ return ScienceProgress(science)
}
private fun deserializeScienceType(json: JsonElement, context: JsonDeserializationContext): ScienceType {
diff --git a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/effects/BonusPerBoardElement.kt b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/effects/BonusPerBoardElement.kt
new file mode 100644
index 00000000..104dfc77
--- /dev/null
+++ b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/effects/BonusPerBoardElement.kt
@@ -0,0 +1,33 @@
+package org.luxons.sevenwonders.game.effects
+
+import org.luxons.sevenwonders.game.api.Table
+import org.luxons.sevenwonders.game.boards.Board
+import org.luxons.sevenwonders.game.boards.BoardElementType
+import org.luxons.sevenwonders.game.boards.RelativeBoardPosition
+import org.luxons.sevenwonders.game.cards.Color
+
+data class BonusPerBoardElement (
+ val boards: List<RelativeBoardPosition>,
+ val type: BoardElementType,
+ val gold: Int = 0,
+ val points: Int = 0,
+ // only relevant if type=CARD
+ val colors: List<Color>? = null
+) : Effect {
+
+ override fun apply(table: Table, playerIndex: Int) {
+ val goldGain = gold * computeNbOfMatchingElementsIn(table, playerIndex)
+ val board = table.getBoard(playerIndex)
+ board.addGold(goldGain)
+ }
+
+ override fun computePoints(table: Table, playerIndex: Int): Int =
+ points * computeNbOfMatchingElementsIn(table, playerIndex)
+
+ private fun computeNbOfMatchingElementsIn(table: Table, playerIndex: Int): Int = boards
+ .map { pos -> table.getBoard(playerIndex, pos) }
+ .map(::computeNbOfMatchingElementsIn)
+ .sum()
+
+ private fun computeNbOfMatchingElementsIn(board: Board): Int = type.getElementCount(board, colors)
+}
diff --git a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/effects/Discount.kt b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/effects/Discount.kt
new file mode 100644
index 00000000..b1455397
--- /dev/null
+++ b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/effects/Discount.kt
@@ -0,0 +1,19 @@
+package org.luxons.sevenwonders.game.effects
+
+import org.luxons.sevenwonders.game.boards.Board
+import org.luxons.sevenwonders.game.resources.Provider
+import org.luxons.sevenwonders.game.resources.ResourceType
+
+data class Discount(
+ val resourceTypes: List<ResourceType> = emptyList(),
+ val providers: List<Provider> = emptyList(),
+ val discountedPrice: Int = 1
+) : InstantOwnBoardEffect() {
+
+ public override fun apply(board: Board) {
+ val rules = board.tradingRules
+ for (type in resourceTypes) {
+ providers.forEach { rules.setCost(type, it, discountedPrice) }
+ }
+ }
+}
diff --git a/game-engine/src/main/java/org/luxons/sevenwonders/game/effects/Effect.java b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/effects/Effect.kt
index 692eaea0..3bf48086 100644
--- a/game-engine/src/main/java/org/luxons/sevenwonders/game/effects/Effect.java
+++ b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/effects/Effect.kt
@@ -1,15 +1,15 @@
-package org.luxons.sevenwonders.game.effects;
+package org.luxons.sevenwonders.game.effects
-import org.luxons.sevenwonders.game.api.Table;
+import org.luxons.sevenwonders.game.api.Table
/**
* Represents an effect than can be applied to a player's board when playing a card or building his wonder. The effect
* may affect (or depend on) the adjacent boards. It can have an instantaneous effect on the board, or be postponed to
* the end of game where point calculations take place.
*/
-public interface Effect {
+interface Effect {
- void apply(Table table, int playerIndex);
+ fun apply(table: Table, playerIndex: Int)
- int computePoints(Table table, int playerIndex);
+ fun computePoints(table: Table, playerIndex: Int): Int
}
diff --git a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/effects/EndGameEffect.kt b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/effects/EndGameEffect.kt
new file mode 100644
index 00000000..392f53b9
--- /dev/null
+++ b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/effects/EndGameEffect.kt
@@ -0,0 +1,9 @@
+package org.luxons.sevenwonders.game.effects
+
+import org.luxons.sevenwonders.game.api.Table
+
+abstract class EndGameEffect : Effect {
+
+ // EndGameEffects don't do anything when applied to the board, they simply give more points in the end
+ override fun apply(table: Table, playerIndex: Int) = Unit
+}
diff --git a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/effects/GoldIncrease.kt b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/effects/GoldIncrease.kt
new file mode 100644
index 00000000..0d206231
--- /dev/null
+++ b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/effects/GoldIncrease.kt
@@ -0,0 +1,8 @@
+package org.luxons.sevenwonders.game.effects
+
+import org.luxons.sevenwonders.game.boards.Board
+
+data class GoldIncrease(val amount: Int) : InstantOwnBoardEffect() {
+
+ public override fun apply(board: Board) = board.addGold(amount)
+}
diff --git a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/effects/InstantOwnBoardEffect.kt b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/effects/InstantOwnBoardEffect.kt
new file mode 100644
index 00000000..fb26dcce
--- /dev/null
+++ b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/effects/InstantOwnBoardEffect.kt
@@ -0,0 +1,14 @@
+package org.luxons.sevenwonders.game.effects
+
+import org.luxons.sevenwonders.game.api.Table
+import org.luxons.sevenwonders.game.boards.Board
+
+abstract class InstantOwnBoardEffect : Effect {
+
+ override fun apply(table: Table, playerIndex: Int) = apply(table.getBoard(playerIndex))
+
+ protected abstract fun apply(board: Board)
+
+ // InstantEffects are only important when applied to the board, they don't give extra points in the end
+ override fun computePoints(table: Table, playerIndex: Int): Int = 0
+}
diff --git a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/effects/MilitaryReinforcements.kt b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/effects/MilitaryReinforcements.kt
new file mode 100644
index 00000000..ad4d64eb
--- /dev/null
+++ b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/effects/MilitaryReinforcements.kt
@@ -0,0 +1,8 @@
+package org.luxons.sevenwonders.game.effects
+
+import org.luxons.sevenwonders.game.boards.Board
+
+data class MilitaryReinforcements(val count: Int) : InstantOwnBoardEffect() {
+
+ public override fun apply(board: Board) = board.military.addShields(count)
+}
diff --git a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/effects/ProductionIncrease.kt b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/effects/ProductionIncrease.kt
new file mode 100644
index 00000000..aa56705e
--- /dev/null
+++ b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/effects/ProductionIncrease.kt
@@ -0,0 +1,14 @@
+package org.luxons.sevenwonders.game.effects
+
+import org.luxons.sevenwonders.game.boards.Board
+import org.luxons.sevenwonders.game.resources.Production
+
+data class ProductionIncrease(val production: Production, val isSellable: Boolean) : InstantOwnBoardEffect() {
+
+ public override fun apply(board: Board) {
+ board.production.addAll(production)
+ if (isSellable) {
+ board.publicProduction.addAll(production)
+ }
+ }
+}
diff --git a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/effects/RawPointsIncrease.kt b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/effects/RawPointsIncrease.kt
new file mode 100644
index 00000000..ed6eb332
--- /dev/null
+++ b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/effects/RawPointsIncrease.kt
@@ -0,0 +1,8 @@
+package org.luxons.sevenwonders.game.effects
+
+import org.luxons.sevenwonders.game.api.Table
+
+data class RawPointsIncrease(val points: Int) : EndGameEffect() {
+
+ override fun computePoints(table: Table, playerIndex: Int): Int = points
+}
diff --git a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/effects/ScienceProgress.kt b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/effects/ScienceProgress.kt
new file mode 100644
index 00000000..850f8ec3
--- /dev/null
+++ b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/effects/ScienceProgress.kt
@@ -0,0 +1,9 @@
+package org.luxons.sevenwonders.game.effects
+
+import org.luxons.sevenwonders.game.boards.Board
+import org.luxons.sevenwonders.game.boards.Science
+
+class ScienceProgress(val science: Science) : InstantOwnBoardEffect() {
+
+ public override fun apply(board: Board) = board.science.addAll(science)
+}
diff --git a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/effects/SpecialAbility.kt b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/effects/SpecialAbility.kt
new file mode 100644
index 00000000..30d57e27
--- /dev/null
+++ b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/effects/SpecialAbility.kt
@@ -0,0 +1,40 @@
+package org.luxons.sevenwonders.game.effects
+
+import org.luxons.sevenwonders.game.api.Table
+import org.luxons.sevenwonders.game.boards.Board
+import org.luxons.sevenwonders.game.cards.Card
+
+enum class SpecialAbility {
+
+ /**
+ * The player can play the last card of each age instead of discarding it. This card can be played by paying its
+ * cost, discarded to gain 3 coins or used in the construction of his or her Wonder.
+ */
+ PLAY_LAST_CARD,
+
+ /**
+ * Once per age, a player can construct a building from his or her hand for free.
+ */
+ ONE_FREE_PER_AGE,
+
+ /**
+ * The player can look at all cards discarded since the beginning of the game, pick one and build it for free.
+ */
+ PLAY_DISCARDED,
+
+ /**
+ * The player can, at the end of the game, "copy" a Guild of his or her choice (purple card), built by one of his or
+ * her two neighboring cities.
+ */
+ COPY_GUILD {
+ override fun computePoints(table: Table, playerIndex: Int): Int {
+ val copiedGuild = table.getBoard(playerIndex).copiedGuild
+ ?: throw IllegalStateException("The copied Guild has not been chosen, cannot compute points")
+ return copiedGuild.effects.stream().mapToInt { e -> e.computePoints(table, playerIndex) }.sum()
+ }
+ };
+
+ fun apply(board: Board) = board.addSpecial(this)
+
+ open fun computePoints(table: Table, playerIndex: Int): Int = 0
+}
diff --git a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/effects/SpecialAbilityActivation.kt b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/effects/SpecialAbilityActivation.kt
new file mode 100644
index 00000000..fd83d7fe
--- /dev/null
+++ b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/effects/SpecialAbilityActivation.kt
@@ -0,0 +1,10 @@
+package org.luxons.sevenwonders.game.effects
+
+import org.luxons.sevenwonders.game.api.Table
+
+data class SpecialAbilityActivation(val specialAbility: SpecialAbility) : Effect {
+
+ override fun apply(table: Table, playerIndex: Int) = specialAbility.apply(table.getBoard(playerIndex))
+
+ override fun computePoints(table: Table, playerIndex: Int): Int = specialAbility.computePoints(table, playerIndex)
+}
diff --git a/game-engine/src/test/java/org/luxons/sevenwonders/game/data/serializers/NumericEffectSerializerTest.java b/game-engine/src/test/java/org/luxons/sevenwonders/game/data/serializers/NumericEffectSerializerTest.java
index 861d5a09..d7aeeeb2 100644
--- a/game-engine/src/test/java/org/luxons/sevenwonders/game/data/serializers/NumericEffectSerializerTest.java
+++ b/game-engine/src/test/java/org/luxons/sevenwonders/game/data/serializers/NumericEffectSerializerTest.java
@@ -12,6 +12,7 @@ import org.luxons.sevenwonders.game.effects.GoldIncrease;
import org.luxons.sevenwonders.game.effects.MilitaryReinforcements;
import org.luxons.sevenwonders.game.effects.ProductionIncrease;
import org.luxons.sevenwonders.game.effects.RawPointsIncrease;
+import org.luxons.sevenwonders.game.resources.Production;
import static org.junit.Assert.assertEquals;
@@ -52,7 +53,7 @@ public class NumericEffectSerializerTest {
@Test(expected = IllegalArgumentException.class)
public void serialize_failOnUnknownType() {
- gson.toJson(new ProductionIncrease());
+ gson.toJson(new ProductionIncrease(new Production(), false));
}
@Theory
diff --git a/game-engine/src/test/java/org/luxons/sevenwonders/game/data/serializers/ProductionIncreaseSerializerTest.java b/game-engine/src/test/java/org/luxons/sevenwonders/game/data/serializers/ProductionIncreaseSerializerTest.java
index 8c5108ba..fd2e593b 100644
--- a/game-engine/src/test/java/org/luxons/sevenwonders/game/data/serializers/ProductionIncreaseSerializerTest.java
+++ b/game-engine/src/test/java/org/luxons/sevenwonders/game/data/serializers/ProductionIncreaseSerializerTest.java
@@ -43,19 +43,13 @@ public class ProductionIncreaseSerializerTest {
if (clay > 0) {
production.addFixedResource(ResourceType.CLAY, clay);
}
- ProductionIncrease prodIncrease = new ProductionIncrease();
- prodIncrease.setProduction(production);
- prodIncrease.setSellable(sellable);
- return prodIncrease;
+ return new ProductionIncrease(production, sellable);
}
private static ProductionIncrease createChoice(boolean sellable, ResourceType... types) {
Production production = new Production();
production.addChoice(types);
- ProductionIncrease prodIncrease = new ProductionIncrease();
- prodIncrease.setProduction(production);
- prodIncrease.setSellable(sellable);
- return prodIncrease;
+ return new ProductionIncrease(production, sellable);
}
@Test
@@ -65,7 +59,7 @@ public class ProductionIncreaseSerializerTest {
@Test
public void serialize_emptyProdIncreaseAsNull() {
- ProductionIncrease prodIncrease = new ProductionIncrease();
+ ProductionIncrease prodIncrease = new ProductionIncrease(new Production(), false);
assertEquals("null", gson.toJson(prodIncrease, ProductionIncrease.class));
}
@@ -138,7 +132,7 @@ public class ProductionIncreaseSerializerTest {
@Test
public void deserialize_emptyList() {
- ProductionIncrease prodIncrease = new ProductionIncrease();
+ ProductionIncrease prodIncrease = new ProductionIncrease(new Production(), true);
assertEquals(prodIncrease, gson.fromJson("\"\"", ProductionIncrease.class));
}
diff --git a/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/BonusPerBoardElementTest.java b/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/BonusPerBoardElementTest.java
deleted file mode 100644
index a32bc342..00000000
--- a/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/BonusPerBoardElementTest.java
+++ /dev/null
@@ -1,142 +0,0 @@
-package org.luxons.sevenwonders.game.effects;
-
-import java.util.Arrays;
-import java.util.Collections;
-
-import org.junit.Before;
-import org.junit.experimental.theories.DataPoints;
-import org.junit.experimental.theories.Theories;
-import org.junit.experimental.theories.Theory;
-import org.junit.runner.RunWith;
-import org.luxons.sevenwonders.game.api.Table;
-import org.luxons.sevenwonders.game.boards.Board;
-import org.luxons.sevenwonders.game.boards.BoardElementType;
-import org.luxons.sevenwonders.game.boards.RelativeBoardPosition;
-import org.luxons.sevenwonders.game.cards.CardBack;
-import org.luxons.sevenwonders.game.cards.Color;
-import org.luxons.sevenwonders.game.test.TestUtilsKt;
-
-import static org.junit.Assert.assertEquals;
-
-@RunWith(Theories.class)
-public class BonusPerBoardElementTest {
-
- private Table table;
-
- @DataPoints
- public static int[] values() {
- return new int[]{0, 1, 2, 3};
- }
-
- @DataPoints
- public static Color[] colors() {
- return Color.values();
- }
-
- @DataPoints
- public static RelativeBoardPosition[] positions() {
- return RelativeBoardPosition.values();
- }
-
- @Before
- public void setUp() {
- table = TestUtilsKt.testTable(4);
- }
-
- private static BonusPerBoardElement createBonus(BoardElementType type, int gold, int points, Color... colors) {
- BonusPerBoardElement bonus = new BonusPerBoardElement();
- bonus.setType(type);
- bonus.setGold(gold);
- bonus.setPoints(points);
- bonus.setColors(Arrays.asList(colors));
- return bonus;
- }
-
- @Theory
- public void computePoints_countsCards(RelativeBoardPosition boardPosition, int nbCards, int nbOtherCards,
- int points, int gold, Color color) {
- Board board = table.getBoard(0, boardPosition);
- TestUtilsKt.addCards(board, nbCards, nbOtherCards, color);
-
- BonusPerBoardElement bonus = createBonus(BoardElementType.CARD, gold, points, color);
- bonus.setBoards(Collections.singletonList(boardPosition));
-
- assertEquals(nbCards * points, bonus.computePoints(table, 0));
- }
-
- @Theory
- public void computePoints_countsDefeatTokens(RelativeBoardPosition boardPosition, int nbDefeatTokens, int points,
- int gold) {
- Board board = table.getBoard(0, boardPosition);
- for (int i = 0; i < nbDefeatTokens; i++) {
- board.getMilitary().defeat();
- }
-
- BonusPerBoardElement bonus = createBonus(BoardElementType.DEFEAT_TOKEN, gold, points);
- bonus.setBoards(Collections.singletonList(boardPosition));
-
- assertEquals(nbDefeatTokens * points, bonus.computePoints(table, 0));
- }
-
- @Theory
- public void computePoints_countsWonderStages(RelativeBoardPosition boardPosition, int nbStages, int points,
- int gold) {
- Board board = table.getBoard(0, boardPosition);
- for (int i = 0; i < nbStages; i++) {
- board.getWonder().buildLevel(new CardBack(""));
- }
-
- BonusPerBoardElement bonus = createBonus(BoardElementType.BUILT_WONDER_STAGES, gold, points);
- bonus.setBoards(Collections.singletonList(boardPosition));
-
- assertEquals(nbStages * points, bonus.computePoints(table, 0));
- }
-
- @Theory
- public void apply_countsCards(RelativeBoardPosition boardPosition, int nbCards, int nbOtherCards, int points,
- int gold, Color color) {
- Board board = table.getBoard(0, boardPosition);
- TestUtilsKt.addCards(board, nbCards, nbOtherCards, color);
-
- BonusPerBoardElement bonus = createBonus(BoardElementType.CARD, gold, points, color);
- bonus.setBoards(Collections.singletonList(boardPosition));
-
- Board selfBoard = table.getBoard(0);
- int initialGold = selfBoard.getGold();
- bonus.apply(table, 0);
- assertEquals(initialGold + nbCards * gold, selfBoard.getGold());
- }
-
- @Theory
- public void apply_countsDefeatTokens(RelativeBoardPosition boardPosition, int nbDefeatTokens, int points,
- int gold) {
- Board board = table.getBoard(0, boardPosition);
- for (int i = 0; i < nbDefeatTokens; i++) {
- board.getMilitary().defeat();
- }
-
- BonusPerBoardElement bonus = createBonus(BoardElementType.DEFEAT_TOKEN, gold, points);
- bonus.setBoards(Collections.singletonList(boardPosition));
-
- Board selfBoard = table.getBoard(0);
- int initialGold = selfBoard.getGold();
- bonus.apply(table, 0);
- assertEquals(initialGold + nbDefeatTokens * gold, selfBoard.getGold());
- }
-
- @Theory
- public void apply_countsWonderStages(RelativeBoardPosition boardPosition, int nbStages, int points, int gold) {
- Board board = table.getBoard(0, boardPosition);
- for (int i = 0; i < nbStages; i++) {
- board.getWonder().buildLevel(new CardBack(""));
- }
-
- BonusPerBoardElement bonus = createBonus(BoardElementType.BUILT_WONDER_STAGES, gold, points);
- bonus.setBoards(Collections.singletonList(boardPosition));
-
- Board selfBoard = table.getBoard(0);
- int initialGold = selfBoard.getGold();
- bonus.apply(table, 0);
- assertEquals(initialGold + nbStages * gold, selfBoard.getGold());
- }
-}
diff --git a/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/DiscountTest.java b/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/DiscountTest.java
deleted file mode 100644
index c13cec1b..00000000
--- a/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/DiscountTest.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package org.luxons.sevenwonders.game.effects;
-
-import org.junit.Assume;
-import org.junit.experimental.theories.DataPoints;
-import org.junit.experimental.theories.Theories;
-import org.junit.experimental.theories.Theory;
-import org.junit.runner.RunWith;
-import org.luxons.sevenwonders.game.boards.Board;
-import org.luxons.sevenwonders.game.resources.Provider;
-import org.luxons.sevenwonders.game.resources.ResourceTransactions;
-import org.luxons.sevenwonders.game.resources.ResourceType;
-import org.luxons.sevenwonders.game.test.TestUtilsKt;
-
-import static org.junit.Assert.assertEquals;
-
-@RunWith(Theories.class)
-public class DiscountTest {
-
- @DataPoints
- public static int[] discountedPrices() {
- return new int[] {0, 1, 2};
- }
-
- @DataPoints
- public static ResourceType[] resourceTypes() {
- return ResourceType.values();
- }
-
- @DataPoints
- public static Provider[] providers() {
- return Provider.values();
- }
-
- @Theory
- public void apply_givesDiscountedPrice(int discountedPrice, ResourceType discountedType, Provider provider) {
- Board board = TestUtilsKt.testBoard(ResourceType.CLAY, 3);
- Discount discount = new Discount();
- discount.setDiscountedPrice(discountedPrice);
- discount.getProviders().add(provider);
- discount.getResourceTypes().add(discountedType);
- discount.apply(board);
-
- ResourceTransactions transactions = TestUtilsKt.createTransactions(provider, discountedType);
- assertEquals(discountedPrice, board.getTradingRules().computeCost(transactions));
- }
-
- @Theory
- public void apply_doesNotAffectOtherResources(int discountedPrice, ResourceType discountedType, Provider provider,
- ResourceType otherType, Provider otherProvider) {
- Assume.assumeTrue(otherProvider != provider);
- Assume.assumeTrue(otherType != discountedType);
-
- Board board = TestUtilsKt.testBoard(ResourceType.CLAY, 3);
- Discount discount = new Discount();
- discount.setDiscountedPrice(discountedPrice);
- discount.getProviders().add(provider);
- discount.getResourceTypes().add(discountedType);
- discount.apply(board);
-
- // this is the default in the settings used by TestUtilsKt.testBoard()
- int normalPrice = 2;
-
- ResourceTransactions fromOtherType = TestUtilsKt.createTransactions(provider, otherType);
- assertEquals(normalPrice, board.getTradingRules().computeCost(fromOtherType));
-
- ResourceTransactions fromOtherProvider = TestUtilsKt.createTransactions(otherProvider, discountedType);
- assertEquals(normalPrice, board.getTradingRules().computeCost(fromOtherProvider));
-
- ResourceTransactions fromOtherProviderAndType = TestUtilsKt.createTransactions(otherProvider, otherType);
- assertEquals(normalPrice, board.getTradingRules().computeCost(fromOtherProviderAndType));
- }
-}
diff --git a/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/GoldIncreaseTest.java b/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/GoldIncreaseTest.java
deleted file mode 100644
index ffc506c0..00000000
--- a/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/GoldIncreaseTest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-package org.luxons.sevenwonders.game.effects;
-
-import org.junit.experimental.theories.DataPoints;
-import org.junit.experimental.theories.Theories;
-import org.junit.experimental.theories.Theory;
-import org.junit.runner.RunWith;
-import org.luxons.sevenwonders.game.api.Table;
-import org.luxons.sevenwonders.game.boards.Board;
-import org.luxons.sevenwonders.game.resources.ResourceType;
-import org.luxons.sevenwonders.game.test.TestUtilsKt;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-@RunWith(Theories.class)
-public class GoldIncreaseTest {
-
- @DataPoints
- public static int[] goldAmounts() {
- return new int[] {-5, -1, 0, 1, 2, 5, 10};
- }
-
- @DataPoints
- public static ResourceType[] resourceTypes() {
- return ResourceType.values();
- }
-
- @Theory
- public void apply_increaseGoldWithRightAmount(int initialAmount, int goldIncreaseAmount, ResourceType type) {
- Board board = TestUtilsKt.testBoard(type, initialAmount);
- GoldIncrease goldIncrease = new GoldIncrease(goldIncreaseAmount);
-
- goldIncrease.apply(board);
-
- assertEquals(initialAmount + goldIncreaseAmount, board.getGold());
- }
-
- @Theory
- public void computePoints_isAlwaysZero(int gold) {
- GoldIncrease goldIncrease = new GoldIncrease(gold);
- Table table = TestUtilsKt.testTable(5);
- assertEquals(0, goldIncrease.computePoints(table, 0));
- }
-
- @Theory
- public void equals_falseWhenNull(int gold) {
- GoldIncrease goldIncrease = new GoldIncrease(gold);
- //noinspection ObjectEqualsNull
- assertFalse(goldIncrease.equals(null));
- }
-
- @Theory
- public void equals_falseWhenDifferentClass(int gold) {
- GoldIncrease goldIncrease = new GoldIncrease(gold);
- MilitaryReinforcements reinforcements = new MilitaryReinforcements(gold);
- //noinspection EqualsBetweenInconvertibleTypes
- assertFalse(goldIncrease.equals(reinforcements));
- }
-
- @Theory
- public void equals_trueWhenSame(int gold) {
- GoldIncrease goldIncrease = new GoldIncrease(gold);
- assertEquals(goldIncrease, goldIncrease);
- }
-
- @Theory
- public void equals_trueWhenSameContent(int gold) {
- GoldIncrease goldIncrease1 = new GoldIncrease(gold);
- GoldIncrease goldIncrease2 = new GoldIncrease(gold);
- assertTrue(goldIncrease1.equals(goldIncrease2));
- }
-
- @Theory
- public void hashCode_sameWhenSameContent(int gold) {
- GoldIncrease goldIncrease1 = new GoldIncrease(gold);
- GoldIncrease goldIncrease2 = new GoldIncrease(gold);
- assertEquals(goldIncrease1.hashCode(), goldIncrease2.hashCode());
- }
-}
diff --git a/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/MilitaryReinforcementsTest.java b/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/MilitaryReinforcementsTest.java
deleted file mode 100644
index f5a25d98..00000000
--- a/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/MilitaryReinforcementsTest.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package org.luxons.sevenwonders.game.effects;
-
-import org.junit.experimental.theories.DataPoints;
-import org.junit.experimental.theories.Theories;
-import org.junit.experimental.theories.Theory;
-import org.junit.runner.RunWith;
-import org.luxons.sevenwonders.game.api.Table;
-import org.luxons.sevenwonders.game.boards.Board;
-import org.luxons.sevenwonders.game.resources.ResourceType;
-import org.luxons.sevenwonders.game.test.TestUtilsKt;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-@RunWith(Theories.class)
-public class MilitaryReinforcementsTest {
-
- @DataPoints
- public static int[] shieldCounts() {
- return new int[] {0, 1, 2, 3, 5};
- }
-
- @DataPoints
- public static ResourceType[] resourceTypes() {
- return ResourceType.values();
- }
-
- @Theory
- public void apply_increaseGoldWithRightAmount(int initialShields, int additionalShields, ResourceType type) {
- Board board = TestUtilsKt.testBoard(type);
- board.getMilitary().addShields(initialShields);
-
- MilitaryReinforcements reinforcements = new MilitaryReinforcements(additionalShields);
- reinforcements.apply(board);
-
- assertEquals(initialShields + additionalShields, board.getMilitary().getNbShields());
- }
-
- @Theory
- public void computePoints_isAlwaysZero(int shields) {
- MilitaryReinforcements reinforcements = new MilitaryReinforcements(shields);
- Table table = TestUtilsKt.testTable(5);
- assertEquals(0, reinforcements.computePoints(table, 0));
- }
-
- @Theory
- public void equals_falseWhenNull(int shields) {
- MilitaryReinforcements reinforcements = new MilitaryReinforcements(shields);
- //noinspection ObjectEqualsNull
- assertFalse(reinforcements.equals(null));
- }
-
- @Theory
- public void equals_falseWhenDifferentClass(int shields) {
- MilitaryReinforcements reinforcements = new MilitaryReinforcements(shields);
- GoldIncrease goldIncrease = new GoldIncrease(shields);
- //noinspection EqualsBetweenInconvertibleTypes
- assertFalse(reinforcements.equals(goldIncrease));
- }
-
- @Theory
- public void equals_trueWhenSame(int shields) {
- MilitaryReinforcements reinforcements = new MilitaryReinforcements(shields);
- assertEquals(reinforcements, reinforcements);
- }
-
- @Theory
- public void equals_trueWhenSameContent(int shields) {
- MilitaryReinforcements reinforcements1 = new MilitaryReinforcements(shields);
- MilitaryReinforcements reinforcements2 = new MilitaryReinforcements(shields);
- assertTrue(reinforcements1.equals(reinforcements2));
- }
-
- @Theory
- public void hashCode_sameWhenSameContent(int shields) {
- MilitaryReinforcements reinforcements1 = new MilitaryReinforcements(shields);
- MilitaryReinforcements reinforcements2 = new MilitaryReinforcements(shields);
- assertEquals(reinforcements1.hashCode(), reinforcements2.hashCode());
- }
-}
diff --git a/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/ProductionIncreaseTest.java b/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/ProductionIncreaseTest.java
deleted file mode 100644
index c39854e5..00000000
--- a/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/ProductionIncreaseTest.java
+++ /dev/null
@@ -1,109 +0,0 @@
-package org.luxons.sevenwonders.game.effects;
-
-import org.junit.experimental.theories.DataPoints;
-import org.junit.experimental.theories.Theories;
-import org.junit.experimental.theories.Theory;
-import org.junit.runner.RunWith;
-import org.luxons.sevenwonders.game.api.Table;
-import org.luxons.sevenwonders.game.boards.Board;
-import org.luxons.sevenwonders.game.resources.Production;
-import org.luxons.sevenwonders.game.resources.ResourceType;
-import org.luxons.sevenwonders.game.resources.Resources;
-import org.luxons.sevenwonders.game.test.TestUtilsKt;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-@RunWith(Theories.class)
-public class ProductionIncreaseTest {
-
- @DataPoints
- public static ResourceType[] resourceTypes() {
- return ResourceType.values();
- }
-
- private static ProductionIncrease createProductionIncrease(ResourceType... types) {
- ProductionIncrease effect = new ProductionIncrease();
- effect.getProduction().addAll(TestUtilsKt.fixedProduction(types));
- return effect;
- }
-
- @Theory
- public void apply_boardContainsAddedResourceType(ResourceType initialType, ResourceType addedType,
- ResourceType extraType) {
- Board board = TestUtilsKt.testBoard(initialType);
- ProductionIncrease effect = createProductionIncrease(addedType);
- effect.setSellable(false);
-
- effect.apply(board);
-
- Resources resources = TestUtilsKt.createResources(initialType, addedType);
- assertTrue(board.getProduction().contains(resources));
- assertFalse(board.getPublicProduction().contains(resources));
-
- Resources moreResources = TestUtilsKt.createResources(initialType, addedType, extraType);
- assertFalse(board.getProduction().contains(moreResources));
- assertFalse(board.getPublicProduction().contains(moreResources));
- }
-
- @Theory
- public void apply_boardContainsAddedResourceType_sellable(ResourceType initialType, ResourceType addedType,
- ResourceType extraType) {
- Board board = TestUtilsKt.testBoard(initialType);
- ProductionIncrease effect = createProductionIncrease(addedType);
- effect.setSellable(true);
-
- effect.apply(board);
-
- Resources resources = TestUtilsKt.createResources(initialType, addedType);
- assertTrue(board.getProduction().contains(resources));
- assertTrue(board.getPublicProduction().contains(resources));
-
- Resources moreResources = TestUtilsKt.createResources(initialType, addedType, extraType);
- assertFalse(board.getProduction().contains(moreResources));
- assertFalse(board.getPublicProduction().contains(moreResources));
- }
-
- @Theory
- public void computePoints_isAlwaysZero(ResourceType addedType) {
- ProductionIncrease effect = createProductionIncrease(addedType);
- Table table = TestUtilsKt.testTable(5);
- assertEquals(0, effect.computePoints(table, 0));
- }
-
- @Theory
- public void equals_falseWhenNull(ResourceType addedType) {
- ProductionIncrease effect = createProductionIncrease(addedType);
- //noinspection ObjectEqualsNull
- assertFalse(effect.equals(null));
- }
-
- @Theory
- public void equals_falseWhenDifferentClass(ResourceType addedType) {
- ProductionIncrease effect = createProductionIncrease(addedType);
- Production production = TestUtilsKt.fixedProduction(addedType);
- //noinspection EqualsBetweenInconvertibleTypes
- assertFalse(effect.equals(production));
- }
-
- @Theory
- public void equals_trueWhenSame(ResourceType addedType) {
- ProductionIncrease effect = createProductionIncrease(addedType);
- assertEquals(effect, effect);
- }
-
- @Theory
- public void equals_trueWhenSameContent(ResourceType addedType) {
- ProductionIncrease effect1 = createProductionIncrease(addedType);
- ProductionIncrease effect2 = createProductionIncrease(addedType);
- assertTrue(effect1.equals(effect2));
- }
-
- @Theory
- public void hashCode_sameWhenSameContent(ResourceType addedType) {
- ProductionIncrease effect1 = createProductionIncrease(addedType);
- ProductionIncrease effect2 = createProductionIncrease(addedType);
- assertEquals(effect1.hashCode(), effect2.hashCode());
- }
-}
diff --git a/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/RawPointsIncreaseTest.java b/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/RawPointsIncreaseTest.java
deleted file mode 100644
index dcf178f3..00000000
--- a/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/RawPointsIncreaseTest.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package org.luxons.sevenwonders.game.effects;
-
-import org.junit.experimental.theories.DataPoints;
-import org.junit.experimental.theories.Theories;
-import org.junit.experimental.theories.Theory;
-import org.junit.runner.RunWith;
-import org.luxons.sevenwonders.game.api.Table;
-import org.luxons.sevenwonders.game.test.TestUtilsKt;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-@RunWith(Theories.class)
-public class RawPointsIncreaseTest {
-
- @DataPoints
- public static int[] points() {
- return new int[] {0, 1, 2, 3, 5};
- }
-
- @Theory
- public void computePoints_equalsNbOfPoints(int points) {
- RawPointsIncrease rawPointsIncrease = new RawPointsIncrease(points);
- Table table = TestUtilsKt.testTable(5);
- assertEquals(points, rawPointsIncrease.computePoints(table, 0));
- }
-
- @Theory
- public void equals_falseWhenNull(int points) {
- RawPointsIncrease rawPointsIncrease = new RawPointsIncrease(points);
- //noinspection ObjectEqualsNull
- assertFalse(rawPointsIncrease.equals(null));
- }
-
- @Theory
- public void equals_falseWhenDifferentClass(int points) {
- RawPointsIncrease rawPointsIncrease = new RawPointsIncrease(points);
- GoldIncrease goldIncrease = new GoldIncrease(points);
- //noinspection EqualsBetweenInconvertibleTypes
- assertFalse(rawPointsIncrease.equals(goldIncrease));
- }
-
- @Theory
- public void equals_trueWhenSame(int points) {
- RawPointsIncrease rawPointsIncrease = new RawPointsIncrease(points);
- assertEquals(rawPointsIncrease, rawPointsIncrease);
- }
-
- @Theory
- public void equals_trueWhenSameContent(int points) {
- RawPointsIncrease rawPointsIncrease1 = new RawPointsIncrease(points);
- RawPointsIncrease rawPointsIncrease2 = new RawPointsIncrease(points);
- assertTrue(rawPointsIncrease1.equals(rawPointsIncrease2));
- }
-
- @Theory
- public void hashCode_sameWhenSameContent(int points) {
- RawPointsIncrease rawPointsIncrease1 = new RawPointsIncrease(points);
- RawPointsIncrease rawPointsIncrease2 = new RawPointsIncrease(points);
- assertEquals(rawPointsIncrease1.hashCode(), rawPointsIncrease2.hashCode());
- }
-}
diff --git a/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/ScienceProgressTest.java b/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/ScienceProgressTest.java
deleted file mode 100644
index cecafad9..00000000
--- a/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/ScienceProgressTest.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package org.luxons.sevenwonders.game.effects;
-
-import org.junit.experimental.theories.DataPoints;
-import org.junit.experimental.theories.Theories;
-import org.junit.experimental.theories.Theory;
-import org.junit.runner.RunWith;
-import org.luxons.sevenwonders.game.boards.Board;
-import org.luxons.sevenwonders.game.boards.Science;
-import org.luxons.sevenwonders.game.boards.ScienceType;
-import org.luxons.sevenwonders.game.resources.ResourceType;
-import org.luxons.sevenwonders.game.test.TestUtilsKt;
-
-import static org.junit.Assert.assertEquals;
-
-@RunWith(Theories.class)
-public class ScienceProgressTest {
-
- @DataPoints
- public static int[] elementsCount() {
- return new int[] {0, 1, 2};
- }
-
- @Theory
- public void apply_initContainsAddedScience(int initCompasses, int initWheels, int initTablets, int initJokers,
- int compasses, int wheels, int tablets, int jokers) {
- Board board = TestUtilsKt.testBoard(ResourceType.ORE);
- Science initialScience = TestUtilsKt.createScience(initCompasses, initWheels, initTablets, initJokers);
- board.getScience().addAll(initialScience);
-
- ScienceProgress effect = TestUtilsKt.createScienceProgress(compasses, wheels, tablets, jokers);
- effect.apply(board);
-
- assertEquals(initCompasses + compasses, board.getScience().getQuantity(ScienceType.COMPASS));
- assertEquals(initWheels + wheels, board.getScience().getQuantity(ScienceType.WHEEL));
- assertEquals(initTablets + tablets, board.getScience().getQuantity(ScienceType.TABLET));
- assertEquals(initJokers + jokers, board.getScience().getJokers());
- }
-}
diff --git a/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/SpecialAbilityActivationTest.java b/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/SpecialAbilityActivationTest.java
deleted file mode 100644
index 021e8f7c..00000000
--- a/game-engine/src/test/java/org/luxons/sevenwonders/game/effects/SpecialAbilityActivationTest.java
+++ /dev/null
@@ -1,94 +0,0 @@
-package org.luxons.sevenwonders.game.effects;
-
-import java.util.Arrays;
-
-import org.junit.Assume;
-import org.junit.Test;
-import org.junit.experimental.theories.DataPoints;
-import org.junit.experimental.theories.Theories;
-import org.junit.experimental.theories.Theory;
-import org.junit.runner.RunWith;
-import org.luxons.sevenwonders.game.api.Table;
-import org.luxons.sevenwonders.game.boards.Board;
-import org.luxons.sevenwonders.game.boards.BoardElementType;
-import org.luxons.sevenwonders.game.boards.RelativeBoardPosition;
-import org.luxons.sevenwonders.game.cards.Card;
-import org.luxons.sevenwonders.game.cards.Color;
-import org.luxons.sevenwonders.game.test.TestUtilsKt;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-@RunWith(Theories.class)
-public class SpecialAbilityActivationTest {
-
- @DataPoints
- public static SpecialAbility[] abilities() {
- return SpecialAbility.values();
- }
-
- @DataPoints
- public static RelativeBoardPosition[] neighbours() {
- return new RelativeBoardPosition[] {RelativeBoardPosition.LEFT, RelativeBoardPosition.RIGHT};
- }
-
- @DataPoints
- public static Card[] guilds() {
- BonusPerBoardElement bonus = new BonusPerBoardElement();
- bonus.setType(BoardElementType.CARD);
- bonus.setColors(Arrays.asList(Color.GREY, Color.BROWN));
- bonus.setBoards(Arrays.asList(RelativeBoardPosition.LEFT, RelativeBoardPosition.RIGHT));
- bonus.setPoints(1);
-
- BonusPerBoardElement bonus2 = new BonusPerBoardElement();
- bonus2.setType(BoardElementType.BUILT_WONDER_STAGES);
- bonus2.setBoards(
- Arrays.asList(RelativeBoardPosition.LEFT, RelativeBoardPosition.SELF, RelativeBoardPosition.RIGHT));
- bonus2.setPoints(1);
-
- return new Card[] {TestUtilsKt.createGuildCard(1, bonus), TestUtilsKt.createGuildCard(2, bonus2)};
- }
-
- @Theory
- public void apply_addsAbility(SpecialAbility ability) {
- SpecialAbilityActivation effect = new SpecialAbilityActivation(ability);
- Table table = TestUtilsKt.testTable(5);
-
- effect.apply(table, 0);
-
- Board board = table.getBoard(0);
- assertTrue(board.hasSpecial(ability));
- }
-
- @Theory
- public void computePoints_zeroExceptForCopyGuild(SpecialAbility ability) {
- Assume.assumeTrue(ability != SpecialAbility.COPY_GUILD);
-
- SpecialAbilityActivation effect = new SpecialAbilityActivation(ability);
- Table table = TestUtilsKt.testTable(5);
-
- assertEquals(0, effect.computePoints(table, 0));
- }
-
- @Theory
- public void computePoints_copiedGuild(Card guildCard, RelativeBoardPosition neighbour) {
- SpecialAbilityActivation effect = new SpecialAbilityActivation(SpecialAbility.COPY_GUILD);
- Table table = TestUtilsKt.testTable(5);
-
- Board neighbourBoard = table.getBoard(0, neighbour);
- neighbourBoard.addCard(guildCard);
-
- Board board = table.getBoard(0);
- board.setCopiedGuild(guildCard);
-
- int directPointsFromGuildCard = guildCard.getEffects().stream().mapToInt(e -> e.computePoints(table, 0)).sum();
- assertEquals(directPointsFromGuildCard, effect.computePoints(table, 0));
- }
-
- @Test(expected = IllegalStateException.class)
- public void computePoints_copyGuild_failWhenNoChosenGuild() {
- SpecialAbilityActivation effect = new SpecialAbilityActivation(SpecialAbility.COPY_GUILD);
- Table table = TestUtilsKt.testTable(5);
- effect.computePoints(table, 0);
- }
-}
diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/cards/CardTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/cards/CardTest.kt
index 170ae1e4..3253136c 100644
--- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/cards/CardTest.kt
+++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/cards/CardTest.kt
@@ -7,6 +7,7 @@ import org.luxons.sevenwonders.game.Settings
import org.luxons.sevenwonders.game.api.Table
import org.luxons.sevenwonders.game.boards.Board
import org.luxons.sevenwonders.game.effects.ProductionIncrease
+import org.luxons.sevenwonders.game.resources.Production
import org.luxons.sevenwonders.game.resources.ResourceTransactions
import org.luxons.sevenwonders.game.resources.ResourceType
import org.luxons.sevenwonders.game.resources.Resources
@@ -31,8 +32,9 @@ class CardTest {
table = Table(boards)
val treeFarmRequirements = Requirements(1)
- val treeFarmEffect = ProductionIncrease()
- treeFarmEffect.production.addChoice(ResourceType.WOOD, ResourceType.CLAY)
+ val treeFarmProduction = Production()
+ treeFarmProduction.addChoice(ResourceType.WOOD, ResourceType.CLAY)
+ val treeFarmEffect = ProductionIncrease(treeFarmProduction, false)
treeFarmCard = testCard("Tree Farm", Color.BROWN, treeFarmEffect, treeFarmRequirements)
}
diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/BonusPerBoardElementTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/BonusPerBoardElementTest.kt
new file mode 100644
index 00000000..ccc1c142
--- /dev/null
+++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/BonusPerBoardElementTest.kt
@@ -0,0 +1,141 @@
+package org.luxons.sevenwonders.game.effects
+
+import org.junit.Before
+import org.junit.experimental.theories.DataPoints
+import org.junit.experimental.theories.Theories
+import org.junit.experimental.theories.Theory
+import org.junit.runner.RunWith
+import org.luxons.sevenwonders.game.api.Table
+import org.luxons.sevenwonders.game.boards.BoardElementType
+import org.luxons.sevenwonders.game.boards.RelativeBoardPosition
+import org.luxons.sevenwonders.game.cards.CardBack
+import org.luxons.sevenwonders.game.cards.Color
+import org.luxons.sevenwonders.game.test.*
+
+import org.junit.Assert.assertEquals
+
+@RunWith(Theories::class)
+class BonusPerBoardElementTest {
+
+ private var table: Table? = null
+
+ @Before
+ fun setUp() {
+ table = testTable(4)
+ }
+
+ @Theory
+ fun computePoints_countsCards(
+ boardPosition: RelativeBoardPosition, nbCards: Int, nbOtherCards: Int,
+ points: Int, gold: Int, color: Color
+ ) {
+ val board = table!!.getBoard(0, boardPosition)
+ addCards(board, nbCards, nbOtherCards, color)
+
+ val bonus = BonusPerBoardElement(listOf(boardPosition), BoardElementType.CARD, gold, points, listOf(color))
+
+ assertEquals((nbCards * points).toLong(), bonus.computePoints(table!!, 0).toLong())
+ }
+
+ @Theory
+ fun computePoints_countsDefeatTokens(
+ boardPosition: RelativeBoardPosition, nbDefeatTokens: Int, points: Int,
+ gold: Int
+ ) {
+ val board = table!!.getBoard(0, boardPosition)
+ for (i in 0 until nbDefeatTokens) {
+ board.military.defeat()
+ }
+
+ val bonus = BonusPerBoardElement(listOf(boardPosition), BoardElementType.DEFEAT_TOKEN, gold, points, listOf())
+
+ assertEquals((nbDefeatTokens * points).toLong(), bonus.computePoints(table!!, 0).toLong())
+ }
+
+ @Theory
+ fun computePoints_countsWonderStages(
+ boardPosition: RelativeBoardPosition, nbStages: Int, points: Int,
+ gold: Int
+ ) {
+ val board = table!!.getBoard(0, boardPosition)
+ for (i in 0 until nbStages) {
+ board.wonder.buildLevel(CardBack(""))
+ }
+
+ val bonus =
+ BonusPerBoardElement(listOf(boardPosition), BoardElementType.BUILT_WONDER_STAGES, gold, points, listOf())
+
+ assertEquals((nbStages * points).toLong(), bonus.computePoints(table!!, 0).toLong())
+ }
+
+ @Theory
+ fun apply_countsCards(
+ boardPosition: RelativeBoardPosition, nbCards: Int, nbOtherCards: Int, points: Int,
+ gold: Int, color: Color
+ ) {
+ val board = table!!.getBoard(0, boardPosition)
+ addCards(board, nbCards, nbOtherCards, color)
+
+ val bonus = BonusPerBoardElement(listOf(boardPosition), BoardElementType.CARD, gold, points, listOf(color))
+
+ val selfBoard = table!!.getBoard(0)
+ val initialGold = selfBoard.gold
+ bonus.apply(table!!, 0)
+ assertEquals((initialGold + nbCards * gold).toLong(), selfBoard.gold.toLong())
+ }
+
+ @Theory
+ fun apply_countsDefeatTokens(
+ boardPosition: RelativeBoardPosition, nbDefeatTokens: Int, points: Int,
+ gold: Int
+ ) {
+ val board = table!!.getBoard(0, boardPosition)
+ for (i in 0 until nbDefeatTokens) {
+ board.military.defeat()
+ }
+
+ val bonus = BonusPerBoardElement(listOf(boardPosition), BoardElementType.DEFEAT_TOKEN, gold, points, listOf())
+
+ val selfBoard = table!!.getBoard(0)
+ val initialGold = selfBoard.gold
+ bonus.apply(table!!, 0)
+ assertEquals((initialGold + nbDefeatTokens * gold).toLong(), selfBoard.gold.toLong())
+ }
+
+ @Theory
+ fun apply_countsWonderStages(boardPosition: RelativeBoardPosition, nbStages: Int, points: Int, gold: Int) {
+ val board = table!!.getBoard(0, boardPosition)
+ for (i in 0 until nbStages) {
+ board.wonder.buildLevel(CardBack(""))
+ }
+
+ val bonus =
+ BonusPerBoardElement(listOf(boardPosition), BoardElementType.BUILT_WONDER_STAGES, gold, points, listOf())
+
+ val selfBoard = table!!.getBoard(0)
+ val initialGold = selfBoard.gold
+ bonus.apply(table!!, 0)
+ assertEquals((initialGold + nbStages * gold).toLong(), selfBoard.gold.toLong())
+ }
+
+ companion object {
+
+ @JvmStatic
+ @DataPoints
+ fun values(): IntArray {
+ return intArrayOf(0, 1, 2, 3)
+ }
+
+ @JvmStatic
+ @DataPoints
+ fun colors(): Array<Color> {
+ return Color.values()
+ }
+
+ @JvmStatic
+ @DataPoints
+ fun positions(): Array<RelativeBoardPosition> {
+ return RelativeBoardPosition.values()
+ }
+ }
+}
diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/DiscountTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/DiscountTest.kt
new file mode 100644
index 00000000..e228d585
--- /dev/null
+++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/DiscountTest.kt
@@ -0,0 +1,72 @@
+package org.luxons.sevenwonders.game.effects
+
+import org.junit.Assert.assertEquals
+import org.junit.Assume
+import org.junit.experimental.theories.DataPoints
+import org.junit.experimental.theories.Theories
+import org.junit.experimental.theories.Theory
+import org.junit.runner.RunWith
+import org.luxons.sevenwonders.game.resources.Provider
+import org.luxons.sevenwonders.game.resources.ResourceType
+import org.luxons.sevenwonders.game.test.createTransactions
+import org.luxons.sevenwonders.game.test.testBoard
+
+@RunWith(Theories::class)
+class DiscountTest {
+
+ @Theory
+ fun apply_givesDiscountedPrice(discountedPrice: Int, discountedType: ResourceType, provider: Provider) {
+ val board = testBoard(ResourceType.CLAY, 3)
+ val discount = Discount(listOf(discountedType), listOf(provider), discountedPrice)
+ discount.apply(board)
+
+ val transactions = createTransactions(provider, discountedType)
+ assertEquals(discountedPrice.toLong(), board.tradingRules.computeCost(transactions).toLong())
+ }
+
+ @Theory
+ fun apply_doesNotAffectOtherResources(
+ discountedPrice: Int, discountedType: ResourceType, provider: Provider,
+ otherType: ResourceType, otherProvider: Provider
+ ) {
+ Assume.assumeTrue(otherProvider != provider)
+ Assume.assumeTrue(otherType != discountedType)
+
+ val board = testBoard(ResourceType.CLAY, 3)
+ val discount = Discount(listOf(discountedType), listOf(provider), discountedPrice)
+ discount.apply(board)
+
+ // this is the default in the settings used by TestUtilsKt.testBoard()
+ val normalPrice = 2
+
+ val fromOtherType = createTransactions(provider, otherType)
+ assertEquals(normalPrice.toLong(), board.tradingRules.computeCost(fromOtherType).toLong())
+
+ val fromOtherProvider = createTransactions(otherProvider, discountedType)
+ assertEquals(normalPrice.toLong(), board.tradingRules.computeCost(fromOtherProvider).toLong())
+
+ val fromOtherProviderAndType = createTransactions(otherProvider, otherType)
+ assertEquals(normalPrice.toLong(), board.tradingRules.computeCost(fromOtherProviderAndType).toLong())
+ }
+
+ companion object {
+
+ @JvmStatic
+ @DataPoints
+ fun discountedPrices(): IntArray {
+ return intArrayOf(0, 1, 2)
+ }
+
+ @JvmStatic
+ @DataPoints
+ fun resourceTypes(): Array<ResourceType> {
+ return ResourceType.values()
+ }
+
+ @JvmStatic
+ @DataPoints
+ fun providers(): Array<Provider> {
+ return Provider.values()
+ }
+ }
+}
diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/GoldIncreaseTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/GoldIncreaseTest.kt
new file mode 100644
index 00000000..175f15ea
--- /dev/null
+++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/GoldIncreaseTest.kt
@@ -0,0 +1,46 @@
+package org.luxons.sevenwonders.game.effects
+
+import org.junit.experimental.theories.DataPoints
+import org.junit.experimental.theories.Theories
+import org.junit.experimental.theories.Theory
+import org.junit.runner.RunWith
+import org.luxons.sevenwonders.game.resources.ResourceType
+import org.luxons.sevenwonders.game.test.*
+
+import org.junit.Assert.assertEquals
+
+@RunWith(Theories::class)
+class GoldIncreaseTest {
+
+ @Theory
+ fun apply_increaseGoldWithRightAmount(initialAmount: Int, goldIncreaseAmount: Int, type: ResourceType) {
+ val board = testBoard(type, initialAmount)
+ val goldIncrease = GoldIncrease(goldIncreaseAmount)
+
+ goldIncrease.apply(board)
+
+ assertEquals((initialAmount + goldIncreaseAmount).toLong(), board.gold.toLong())
+ }
+
+ @Theory
+ fun computePoints_isAlwaysZero(gold: Int) {
+ val goldIncrease = GoldIncrease(gold)
+ val table = testTable(5)
+ assertEquals(0, goldIncrease.computePoints(table, 0).toLong())
+ }
+
+ companion object {
+
+ @JvmStatic
+ @DataPoints
+ fun goldAmounts(): IntArray {
+ return intArrayOf(-5, -1, 0, 1, 2, 5, 10)
+ }
+
+ @JvmStatic
+ @DataPoints
+ fun resourceTypes(): Array<ResourceType> {
+ return ResourceType.values()
+ }
+ }
+}
diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/MilitaryReinforcementsTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/MilitaryReinforcementsTest.kt
new file mode 100644
index 00000000..a8bd01d6
--- /dev/null
+++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/MilitaryReinforcementsTest.kt
@@ -0,0 +1,47 @@
+package org.luxons.sevenwonders.game.effects
+
+import org.junit.experimental.theories.DataPoints
+import org.junit.experimental.theories.Theories
+import org.junit.experimental.theories.Theory
+import org.junit.runner.RunWith
+import org.luxons.sevenwonders.game.resources.ResourceType
+import org.luxons.sevenwonders.game.test.*
+
+import org.junit.Assert.assertEquals
+
+@RunWith(Theories::class)
+class MilitaryReinforcementsTest {
+
+ @Theory
+ fun apply_increaseGoldWithRightAmount(initialShields: Int, additionalShields: Int, type: ResourceType) {
+ val board = testBoard(type)
+ board.military.addShields(initialShields)
+
+ val reinforcements = MilitaryReinforcements(additionalShields)
+ reinforcements.apply(board)
+
+ assertEquals((initialShields + additionalShields).toLong(), board.military.nbShields.toLong())
+ }
+
+ @Theory
+ fun computePoints_isAlwaysZero(shields: Int) {
+ val reinforcements = MilitaryReinforcements(shields)
+ val table = testTable(5)
+ assertEquals(0, reinforcements.computePoints(table, 0).toLong())
+ }
+
+ companion object {
+
+ @JvmStatic
+ @DataPoints
+ fun shieldCounts(): IntArray {
+ return intArrayOf(0, 1, 2, 3, 5)
+ }
+
+ @JvmStatic
+ @DataPoints
+ fun resourceTypes(): Array<ResourceType> {
+ return ResourceType.values()
+ }
+ }
+}
diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/ProductionIncreaseTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/ProductionIncreaseTest.kt
new file mode 100644
index 00000000..6f8da55d
--- /dev/null
+++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/ProductionIncreaseTest.kt
@@ -0,0 +1,72 @@
+package org.luxons.sevenwonders.game.effects
+
+import org.junit.experimental.theories.DataPoints
+import org.junit.experimental.theories.Theories
+import org.junit.experimental.theories.Theory
+import org.junit.runner.RunWith
+import org.luxons.sevenwonders.game.resources.ResourceType
+import org.luxons.sevenwonders.game.test.*
+
+import org.junit.Assert.assertEquals
+import org.junit.Assert.assertFalse
+import org.junit.Assert.assertTrue
+
+@RunWith(Theories::class)
+class ProductionIncreaseTest {
+
+ @Theory
+ fun apply_boardContainsAddedResourceType(
+ initialType: ResourceType,
+ addedType: ResourceType,
+ extraType: ResourceType
+ ) {
+ val board = testBoard(initialType)
+ val effect = ProductionIncrease(fixedProduction(addedType), false)
+
+ effect.apply(board)
+
+ val resources = createResources(initialType, addedType)
+ assertTrue(board.production.contains(resources))
+ assertFalse(board.publicProduction.contains(resources))
+
+ val moreResources = createResources(initialType, addedType, extraType)
+ assertFalse(board.production.contains(moreResources))
+ assertFalse(board.publicProduction.contains(moreResources))
+ }
+
+ @Theory
+ fun apply_boardContainsAddedResourceType_sellable(
+ initialType: ResourceType,
+ addedType: ResourceType,
+ extraType: ResourceType
+ ) {
+ val board = testBoard(initialType)
+ val effect = ProductionIncrease(fixedProduction(addedType), true)
+
+ effect.apply(board)
+
+ val resources = createResources(initialType, addedType)
+ assertTrue(board.production.contains(resources))
+ assertTrue(board.publicProduction.contains(resources))
+
+ val moreResources = createResources(initialType, addedType, extraType)
+ assertFalse(board.production.contains(moreResources))
+ assertFalse(board.publicProduction.contains(moreResources))
+ }
+
+ @Theory
+ fun computePoints_isAlwaysZero(addedType: ResourceType) {
+ val effect = ProductionIncrease(fixedProduction(addedType), false)
+ val table = testTable(5)
+ assertEquals(0, effect.computePoints(table, 0).toLong())
+ }
+
+ companion object {
+
+ @JvmStatic
+ @DataPoints
+ fun resourceTypes(): Array<ResourceType> {
+ return ResourceType.values()
+ }
+ }
+}
diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/RawPointsIncreaseTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/RawPointsIncreaseTest.kt
new file mode 100644
index 00000000..844c28eb
--- /dev/null
+++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/RawPointsIncreaseTest.kt
@@ -0,0 +1,28 @@
+package org.luxons.sevenwonders.game.effects
+
+import org.junit.Assert.assertEquals
+import org.junit.experimental.theories.DataPoints
+import org.junit.experimental.theories.Theories
+import org.junit.experimental.theories.Theory
+import org.junit.runner.RunWith
+import org.luxons.sevenwonders.game.test.testTable
+
+@RunWith(Theories::class)
+class RawPointsIncreaseTest {
+
+ @Theory
+ fun computePoints_equalsNbOfPoints(points: Int) {
+ val rawPointsIncrease = RawPointsIncrease(points)
+ val table = testTable(5)
+ assertEquals(points.toLong(), rawPointsIncrease.computePoints(table, 0).toLong())
+ }
+
+ companion object {
+
+ @JvmStatic
+ @DataPoints
+ fun points(): IntArray {
+ return intArrayOf(0, 1, 2, 3, 5)
+ }
+ }
+}
diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/ScienceProgressTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/ScienceProgressTest.kt
new file mode 100644
index 00000000..cbea1581
--- /dev/null
+++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/ScienceProgressTest.kt
@@ -0,0 +1,43 @@
+package org.luxons.sevenwonders.game.effects
+
+import org.junit.Assert.assertEquals
+import org.junit.experimental.theories.DataPoints
+import org.junit.experimental.theories.Theories
+import org.junit.experimental.theories.Theory
+import org.junit.runner.RunWith
+import org.luxons.sevenwonders.game.boards.ScienceType
+import org.luxons.sevenwonders.game.resources.ResourceType
+import org.luxons.sevenwonders.game.test.createScience
+import org.luxons.sevenwonders.game.test.createScienceProgress
+import org.luxons.sevenwonders.game.test.testBoard
+
+@RunWith(Theories::class)
+class ScienceProgressTest {
+
+ @Theory
+ fun apply_initContainsAddedScience(
+ initCompasses: Int, initWheels: Int, initTablets: Int, initJokers: Int,
+ compasses: Int, wheels: Int, tablets: Int, jokers: Int
+ ) {
+ val board = testBoard(ResourceType.ORE)
+ val initialScience = createScience(initCompasses, initWheels, initTablets, initJokers)
+ board.science.addAll(initialScience)
+
+ val effect = createScienceProgress(compasses, wheels, tablets, jokers)
+ effect.apply(board)
+
+ assertEquals((initCompasses + compasses).toLong(), board.science.getQuantity(ScienceType.COMPASS).toLong())
+ assertEquals((initWheels + wheels).toLong(), board.science.getQuantity(ScienceType.WHEEL).toLong())
+ assertEquals((initTablets + tablets).toLong(), board.science.getQuantity(ScienceType.TABLET).toLong())
+ assertEquals((initJokers + jokers).toLong(), board.science.jokers.toLong())
+ }
+
+ companion object {
+
+ @JvmStatic
+ @DataPoints
+ fun elementsCount(): IntArray {
+ return intArrayOf(0, 1, 2)
+ }
+ }
+}
diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/SpecialAbilityActivationTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/SpecialAbilityActivationTest.kt
new file mode 100644
index 00000000..7282d60d
--- /dev/null
+++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/SpecialAbilityActivationTest.kt
@@ -0,0 +1,95 @@
+package org.luxons.sevenwonders.game.effects
+
+import org.junit.Assert.assertEquals
+import org.junit.Assert.assertTrue
+import org.junit.Assume
+import org.junit.Test
+import org.junit.experimental.theories.DataPoints
+import org.junit.experimental.theories.Theories
+import org.junit.experimental.theories.Theory
+import org.junit.runner.RunWith
+import org.luxons.sevenwonders.game.boards.BoardElementType
+import org.luxons.sevenwonders.game.boards.RelativeBoardPosition
+import org.luxons.sevenwonders.game.cards.Card
+import org.luxons.sevenwonders.game.cards.Color
+import org.luxons.sevenwonders.game.test.createGuildCard
+import org.luxons.sevenwonders.game.test.testTable
+
+@RunWith(Theories::class)
+class SpecialAbilityActivationTest {
+
+ @Theory
+ fun apply_addsAbility(ability: SpecialAbility) {
+ val effect = SpecialAbilityActivation(ability)
+ val table = testTable(5)
+
+ effect.apply(table, 0)
+
+ val board = table.getBoard(0)
+ assertTrue(board.hasSpecial(ability))
+ }
+
+ @Theory
+ fun computePoints_zeroExceptForCopyGuild(ability: SpecialAbility) {
+ Assume.assumeTrue(ability !== SpecialAbility.COPY_GUILD)
+
+ val effect = SpecialAbilityActivation(ability)
+ val table = testTable(5)
+
+ assertEquals(0, effect.computePoints(table, 0).toLong())
+ }
+
+ @Theory
+ fun computePoints_copiedGuild(guildCard: Card, neighbour: RelativeBoardPosition) {
+ val effect = SpecialAbilityActivation(SpecialAbility.COPY_GUILD)
+ val table = testTable(5)
+
+ val neighbourBoard = table.getBoard(0, neighbour)
+ neighbourBoard.addCard(guildCard)
+
+ val board = table.getBoard(0)
+ board.copiedGuild = guildCard
+
+ val directPointsFromGuildCard = guildCard.effects.stream().mapToInt { e -> e.computePoints(table, 0) }.sum()
+ assertEquals(directPointsFromGuildCard.toLong(), effect.computePoints(table, 0).toLong())
+ }
+
+ @Test(expected = IllegalStateException::class)
+ fun computePoints_copyGuild_failWhenNoChosenGuild() {
+ val effect = SpecialAbilityActivation(SpecialAbility.COPY_GUILD)
+ val table = testTable(5)
+ effect.computePoints(table, 0)
+ }
+
+ companion object {
+
+ @JvmStatic
+ @DataPoints
+ fun abilities(): Array<SpecialAbility> {
+ return SpecialAbility.values()
+ }
+
+ @JvmStatic
+ @DataPoints
+ fun neighbours(): Array<RelativeBoardPosition> {
+ return arrayOf(RelativeBoardPosition.LEFT, RelativeBoardPosition.RIGHT)
+ }
+
+ @JvmStatic
+ @DataPoints
+ fun guilds(): Array<Card> {
+ val bonus = BonusPerBoardElement(
+ listOf(RelativeBoardPosition.LEFT, RelativeBoardPosition.RIGHT),
+ BoardElementType.CARD,
+ points = 1,
+ colors = listOf(Color.GREY, Color.BROWN)
+ )
+ val bonus2 = BonusPerBoardElement(
+ listOf(RelativeBoardPosition.LEFT, RelativeBoardPosition.SELF, RelativeBoardPosition.RIGHT),
+ BoardElementType.BUILT_WONDER_STAGES,
+ points = 1
+ )
+ return arrayOf(createGuildCard(1, bonus), createGuildCard(2, bonus2))
+ }
+ }
+}
diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/test/TestUtils.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/test/TestUtils.kt
index 85caa35f..28ab714d 100644
--- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/test/TestUtils.kt
+++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/test/TestUtils.kt
@@ -183,9 +183,7 @@ fun getDifferentColorFrom(vararg colors: Color): Color {
}
fun createScienceProgress(compasses: Int, wheels: Int, tablets: Int, jokers: Int): ScienceProgress {
- val progress = ScienceProgress()
- progress.science = createScience(compasses, wheels, tablets, jokers)
- return progress
+ return ScienceProgress(createScience(compasses, wheels, tablets, jokers))
}
fun createScience(compasses: Int, wheels: Int, tablets: Int, jokers: Int): Science {
bgstack15