initial commit

This commit is contained in:
2025-05-03 16:25:52 +02:00
commit e02582cba5
15 changed files with 271 additions and 0 deletions

View 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);
}
}

View 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;
}
}

View File

@@ -0,0 +1,7 @@
package cz.jull;
public class Main {
public static void main(String[] args) {
}
}

View 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<>();
}

View 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");
}
}
}

View 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)];
}
}

View 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)];
}
}

View 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)];
}
}

View 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)];
}
}