summaryrefslogtreecommitdiff
path: root/game-engine/src/main/java
diff options
context:
space:
mode:
authorjbion <joffrey.bion@amadeus.com>2018-07-08 13:30:41 +0200
committerjbion <joffrey.bion@amadeus.com>2018-07-08 13:34:13 +0200
commit3b844531a2f9ad8037c9666cfff00916b5321cf9 (patch)
treea8505a260ab6cccf4fb3c153c3a1009b0d5a559e /game-engine/src/main/java
parentKotlin mig: api package tests (diff)
downloadseven-wonders-3b844531a2f9ad8037c9666cfff00916b5321cf9.tar.gz
seven-wonders-3b844531a2f9ad8037c9666cfff00916b5321cf9.tar.bz2
seven-wonders-3b844531a2f9ad8037c9666cfff00916b5321cf9.zip
Kotlin mig: wonders package
Diffstat (limited to 'game-engine/src/main/java')
-rw-r--r--game-engine/src/main/java/org/luxons/sevenwonders/game/wonders/Wonder.java102
-rw-r--r--game-engine/src/main/java/org/luxons/sevenwonders/game/wonders/WonderStage.java54
2 files changed, 0 insertions, 156 deletions
diff --git a/game-engine/src/main/java/org/luxons/sevenwonders/game/wonders/Wonder.java b/game-engine/src/main/java/org/luxons/sevenwonders/game/wonders/Wonder.java
deleted file mode 100644
index dd0170da..00000000
--- a/game-engine/src/main/java/org/luxons/sevenwonders/game/wonders/Wonder.java
+++ /dev/null
@@ -1,102 +0,0 @@
-package org.luxons.sevenwonders.game.wonders;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.luxons.sevenwonders.game.api.Table;
-import org.luxons.sevenwonders.game.cards.CardBack;
-import org.luxons.sevenwonders.game.resources.ResourceTransactions;
-import org.luxons.sevenwonders.game.resources.ResourceType;
-
-public class Wonder {
-
- private String name;
-
- private ResourceType initialResource;
-
- private List<WonderStage> stages;
-
- private String image;
-
- public Wonder() {
- }
-
- public Wonder(String name, ResourceType initialResource, WonderStage... stages) {
- this.name = name;
- this.initialResource = initialResource;
- this.stages = Arrays.asList(stages);
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public ResourceType getInitialResource() {
- return initialResource;
- }
-
- public void setInitialResource(ResourceType initialResource) {
- this.initialResource = initialResource;
- }
-
- public List<WonderStage> getStages() {
- return stages;
- }
-
- public void setStages(List<WonderStage> stages) {
- this.stages = stages;
- }
-
- public int getNbBuiltStages() {
- return (int) stages.stream().filter(WonderStage::isBuilt).count();
- }
-
- public String getImage() {
- return image;
- }
-
- public void setImage(String image) {
- this.image = image;
- }
-
- public boolean isNextStageBuildable(Table table, int playerIndex, ResourceTransactions boughtResources) {
- int nextLevel = getNbBuiltStages();
- if (nextLevel == stages.size()) {
- return false;
- }
- return getNextStage().isBuildable(table, playerIndex, boughtResources);
- }
-
- public void buildLevel(CardBack cardBack) {
- getNextStage().build(cardBack);
- }
-
- private WonderStage getNextStage() {
- int nextLevel = getNbBuiltStages();
- if (nextLevel == stages.size()) {
- throw new IllegalStateException("This wonder has already reached its maximum level");
- }
- return stages.get(nextLevel);
- }
-
- public void activateLastBuiltStage(Table table, int playerIndex, ResourceTransactions boughtResources) {
- getLastBuiltStage().activate(table, playerIndex, boughtResources);
- }
-
- private WonderStage getLastBuiltStage() {
- int lastLevel = getNbBuiltStages() - 1;
- return stages.get(lastLevel);
- }
-
- public int computePoints(Table table, int playerIndex) {
- return stages.stream()
- .filter(WonderStage::isBuilt)
- .flatMap(c -> c.getEffects().stream())
- .mapToInt(e -> e.computePoints(table, playerIndex))
- .sum();
- }
-}
diff --git a/game-engine/src/main/java/org/luxons/sevenwonders/game/wonders/WonderStage.java b/game-engine/src/main/java/org/luxons/sevenwonders/game/wonders/WonderStage.java
deleted file mode 100644
index f4ec1140..00000000
--- a/game-engine/src/main/java/org/luxons/sevenwonders/game/wonders/WonderStage.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package org.luxons.sevenwonders.game.wonders;
-
-import java.util.List;
-
-import org.luxons.sevenwonders.game.api.Table;
-import org.luxons.sevenwonders.game.boards.Board;
-import org.luxons.sevenwonders.game.cards.CardBack;
-import org.luxons.sevenwonders.game.cards.Requirements;
-import org.luxons.sevenwonders.game.effects.Effect;
-import org.luxons.sevenwonders.game.resources.ResourceTransactions;
-
-public class WonderStage {
-
- private final Requirements requirements;
-
- private final List<Effect> effects;
-
- private CardBack cardBack;
-
- public WonderStage(Requirements requirements, List<Effect> effects) {
- this.requirements = requirements;
- this.effects = effects;
- }
-
- public Requirements getRequirements() {
- return requirements;
- }
-
- public List<Effect> getEffects() {
- return effects;
- }
-
- public CardBack getCardBack() {
- return cardBack;
- }
-
- public boolean isBuilt() {
- return cardBack != null;
- }
-
- public boolean isBuildable(Table table, int playerIndex, ResourceTransactions boughtResources) {
- Board board = table.getBoard(playerIndex);
- return requirements.areMetWithHelpBy(board, boughtResources);
- }
-
- void build(CardBack cardBack) {
- this.cardBack = cardBack;
- }
-
- void activate(Table table, int playerIndex, ResourceTransactions boughtResources) {
- effects.forEach(e -> e.apply(table, playerIndex));
- requirements.pay(table, playerIndex, boughtResources);
- }
-}
bgstack15