From 66bec3838bb82cf3109de9a5a688603f84dee528 Mon Sep 17 00:00:00 2001 From: jbion Date: Thu, 22 Dec 2016 14:47:04 +0100 Subject: Add BoughtResources representation --- .../sevenwonders/actions/PrepareCardAction.java | 2 +- .../java/org/luxons/sevenwonders/game/Game.java | 1 + .../java/org/luxons/sevenwonders/game/Move.java | 58 ---------------------- .../org/luxons/sevenwonders/game/MoveType.java | 5 -- .../sevenwonders/game/api/BoughtResources.java | 27 ++++++++++ .../org/luxons/sevenwonders/game/api/Move.java | 55 ++++++++++++++++++++ .../org/luxons/sevenwonders/game/api/MoveType.java | 5 ++ .../org/luxons/sevenwonders/game/api/Table.java | 1 - 8 files changed, 89 insertions(+), 65 deletions(-) delete mode 100644 src/main/java/org/luxons/sevenwonders/game/Move.java delete mode 100644 src/main/java/org/luxons/sevenwonders/game/MoveType.java create mode 100644 src/main/java/org/luxons/sevenwonders/game/api/BoughtResources.java create mode 100644 src/main/java/org/luxons/sevenwonders/game/api/Move.java create mode 100644 src/main/java/org/luxons/sevenwonders/game/api/MoveType.java (limited to 'src/main/java/org') diff --git a/src/main/java/org/luxons/sevenwonders/actions/PrepareCardAction.java b/src/main/java/org/luxons/sevenwonders/actions/PrepareCardAction.java index 8fd809a0..66ab8691 100644 --- a/src/main/java/org/luxons/sevenwonders/actions/PrepareCardAction.java +++ b/src/main/java/org/luxons/sevenwonders/actions/PrepareCardAction.java @@ -1,6 +1,6 @@ package org.luxons.sevenwonders.actions; -import org.luxons.sevenwonders.game.Move; +import org.luxons.sevenwonders.game.api.Move; public class PrepareCardAction { diff --git a/src/main/java/org/luxons/sevenwonders/game/Game.java b/src/main/java/org/luxons/sevenwonders/game/Game.java index 9023a80f..dd98f421 100644 --- a/src/main/java/org/luxons/sevenwonders/game/Game.java +++ b/src/main/java/org/luxons/sevenwonders/game/Game.java @@ -7,6 +7,7 @@ import java.util.Map; import java.util.stream.Collectors; import java.util.stream.IntStream; +import org.luxons.sevenwonders.game.api.Move; import org.luxons.sevenwonders.game.api.PlayerTurnInfo; import org.luxons.sevenwonders.game.api.Table; import org.luxons.sevenwonders.game.boards.Board; diff --git a/src/main/java/org/luxons/sevenwonders/game/Move.java b/src/main/java/org/luxons/sevenwonders/game/Move.java deleted file mode 100644 index f1fa97aa..00000000 --- a/src/main/java/org/luxons/sevenwonders/game/Move.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.luxons.sevenwonders.game; - -import java.util.HashMap; -import java.util.Map; - -import org.luxons.sevenwonders.game.api.Table; -import org.luxons.sevenwonders.game.resources.Resources; - -public class Move { - - private int playerIndex; - - private String cardName; - - private MoveType moveType; - - private Map boughtResources = new HashMap<>(); - - public int getPlayerIndex() { - return playerIndex; - } - - public void setPlayerIndex(int playerIndex) { - this.playerIndex = playerIndex; - } - - public String getCardName() { - return cardName; - } - - public void setCardName(String cardName) { - this.cardName = cardName; - } - - public MoveType getType() { - return moveType; - } - - public void setMoveType(MoveType moveType) { - this.moveType = moveType; - } - - public Map getBoughtResources() { - return boughtResources; - } - - public void setBoughtResources(Map boughtResources) { - this.boughtResources = boughtResources; - } - - public boolean isValid(Table table) { - if (moveType == MoveType.DISCARD) { - return true; - } - // TODO create a version of the Move class with actual card data? - return false; - } -} diff --git a/src/main/java/org/luxons/sevenwonders/game/MoveType.java b/src/main/java/org/luxons/sevenwonders/game/MoveType.java deleted file mode 100644 index b24d673c..00000000 --- a/src/main/java/org/luxons/sevenwonders/game/MoveType.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.luxons.sevenwonders.game; - -public enum MoveType { - PLAY, UPGRADE_WONDER, DISCARD -} diff --git a/src/main/java/org/luxons/sevenwonders/game/api/BoughtResources.java b/src/main/java/org/luxons/sevenwonders/game/api/BoughtResources.java new file mode 100644 index 00000000..01277cab --- /dev/null +++ b/src/main/java/org/luxons/sevenwonders/game/api/BoughtResources.java @@ -0,0 +1,27 @@ +package org.luxons.sevenwonders.game.api; + +import org.luxons.sevenwonders.game.boards.Provider; +import org.luxons.sevenwonders.game.resources.Resources; + +public class BoughtResources { + + private Provider provider; + + private 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; + } +} diff --git a/src/main/java/org/luxons/sevenwonders/game/api/Move.java b/src/main/java/org/luxons/sevenwonders/game/api/Move.java new file mode 100644 index 00000000..223f6615 --- /dev/null +++ b/src/main/java/org/luxons/sevenwonders/game/api/Move.java @@ -0,0 +1,55 @@ +package org.luxons.sevenwonders.game.api; + +import java.util.ArrayList; +import java.util.List; + +public class Move { + + private int playerIndex; + + private String cardName; + + private MoveType type; + + private List boughtResources = new ArrayList<>(); + + public int getPlayerIndex() { + return playerIndex; + } + + public void setPlayerIndex(int playerIndex) { + this.playerIndex = playerIndex; + } + + public String getCardName() { + return cardName; + } + + public void setCardName(String cardName) { + this.cardName = cardName; + } + + public MoveType getType() { + return type; + } + + public void setType(MoveType type) { + this.type = type; + } + + public List getBoughtResources() { + return boughtResources; + } + + public void setBoughtResources(List boughtResources) { + this.boughtResources = boughtResources; + } + + public boolean isValid(Table table) { + if (type == MoveType.DISCARD) { + return true; + } + // TODO create a version of the Move class with actual card data? + return false; + } +} diff --git a/src/main/java/org/luxons/sevenwonders/game/api/MoveType.java b/src/main/java/org/luxons/sevenwonders/game/api/MoveType.java new file mode 100644 index 00000000..66f2331a --- /dev/null +++ b/src/main/java/org/luxons/sevenwonders/game/api/MoveType.java @@ -0,0 +1,5 @@ +package org.luxons.sevenwonders.game.api; + +public enum MoveType { + PLAY, UPGRADE_WONDER, DISCARD +} diff --git a/src/main/java/org/luxons/sevenwonders/game/api/Table.java b/src/main/java/org/luxons/sevenwonders/game/api/Table.java index 7603f532..2ef27a2a 100644 --- a/src/main/java/org/luxons/sevenwonders/game/api/Table.java +++ b/src/main/java/org/luxons/sevenwonders/game/api/Table.java @@ -2,7 +2,6 @@ package org.luxons.sevenwonders.game.api; import java.util.List; -import org.luxons.sevenwonders.game.Move; import org.luxons.sevenwonders.game.boards.Board; import org.luxons.sevenwonders.game.boards.RelativeBoardPosition; import org.luxons.sevenwonders.game.cards.Card; -- cgit