diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/luxons/sevenwonders/game/data/GameData.java | 60 | ||||
-rw-r--r-- | src/main/java/org/luxons/sevenwonders/game/data/GameDataLoader.java | 49 | ||||
-rw-r--r-- | src/main/java/org/luxons/sevenwonders/game/effects/ScienceProgress.java (renamed from src/main/java/org/luxons/sevenwonders/game/effects/ScienceIncrease.java) | 2 | ||||
-rw-r--r-- | src/main/java/org/luxons/sevenwonders/game/wonders/Wonder.java | 27 | ||||
-rw-r--r-- | src/test/java/org/luxons/sevenwonders/game/cards/CardTest.java | 6 | ||||
-rw-r--r-- | src/test/java/org/luxons/sevenwonders/game/effects/EffectTest.java | 6 |
6 files changed, 140 insertions, 10 deletions
diff --git a/src/main/java/org/luxons/sevenwonders/game/data/GameData.java b/src/main/java/org/luxons/sevenwonders/game/data/GameData.java new file mode 100644 index 00000000..70a64eef --- /dev/null +++ b/src/main/java/org/luxons/sevenwonders/game/data/GameData.java @@ -0,0 +1,60 @@ +package org.luxons.sevenwonders.game.data; + +import java.util.ArrayList; +import java.util.List; + +import org.luxons.sevenwonders.game.cards.Card; +import org.luxons.sevenwonders.game.wonders.Wonder; + +public class GameData { + + private int nbAges = 3; + + private int minPlayers = 3; + + private int maxPlayers = 7; + + private List<Wonder> wonders = new ArrayList<>(); + + private List<List<Card>> cardsPerAge = new ArrayList<>(); + + public int getNbAges() { + return nbAges; + } + + public void setNbAges(int nbAges) { + this.nbAges = nbAges; + } + + public int getMinPlayers() { + return minPlayers; + } + + public void setMinPlayers(int minPlayers) { + this.minPlayers = minPlayers; + } + + public int getMaxPlayers() { + return maxPlayers; + } + + public void setMaxPlayers(int maxPlayers) { + this.maxPlayers = maxPlayers; + } + + public List<Wonder> getWonders() { + return wonders; + } + + public void setWonders(List<Wonder> wonders) { + this.wonders = wonders; + } + + public List<Card> getCards(int age) { + return cardsPerAge.get(age - 1); // 0-based + } + + public void setCards(int age, List<Card> cards) { + cardsPerAge.set(age - 1, cards); // 0-based + } +} diff --git a/src/main/java/org/luxons/sevenwonders/game/data/GameDataLoader.java b/src/main/java/org/luxons/sevenwonders/game/data/GameDataLoader.java new file mode 100644 index 00000000..3047b900 --- /dev/null +++ b/src/main/java/org/luxons/sevenwonders/game/data/GameDataLoader.java @@ -0,0 +1,49 @@ +package org.luxons.sevenwonders.game.data; + +import java.util.ArrayList; +import java.util.List; + +import org.luxons.sevenwonders.game.cards.Card; +import org.luxons.sevenwonders.game.cards.Color; +import org.luxons.sevenwonders.game.cards.Requirements; +import org.luxons.sevenwonders.game.effects.GoldIncrease; +import org.luxons.sevenwonders.game.effects.RawPointsIncrease; +import org.luxons.sevenwonders.game.effects.ScienceProgress; +import org.luxons.sevenwonders.game.resources.ResourceType; +import org.luxons.sevenwonders.game.wonders.Wonder; + +public class GameDataLoader { + + private static final String wondersFile = "wonders.json"; + + public static GameData load() { + GameData data = new GameData(); + data.setWonders(loadWonders()); + for (int age = 1; age <= data.getNbAges(); age++) { + data.setCards(age, loadCards(age)); + } + return data; + } + + private static List<Wonder> loadWonders() { + List<Wonder> wonders = new ArrayList<>(); + // TODO load actual file + wonders.add(new Wonder("TestWonder W", ResourceType.WOOD)); + wonders.add(new Wonder("TestWonder S", ResourceType.STONE)); + wonders.add(new Wonder("TestWonder O", ResourceType.ORE)); + wonders.add(new Wonder("TestWonder C", ResourceType.CLAY)); + wonders.add(new Wonder("TestWonder G", ResourceType.GLASS)); + wonders.add(new Wonder("TestWonder L", ResourceType.LOOM)); + wonders.add(new Wonder("TestWonder P", ResourceType.PAPYRUS)); + return wonders; + } + + private static List<Card> loadCards(int age) { + List<Card> wonders = new ArrayList<>(); + // TODO load actual file + wonders.add(new Card("TestCard Yellow", Color.YELLOW, new Requirements(), new GoldIncrease())); + wonders.add(new Card("TestCard Blue", Color.BLUE, new Requirements(), new RawPointsIncrease())); + wonders.add(new Card("TestCard Green", Color.GREEN, new Requirements(), new ScienceProgress())); + return wonders; + } +} diff --git a/src/main/java/org/luxons/sevenwonders/game/effects/ScienceIncrease.java b/src/main/java/org/luxons/sevenwonders/game/effects/ScienceProgress.java index 4e3944cf..8feba09d 100644 --- a/src/main/java/org/luxons/sevenwonders/game/effects/ScienceIncrease.java +++ b/src/main/java/org/luxons/sevenwonders/game/effects/ScienceProgress.java @@ -3,7 +3,7 @@ package org.luxons.sevenwonders.game.effects; import org.luxons.sevenwonders.game.boards.Board; import org.luxons.sevenwonders.game.boards.Science; -public class ScienceIncrease extends InstantEffect { +public class ScienceProgress extends InstantEffect { private Science science; diff --git a/src/main/java/org/luxons/sevenwonders/game/wonders/Wonder.java b/src/main/java/org/luxons/sevenwonders/game/wonders/Wonder.java index 3a3d0e97..27d06435 100644 --- a/src/main/java/org/luxons/sevenwonders/game/wonders/Wonder.java +++ b/src/main/java/org/luxons/sevenwonders/game/wonders/Wonder.java @@ -7,20 +7,41 @@ import org.luxons.sevenwonders.game.resources.ResourceType; public class Wonder { - private final ResourceType initialResource; + private String name; - private final List<WonderLevel> levels; + private ResourceType initialResource; - public Wonder(ResourceType initialResource, WonderLevel... levels) { + private List<WonderLevel> levels; + + public Wonder() { + } + + public Wonder(String name, ResourceType initialResource, WonderLevel... levels) { this.initialResource = initialResource; this.levels = Arrays.asList(levels); } + 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<WonderLevel> getLevels() { return levels; } + + public void setLevels(List<WonderLevel> levels) { + this.levels = levels; + } } diff --git a/src/test/java/org/luxons/sevenwonders/game/cards/CardTest.java b/src/test/java/org/luxons/sevenwonders/game/cards/CardTest.java index db11c466..db4eb049 100644 --- a/src/test/java/org/luxons/sevenwonders/game/cards/CardTest.java +++ b/src/test/java/org/luxons/sevenwonders/game/cards/CardTest.java @@ -24,9 +24,9 @@ public class CardTest { @Before public void initBoard() { Settings settings = new Settings(); - board = new Board(new Wonder(ResourceType.WOOD), settings); - leftBoard = new Board(new Wonder(ResourceType.STONE), settings); - rightBoard = new Board(new Wonder(ResourceType.PAPYRUS), settings); + board = new Board(new Wonder("TestWonder", ResourceType.WOOD), settings); + leftBoard = new Board(new Wonder("TestWonder", ResourceType.STONE), settings); + rightBoard = new Board(new Wonder("TestWonder", ResourceType.PAPYRUS), settings); Requirements treeFarmRequirements = new Requirements(); treeFarmRequirements.setGoldCost(1); diff --git a/src/test/java/org/luxons/sevenwonders/game/effects/EffectTest.java b/src/test/java/org/luxons/sevenwonders/game/effects/EffectTest.java index 51a7a192..25dfcf38 100644 --- a/src/test/java/org/luxons/sevenwonders/game/effects/EffectTest.java +++ b/src/test/java/org/luxons/sevenwonders/game/effects/EffectTest.java @@ -32,9 +32,9 @@ public class EffectTest { Settings settings = new Settings(); settings.setInitialGold(INITIAL_GOLD); - board = new Board(new Wonder(ResourceType.WOOD), settings); - leftBoard = new Board(new Wonder(ResourceType.STONE), settings); - rightBoard = new Board(new Wonder(ResourceType.PAPYRUS), settings); + board = new Board(new Wonder("TestWonder", ResourceType.WOOD), settings); + leftBoard = new Board(new Wonder("TestWonder", ResourceType.STONE), settings); + rightBoard = new Board(new Wonder("TestWonder", ResourceType.PAPYRUS), settings); resources1Stone1Wood = new Resources(); resources1Stone1Wood.add(ResourceType.STONE, 1); |