initial commit
This commit is contained in:
23
src/main/java/cz/jull/Game.java
Normal file
23
src/main/java/cz/jull/Game.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package cz.jull;
|
||||
|
||||
import cz.jull.surroundings.ForestType;
|
||||
import cz.jull.surroundings.PathType;
|
||||
import cz.jull.surroundings.SoilType;
|
||||
import cz.jull.surroundings.WaterType;
|
||||
|
||||
public class Game {
|
||||
private Player player = new Player();
|
||||
private ForestType forestType;
|
||||
private WaterType waterType;
|
||||
private SoilType soilType;
|
||||
private PathType pathType;
|
||||
|
||||
public void generateStats() {
|
||||
forestType = ForestType.getRandom();
|
||||
waterType = WaterType.getRandom();
|
||||
soilType = SoilType.getRandom();
|
||||
pathType = PathType.getRandom();
|
||||
|
||||
player.setCoins(10000);
|
||||
}
|
||||
}
|
||||
32
src/main/java/cz/jull/Item.java
Normal file
32
src/main/java/cz/jull/Item.java
Normal file
@@ -0,0 +1,32 @@
|
||||
package cz.jull;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum Item {
|
||||
AXE("Axe"),
|
||||
SCYTHE("Scythe"),
|
||||
|
||||
WOOD("Wood"),
|
||||
|
||||
WHEAT("Wheat"),
|
||||
GRAPES("Grapes"),
|
||||
HOPS("Hops"),
|
||||
|
||||
MILK("Milk"),
|
||||
|
||||
VINEYARD("Vineyard"),
|
||||
FARMLAND("Farmland"),
|
||||
|
||||
FENCE_WITH_COWS("Fence with cows"),
|
||||
|
||||
VILLAGER_HOUSE("Villager house"),
|
||||
CHURCH("Church"),
|
||||
PUB("Pub");
|
||||
|
||||
private final String name;
|
||||
|
||||
Item(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
7
src/main/java/cz/jull/Main.java
Normal file
7
src/main/java/cz/jull/Main.java
Normal file
@@ -0,0 +1,7 @@
|
||||
package cz.jull;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
|
||||
}
|
||||
}
|
||||
15
src/main/java/cz/jull/Player.java
Normal file
15
src/main/java/cz/jull/Player.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package cz.jull;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class Player {
|
||||
private int coins;
|
||||
|
||||
private List<Item> inventory = new ArrayList<>();
|
||||
}
|
||||
29
src/main/java/cz/jull/market/Market.java
Normal file
29
src/main/java/cz/jull/market/Market.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package cz.jull.market;
|
||||
|
||||
import cz.jull.Item;
|
||||
import cz.jull.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Market {
|
||||
private final List<Item> availableItems = new ArrayList<>(List.of(
|
||||
Item.AXE, Item.SCYTHE,
|
||||
Item.VINEYARD, Item.FARMLAND,
|
||||
Item.VILLAGER_HOUSE, Item.CHURCH, Item.FENCE_WITH_COWS,
|
||||
Item.PUB
|
||||
));
|
||||
|
||||
public void sellItem(Player player, Item item) {
|
||||
player.getInventory().remove(item);
|
||||
}
|
||||
|
||||
public void buyItem(Player player, Item item) throws Exception {
|
||||
if (availableItems.contains(item)) {
|
||||
player.getInventory().add(item);
|
||||
availableItems.remove(item);
|
||||
} else {
|
||||
throw new Exception("Item is not available");
|
||||
}
|
||||
}
|
||||
}
|
||||
16
src/main/java/cz/jull/surroundings/ForestType.java
Normal file
16
src/main/java/cz/jull/surroundings/ForestType.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package cz.jull.surroundings;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public enum ForestType {
|
||||
SMALL,
|
||||
MEDIUM,
|
||||
LARGE;
|
||||
|
||||
public static ForestType getRandom() {
|
||||
Random random = new Random();
|
||||
ForestType[] types = values();
|
||||
|
||||
return types[random.nextInt(types.length)];
|
||||
}
|
||||
}
|
||||
16
src/main/java/cz/jull/surroundings/PathType.java
Normal file
16
src/main/java/cz/jull/surroundings/PathType.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package cz.jull.surroundings;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public enum PathType {
|
||||
DEAD_END,
|
||||
SIDE_PATH,
|
||||
MAIN_PATH;
|
||||
|
||||
public static PathType getRandom() {
|
||||
Random random = new Random();
|
||||
PathType[] types = values();
|
||||
|
||||
return types[random.nextInt(types.length)];
|
||||
}
|
||||
}
|
||||
16
src/main/java/cz/jull/surroundings/SoilType.java
Normal file
16
src/main/java/cz/jull/surroundings/SoilType.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package cz.jull.surroundings;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public enum SoilType {
|
||||
STONY,
|
||||
LESS_FERTILE,
|
||||
FERTILE;
|
||||
|
||||
public static SoilType getRandom() {
|
||||
Random random = new Random();
|
||||
SoilType[] types = values();
|
||||
|
||||
return types[random.nextInt(types.length)];
|
||||
}
|
||||
}
|
||||
16
src/main/java/cz/jull/surroundings/WaterType.java
Normal file
16
src/main/java/cz/jull/surroundings/WaterType.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package cz.jull.surroundings;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public enum WaterType {
|
||||
WELL,
|
||||
POND,
|
||||
RIVER;
|
||||
|
||||
public static WaterType getRandom() {
|
||||
Random random = new Random();
|
||||
WaterType[] types = values();
|
||||
|
||||
return types[random.nextInt(types.length)];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user