summaryrefslogtreecommitdiff
path: root/game-engine/src/main/java
diff options
context:
space:
mode:
authorjbion <joffrey.bion@amadeus.com>2018-07-07 16:27:47 +0200
committerjbion <joffrey.bion@amadeus.com>2018-07-07 23:40:44 +0200
commitb30630782ee35cfed275217324f28285ad39d715 (patch)
treebda9944ccf95b25c602408580b8c536cbeb009ab /game-engine/src/main/java
parentKotlin mig: Game class (diff)
downloadseven-wonders-b30630782ee35cfed275217324f28285ad39d715.tar.gz
seven-wonders-b30630782ee35cfed275217324f28285ad39d715.tar.bz2
seven-wonders-b30630782ee35cfed275217324f28285ad39d715.zip
Kotlin mig: effects package
Diffstat (limited to 'game-engine/src/main/java')
-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/Effect.java15
-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
12 files changed, 0 insertions, 445 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/Effect.java b/game-engine/src/main/java/org/luxons/sevenwonders/game/effects/Effect.java
deleted file mode 100644
index 692eaea0..00000000
--- a/game-engine/src/main/java/org/luxons/sevenwonders/game/effects/Effect.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package org.luxons.sevenwonders.game.effects;
-
-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 {
-
- void apply(Table table, int playerIndex);
-
- int computePoints(Table table, int playerIndex);
-}
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);
- }
-}
bgstack15