diff options
author | Joffrey Bion <joffrey.bion@amadeus.com> | 2018-04-27 18:44:31 +0200 |
---|---|---|
committer | Joffrey BION <joffrey.bion@gmail.com> | 2018-04-27 21:52:33 +0200 |
commit | 5794738944e822760c0648e1bc41cbab95497add (patch) | |
tree | 22052285a4683effa2a30eb7b8a3de87e9b1cfe2 /game-engine/src/main | |
parent | Use independent WS clients for each test to prevent race conditions on CI (diff) | |
download | seven-wonders-5794738944e822760c0648e1bc41cbab95497add.tar.gz seven-wonders-5794738944e822760c0648e1bc41cbab95497add.tar.bz2 seven-wonders-5794738944e822760c0648e1bc41cbab95497add.zip |
Bought resources refactoring
Diffstat (limited to 'game-engine/src/main')
14 files changed, 188 insertions, 133 deletions
diff --git a/game-engine/src/main/java/org/luxons/sevenwonders/game/api/PlayerMove.java b/game-engine/src/main/java/org/luxons/sevenwonders/game/api/PlayerMove.java index bad8f852..807e51a9 100644 --- a/game-engine/src/main/java/org/luxons/sevenwonders/game/api/PlayerMove.java +++ b/game-engine/src/main/java/org/luxons/sevenwonders/game/api/PlayerMove.java @@ -1,10 +1,10 @@ package org.luxons.sevenwonders.game.api; import java.util.ArrayList; -import java.util.List; +import java.util.Collection; import org.luxons.sevenwonders.game.moves.MoveType; -import org.luxons.sevenwonders.game.resources.BoughtResources; +import org.luxons.sevenwonders.game.resources.ResourceTransaction; public class PlayerMove { @@ -12,7 +12,7 @@ public class PlayerMove { private String cardName; - private List<BoughtResources> boughtResources = new ArrayList<>(); + private Collection<ResourceTransaction> transactions = new ArrayList<>(); public MoveType getType() { return type; @@ -30,12 +30,12 @@ public class PlayerMove { this.cardName = cardName; } - public List<BoughtResources> getBoughtResources() { - return boughtResources; + public Collection<ResourceTransaction> getTransactions() { + return transactions; } - public void setBoughtResources(List<BoughtResources> boughtResources) { - this.boughtResources = boughtResources; + public void setTransactions(Collection<ResourceTransaction> transactions) { + this.transactions = transactions; } @Override diff --git a/game-engine/src/main/java/org/luxons/sevenwonders/game/cards/Card.java b/game-engine/src/main/java/org/luxons/sevenwonders/game/cards/Card.java index 084d19a5..2d2f6777 100644 --- a/game-engine/src/main/java/org/luxons/sevenwonders/game/cards/Card.java +++ b/game-engine/src/main/java/org/luxons/sevenwonders/game/cards/Card.java @@ -6,7 +6,7 @@ import java.util.Objects; import org.luxons.sevenwonders.game.api.Table; import org.luxons.sevenwonders.game.boards.Board; import org.luxons.sevenwonders.game.effects.Effect; -import org.luxons.sevenwonders.game.resources.BoughtResources; +import org.luxons.sevenwonders.game.resources.ResourceTransactions; public class Card { @@ -93,13 +93,13 @@ public class Card { if (!isAllowedOnBoard(board)) { return false; } - return isChainableOn(board) || requirements.couldBeMetBy(table, playerIndex); + return isChainableOn(board) || requirements.areMetBy(table, playerIndex); } - public void applyTo(Table table, int playerIndex, List<BoughtResources> boughtResources) { + public void applyTo(Table table, int playerIndex, ResourceTransactions transactions) { Board playerBoard = table.getBoard(playerIndex); if (!isChainableOn(playerBoard)) { - requirements.pay(table, playerIndex, boughtResources); + requirements.pay(table, playerIndex, transactions); } effects.forEach(e -> e.apply(table, playerIndex)); } diff --git a/game-engine/src/main/java/org/luxons/sevenwonders/game/cards/Requirements.java b/game-engine/src/main/java/org/luxons/sevenwonders/game/cards/Requirements.java index 3f9c4409..8c7245ed 100644 --- a/game-engine/src/main/java/org/luxons/sevenwonders/game/cards/Requirements.java +++ b/game-engine/src/main/java/org/luxons/sevenwonders/game/cards/Requirements.java @@ -1,12 +1,9 @@ package org.luxons.sevenwonders.game.cards; -import java.util.List; - import org.luxons.sevenwonders.game.api.Table; import org.luxons.sevenwonders.game.boards.Board; -import org.luxons.sevenwonders.game.boards.RelativeBoardPosition; import org.luxons.sevenwonders.game.resources.BestPriceCalculator; -import org.luxons.sevenwonders.game.resources.BoughtResources; +import org.luxons.sevenwonders.game.resources.ResourceTransactions; import org.luxons.sevenwonders.game.resources.Resources; public class Requirements { @@ -53,7 +50,7 @@ public class Requirements { * * @return true if the given board meets these requirements */ - public boolean areMetWithHelpBy(Board board, List<BoughtResources> boughtResources) { + public boolean areMetWithHelpBy(Board board, ResourceTransactions boughtResources) { if (!hasRequiredGold(board, boughtResources)) { return false; } @@ -64,7 +61,7 @@ public class Requirements { } /** - * Returns whether the given player's board could meet these requirements, on its own or by buying resources to + * Returns whether the given player's board meets these requirements, either on its own or by buying resources to * neighbours. * * @param table @@ -74,7 +71,7 @@ public class Requirements { * * @return true if the given player's board could meet these requirements */ - boolean couldBeMetBy(Table table, int playerIndex) { + boolean areMetBy(Table table, int playerIndex) { Board board = table.getBoard(playerIndex); if (!hasRequiredGold(board)) { return false; @@ -89,8 +86,8 @@ public class Requirements { return board.getGold() >= gold; } - private boolean hasRequiredGold(Board board, List<BoughtResources> boughtResources) { - int resourcesPrice = board.getTradingRules().computeCost(boughtResources); + private boolean hasRequiredGold(Board board, ResourceTransactions resourceTransactions) { + int resourcesPrice = board.getTradingRules().computeCost(resourceTransactions); return board.getGold() >= gold + resourcesPrice; } @@ -98,34 +95,14 @@ public class Requirements { return board.getProduction().contains(resources); } - private boolean producesRequiredResourcesWithHelp(Board board, List<BoughtResources> boughtResources) { - Resources totalBoughtResources = getTotalResources(boughtResources); + private boolean producesRequiredResourcesWithHelp(Board board, ResourceTransactions transactions) { + Resources totalBoughtResources = transactions.asResources(); Resources remainingResources = this.resources.minus(totalBoughtResources); return board.getProduction().contains(remainingResources); } - private static Resources getTotalResources(List<BoughtResources> boughtResources) { - return boughtResources.stream().map(BoughtResources::getResources).reduce(new Resources(), (r1, r2) -> { - r1.addAll(r2); - return r1; - }); - } - - public void pay(Table table, int playerIndex, List<BoughtResources> boughtResources) { + public void pay(Table table, int playerIndex, ResourceTransactions transactions) { table.getBoard(playerIndex).removeGold(gold); - payBoughtResources(table, playerIndex, boughtResources); - } - - private void payBoughtResources(Table table, int playerIndex, List<BoughtResources> boughtResourcesList) { - boughtResourcesList.forEach(res -> payBoughtResources(table, playerIndex, res)); - } - - private void payBoughtResources(Table table, int playerIndex, BoughtResources boughtResources) { - Board board = table.getBoard(playerIndex); - int price = board.getTradingRules().computeCost(boughtResources); - board.removeGold(price); - RelativeBoardPosition providerPosition = boughtResources.getProvider().getBoardPosition(); - Board providerBoard = table.getBoard(playerIndex, providerPosition); - providerBoard.addGold(price); + transactions.execute(table, playerIndex); } } diff --git a/game-engine/src/main/java/org/luxons/sevenwonders/game/moves/BuildWonderMove.java b/game-engine/src/main/java/org/luxons/sevenwonders/game/moves/BuildWonderMove.java index f1cb50b3..f70d2626 100644 --- a/game-engine/src/main/java/org/luxons/sevenwonders/game/moves/BuildWonderMove.java +++ b/game-engine/src/main/java/org/luxons/sevenwonders/game/moves/BuildWonderMove.java @@ -18,7 +18,7 @@ public class BuildWonderMove extends CardFromHandMove { public void validate(Table table, List<Card> playerHand) throws InvalidMoveException { super.validate(table, playerHand); Board board = table.getBoard(getPlayerIndex()); - if (!board.getWonder().isNextStageBuildable(table, getPlayerIndex(), getBoughtResources())) { + if (!board.getWonder().isNextStageBuildable(table, getPlayerIndex(), getTransactions())) { throw new InvalidMoveException( String.format("Player %d cannot upgrade his wonder with the given resources", getPlayerIndex())); } @@ -34,6 +34,6 @@ public class BuildWonderMove extends CardFromHandMove { public void activate(Table table, List<Card> discardedCards, Settings settings) { int playerIndex = getPlayerIndex(); Board board = table.getBoard(playerIndex); - board.getWonder().activateLastBuiltStage(table, playerIndex, getBoughtResources()); + board.getWonder().activateLastBuiltStage(table, playerIndex, getTransactions()); } } diff --git a/game-engine/src/main/java/org/luxons/sevenwonders/game/moves/Move.java b/game-engine/src/main/java/org/luxons/sevenwonders/game/moves/Move.java index 230b9ef1..cfb12e67 100644 --- a/game-engine/src/main/java/org/luxons/sevenwonders/game/moves/Move.java +++ b/game-engine/src/main/java/org/luxons/sevenwonders/game/moves/Move.java @@ -6,7 +6,7 @@ import org.luxons.sevenwonders.game.Settings; import org.luxons.sevenwonders.game.api.PlayerMove; import org.luxons.sevenwonders.game.api.Table; import org.luxons.sevenwonders.game.cards.Card; -import org.luxons.sevenwonders.game.resources.BoughtResources; +import org.luxons.sevenwonders.game.resources.ResourceTransactions; public abstract class Move { @@ -16,13 +16,13 @@ public abstract class Move { private MoveType type; - private List<BoughtResources> boughtResources; + private ResourceTransactions transactions; Move(int playerIndex, Card card, PlayerMove move) { this.playerIndex = playerIndex; this.card = card; this.type = move.getType(); - this.boughtResources = move.getBoughtResources(); + this.transactions = new ResourceTransactions(move.getTransactions()); } public int getPlayerIndex() { @@ -37,8 +37,8 @@ public abstract class Move { return type; } - public List<BoughtResources> getBoughtResources() { - return boughtResources; + public ResourceTransactions getTransactions() { + return transactions; } public abstract void validate(Table table, List<Card> playerHand) throws InvalidMoveException; diff --git a/game-engine/src/main/java/org/luxons/sevenwonders/game/moves/PlayCardMove.java b/game-engine/src/main/java/org/luxons/sevenwonders/game/moves/PlayCardMove.java index 82052981..18d6ba90 100644 --- a/game-engine/src/main/java/org/luxons/sevenwonders/game/moves/PlayCardMove.java +++ b/game-engine/src/main/java/org/luxons/sevenwonders/game/moves/PlayCardMove.java @@ -19,7 +19,7 @@ public class PlayCardMove extends CardFromHandMove { super.validate(table, playerHand); Board board = table.getBoard(getPlayerIndex()); if (!getCard().isChainableOn(board) && !getCard().getRequirements() - .areMetWithHelpBy(board, getBoughtResources())) { + .areMetWithHelpBy(board, getTransactions())) { throw new InvalidMoveException( String.format("Player %d cannot play the card %s with the given resources", getPlayerIndex(), getCard().getName())); @@ -34,6 +34,6 @@ public class PlayCardMove extends CardFromHandMove { @Override public void activate(Table table, List<Card> discardedCards, Settings settings) { - getCard().applyTo(table, getPlayerIndex(), getBoughtResources()); + getCard().applyTo(table, getPlayerIndex(), getTransactions()); } } diff --git a/game-engine/src/main/java/org/luxons/sevenwonders/game/resources/BestPriceCalculator.java b/game-engine/src/main/java/org/luxons/sevenwonders/game/resources/BestPriceCalculator.java index bde6dcb9..10ac8343 100644 --- a/game-engine/src/main/java/org/luxons/sevenwonders/game/resources/BestPriceCalculator.java +++ b/game-engine/src/main/java/org/luxons/sevenwonders/game/resources/BestPriceCalculator.java @@ -14,11 +14,11 @@ public class BestPriceCalculator { private final List<ResourcePool> pools; - private final List<BoughtResources> boughtResources; + private final ResourceTransactions boughtResources; private int pricePaid; - private List<BoughtResources> bestSolution; + private ResourceTransactions bestSolution; private int bestPrice; @@ -26,7 +26,7 @@ public class BestPriceCalculator { Board board = table.getBoard(playerIndex); this.resourcesLeftToPay = resourcesToPay.minus(board.getProduction().getFixedResources()); this.pools = createResourcePools(table, playerIndex); - this.boughtResources = new ArrayList<>(); + this.boughtResources = new ResourceTransactions(); this.pricePaid = 0; this.bestSolution = null; this.bestPrice = Integer.MAX_VALUE; @@ -56,10 +56,10 @@ public class BestPriceCalculator { return bestPriceCalculator.bestPrice; } - public static List<BoughtResources> bestSolution(Resources resources, Table table, int playerIndex) { - BestPriceCalculator bestPriceCalculator = new BestPriceCalculator(resources, table, playerIndex); - bestPriceCalculator.computePossibilities(); - return bestPriceCalculator.bestSolution; + public static ResourceTransactions bestSolution(Resources resources, Table table, int playerIndex) { + BestPriceCalculator calculator = new BestPriceCalculator(resources, table, playerIndex); + calculator.computePossibilities(); + return calculator.bestSolution; } private void computePossibilities() { @@ -77,15 +77,14 @@ public class BestPriceCalculator { resourcesLeftToPay.add(type, 1); continue; } - BoughtResources boughtRes = new BoughtResources(pool.getProvider(), Resources.of(type)); int cost = pool.getCost(type); resourcesLeftToPay.remove(type, 1); - boughtResources.add(boughtRes); + boughtResources.add(pool.getProvider(), Resources.of(type)); pricePaid += cost; computePossibilitiesWhenUsing(type, pool); pricePaid -= cost; - boughtResources.remove(boughtRes); + boughtResources.remove(pool.getProvider(), Resources.of(type)); resourcesLeftToPay.add(type, 1); } } @@ -106,7 +105,7 @@ public class BestPriceCalculator { private void updateBestSolutionIfNeeded() { if (pricePaid < bestPrice) { bestPrice = pricePaid; - bestSolution = new ArrayList<>(boughtResources); + bestSolution = new ResourceTransactions(boughtResources.toTransactions()); } } } diff --git a/game-engine/src/main/java/org/luxons/sevenwonders/game/resources/BoughtResources.java b/game-engine/src/main/java/org/luxons/sevenwonders/game/resources/BoughtResources.java deleted file mode 100644 index 71293190..00000000 --- a/game-engine/src/main/java/org/luxons/sevenwonders/game/resources/BoughtResources.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.luxons.sevenwonders.game.resources; - -import java.util.Objects; - -public class BoughtResources { - - private Provider provider; - - private Resources resources; - - public BoughtResources() { - } - - public BoughtResources(Provider provider, Resources resources) { - this.provider = provider; - this.resources = resources; - } - - public Provider getProvider() { - return provider; - } - - public void setProvider(Provider provider) { - this.provider = provider; - } - - public Resources getResources() { - return resources; - } - - public void setResources(Resources resources) { - this.resources = resources; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - BoughtResources that = (BoughtResources) o; - return provider == that.provider && Objects.equals(resources, that.resources); - } - - @Override - public int hashCode() { - return Objects.hash(provider, resources); - } - - @Override - public String toString() { - return "BoughtResources{" + "provider=" + provider + ", resources=" + resources + '}'; - } -} diff --git a/game-engine/src/main/java/org/luxons/sevenwonders/game/resources/ResourceTransaction.java b/game-engine/src/main/java/org/luxons/sevenwonders/game/resources/ResourceTransaction.java new file mode 100644 index 00000000..3cb8eea1 --- /dev/null +++ b/game-engine/src/main/java/org/luxons/sevenwonders/game/resources/ResourceTransaction.java @@ -0,0 +1,53 @@ +package org.luxons.sevenwonders.game.resources; + +import java.util.Objects; + +import org.luxons.sevenwonders.game.api.Table; +import org.luxons.sevenwonders.game.boards.Board; +import org.luxons.sevenwonders.game.boards.RelativeBoardPosition; + +public class ResourceTransaction { + + private final Provider provider; + + private final Resources resources; + + public ResourceTransaction(Provider provider, Resources resources) { + this.provider = provider; + this.resources = resources; + } + + public Provider getProvider() { + return provider; + } + + public Resources getResources() { + return resources; + } + + void execute(Table table, int playerIndex) { + Board board = table.getBoard(playerIndex); + int price = board.getTradingRules().computeCost(this); + board.removeGold(price); + RelativeBoardPosition providerPosition = provider.getBoardPosition(); + Board providerBoard = table.getBoard(playerIndex, providerPosition); + providerBoard.addGold(price); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ResourceTransaction that = (ResourceTransaction) o; + return provider == that.provider && Objects.equals(resources, that.resources); + } + + @Override + public int hashCode() { + return Objects.hash(provider, resources); + } +} diff --git a/game-engine/src/main/java/org/luxons/sevenwonders/game/resources/ResourceTransactions.java b/game-engine/src/main/java/org/luxons/sevenwonders/game/resources/ResourceTransactions.java new file mode 100644 index 00000000..a8fdc6c7 --- /dev/null +++ b/game-engine/src/main/java/org/luxons/sevenwonders/game/resources/ResourceTransactions.java @@ -0,0 +1,71 @@ +package org.luxons.sevenwonders.game.resources; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.stream.Collectors; + +import org.luxons.sevenwonders.game.api.Table; + +public class ResourceTransactions { + + private final Map<Provider, Resources> resourcesByProvider; + + public ResourceTransactions() { + this.resourcesByProvider = new HashMap<>(); + } + + public ResourceTransactions(Collection<ResourceTransaction> transactions) { + this(); + transactions.forEach(t -> add(t.getProvider(), t.getResources())); + } + + public void add(Provider provider, Resources resources) { + resourcesByProvider.putIfAbsent(provider, new Resources()); + resourcesByProvider.merge(provider, resources, Resources::addAll); + } + + public void remove(Provider provider, Resources resources) { + resourcesByProvider.compute(provider, (p, prevResources) -> { + if (prevResources == null) { + throw new IllegalStateException("Cannot remove resources from resource transactions"); + } + return prevResources.minus(resources); + }); + } + + public void execute(Table table, int playerIndex) { + toTransactions().forEach(t -> t.execute(table, playerIndex)); + } + + public Set<ResourceTransaction> toTransactions() { + return resourcesByProvider.entrySet() + .stream() + .filter(e -> !e.getValue().isEmpty()) + .map(e -> new ResourceTransaction(e.getKey(), e.getValue())) + .collect(Collectors.toSet()); + } + + public Resources asResources() { + return resourcesByProvider.values().stream().reduce(new Resources(), Resources::addAll); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ResourceTransactions that = (ResourceTransactions) o; + return Objects.equals(resourcesByProvider, that.resourcesByProvider); + } + + @Override + public int hashCode() { + return Objects.hash(resourcesByProvider); + } +} diff --git a/game-engine/src/main/java/org/luxons/sevenwonders/game/resources/Resources.java b/game-engine/src/main/java/org/luxons/sevenwonders/game/resources/Resources.java index 1b263760..d354f121 100644 --- a/game-engine/src/main/java/org/luxons/sevenwonders/game/resources/Resources.java +++ b/game-engine/src/main/java/org/luxons/sevenwonders/game/resources/Resources.java @@ -32,8 +32,9 @@ public class Resources { quantities.computeIfPresent(type, (t, oldQty) -> oldQty - quantity); } - public void addAll(Resources resources) { + public Resources addAll(Resources resources) { resources.quantities.forEach(this::add); + return this; } public int getQuantity(ResourceType type) { @@ -55,6 +56,13 @@ public class Resources { return quantity.getValue() <= getQuantity(quantity.getKey()); } + public Resources plus(Resources resources) { + Resources merged = new Resources(); + merged.addAll(this); + merged.addAll(resources); + return merged; + } + /** * Creates new {@link Resources} object containing these resources minus the given resources. * diff --git a/game-engine/src/main/java/org/luxons/sevenwonders/game/resources/TradingRules.java b/game-engine/src/main/java/org/luxons/sevenwonders/game/resources/TradingRules.java index 8cd1d9bc..ffbce8ab 100644 --- a/game-engine/src/main/java/org/luxons/sevenwonders/game/resources/TradingRules.java +++ b/game-engine/src/main/java/org/luxons/sevenwonders/game/resources/TradingRules.java @@ -1,7 +1,6 @@ package org.luxons.sevenwonders.game.resources; import java.util.EnumMap; -import java.util.List; import java.util.Map; public class TradingRules { @@ -26,13 +25,17 @@ public class TradingRules { costs.computeIfAbsent(type, t -> new EnumMap<>(Provider.class)).put(provider, cost); } - public int computeCost(List<BoughtResources> boughtResources) { - return boughtResources.stream().mapToInt(this::computeCost).sum(); + public int computeCost(ResourceTransactions transactions) { + return transactions.toTransactions().stream().mapToInt(this::computeCost).sum(); } - public int computeCost(BoughtResources boughtResources) { - Resources resources = boughtResources.getResources(); - Provider provider = boughtResources.getProvider(); + int computeCost(ResourceTransaction transaction) { + Resources resources = transaction.getResources(); + Provider provider = transaction.getProvider(); + return computeCost(resources, provider); + } + + private int computeCost(Resources resources, Provider provider) { int total = 0; for (ResourceType type : ResourceType.values()) { int count = resources.getQuantity(type); 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 index 73fff305..dd0170da 100644 --- 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 @@ -5,7 +5,7 @@ import java.util.List; import org.luxons.sevenwonders.game.api.Table; import org.luxons.sevenwonders.game.cards.CardBack; -import org.luxons.sevenwonders.game.resources.BoughtResources; +import org.luxons.sevenwonders.game.resources.ResourceTransactions; import org.luxons.sevenwonders.game.resources.ResourceType; public class Wonder { @@ -63,7 +63,7 @@ public class Wonder { this.image = image; } - public boolean isNextStageBuildable(Table table, int playerIndex, List<BoughtResources> boughtResources) { + public boolean isNextStageBuildable(Table table, int playerIndex, ResourceTransactions boughtResources) { int nextLevel = getNbBuiltStages(); if (nextLevel == stages.size()) { return false; @@ -83,7 +83,7 @@ public class Wonder { return stages.get(nextLevel); } - public void activateLastBuiltStage(Table table, int playerIndex, List<BoughtResources> boughtResources) { + public void activateLastBuiltStage(Table table, int playerIndex, ResourceTransactions boughtResources) { getLastBuiltStage().activate(table, playerIndex, boughtResources); } 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 index a53e2694..f4ec1140 100644 --- 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 @@ -7,7 +7,7 @@ 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.BoughtResources; +import org.luxons.sevenwonders.game.resources.ResourceTransactions; public class WonderStage { @@ -38,7 +38,7 @@ public class WonderStage { return cardBack != null; } - public boolean isBuildable(Table table, int playerIndex, List<BoughtResources> boughtResources) { + public boolean isBuildable(Table table, int playerIndex, ResourceTransactions boughtResources) { Board board = table.getBoard(playerIndex); return requirements.areMetWithHelpBy(board, boughtResources); } @@ -47,7 +47,7 @@ public class WonderStage { this.cardBack = cardBack; } - void activate(Table table, int playerIndex, List<BoughtResources> boughtResources) { + void activate(Table table, int playerIndex, ResourceTransactions boughtResources) { effects.forEach(e -> e.apply(table, playerIndex)); requirements.pay(table, playerIndex, boughtResources); } |