diff options
author | Joffrey BION <joffrey.bion@gmail.com> | 2016-12-07 23:36:33 +0100 |
---|---|---|
committer | Joffrey BION <joffrey.bion@gmail.com> | 2016-12-08 02:11:15 +0100 |
commit | 066e4159dc4aadf63eb4d3b8c61da1f85158020b (patch) | |
tree | 6a9ae6575b58e444278601679bb3329d955deebf /src/main/java/org/luxons | |
parent | First draft of the game engine: boards, card effects, costs (diff) | |
download | seven-wonders-066e4159dc4aadf63eb4d3b8c61da1f85158020b.tar.gz seven-wonders-066e4159dc4aadf63eb4d3b8c61da1f85158020b.tar.bz2 seven-wonders-066e4159dc4aadf63eb4d3b8c61da1f85158020b.zip |
Add game data loading skeleton
Diffstat (limited to 'src/main/java/org/luxons')
-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 |
4 files changed, 134 insertions, 4 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; + } } |