feat: added new features
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package cz.jull;
|
||||
|
||||
import cz.jull.market.Market;
|
||||
import cz.jull.surroundings.ForestType;
|
||||
import cz.jull.surroundings.PathType;
|
||||
import cz.jull.surroundings.SoilType;
|
||||
@@ -11,7 +12,7 @@ import java.util.List;
|
||||
|
||||
public class Game {
|
||||
@Getter
|
||||
private Player player = new Player();
|
||||
private final Player player = new Player();
|
||||
|
||||
private ForestType forestType;
|
||||
|
||||
@@ -25,7 +26,9 @@ public class Game {
|
||||
private WaterType waterType;
|
||||
|
||||
@Getter
|
||||
private List<Item> buildings = new ArrayList<>();
|
||||
private final List<Item> buildings = new ArrayList<>();
|
||||
|
||||
private final Market market = new Market(this);
|
||||
|
||||
public void generateStats() {
|
||||
forestType = ForestType.getRandom();
|
||||
@@ -59,5 +62,41 @@ public class Game {
|
||||
return;
|
||||
}
|
||||
forestType.setSize(forestType.getSize() - 1);
|
||||
for (int i = 0; i < forestType.getAxesNeeded(); i++) {
|
||||
player.getInventory().remove(Item.AXE);
|
||||
player.getInventory().add(Item.WOOD);
|
||||
}
|
||||
}
|
||||
|
||||
public void harvest(Item item) {
|
||||
switch (item) {
|
||||
case WHEAT_FARMLAND -> {
|
||||
buildings.remove(Item.WHEAT_SEEDS);
|
||||
player.getInventory().add(Item.WHEAT);
|
||||
}
|
||||
|
||||
case HOPS_FARMLAND -> {
|
||||
buildings.remove(Item.HOPS_SEEDS);
|
||||
player.getInventory().add(Item.HOPS);
|
||||
}
|
||||
|
||||
case VINEYARD -> {
|
||||
buildings.remove(Item.GRAPEVINE_SEEDS);
|
||||
player.getInventory().add(Item.GRAPEVINE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void produce(Item item) {
|
||||
int bakeryProducedMoney = 0;
|
||||
int pubProducedMoney = 0;
|
||||
int wineryProducedMoney = 0;
|
||||
|
||||
switch (item) {
|
||||
case BAKERY -> {
|
||||
player.getInventory().remove(Item.WHEAT);
|
||||
// TODO dodelat ostatni factories a vymyslet logiku na delani penez tak ze to bude brat kolik harvestnul napr obili a pote to nejak vynasobit a to budou money
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,53 +2,61 @@ package cz.jull;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
|
||||
public enum Item implements Buildable {
|
||||
AXE("Axe", false),
|
||||
SCYTHE("Scythe", false),
|
||||
AXE("Axe", false, 5),
|
||||
SCYTHE("Scythe", false, 5),
|
||||
|
||||
WOOD("Wood", false),
|
||||
WHEAT("Wheat", false, 0),
|
||||
HOPS("Hops", false, 0),
|
||||
GRAPEVINE("Grapes", false, 0),
|
||||
WOOD("Wood", false, 0),
|
||||
MILK("Milk", false, 0),
|
||||
|
||||
WHEAT("Wheat", true),
|
||||
HOPS("Hops", true),
|
||||
GRAPES("Grapes", true),
|
||||
WHEAT_SEEDS("Wheat seeds", true, 5),
|
||||
HOPS_SEEDS("Hops seeds", true, 5),
|
||||
GRAPEVINE_SEEDS("Grapes seeds", true, 5),
|
||||
|
||||
MILK("Milk", false),
|
||||
VINEYARD("Vineyard", true, 100),
|
||||
WHEAT_FARMLAND("Wheat farmland", true, 100),
|
||||
HOPS_FARMLAND("Hops farmland", true, 100),
|
||||
|
||||
VINEYARD("Vineyard", true),
|
||||
FARMLAND("Farmland", true),
|
||||
FENCE_WITH_COWS("Fence with cows", true, 100),
|
||||
|
||||
FENCE_WITH_COWS("Fence with cows", true),
|
||||
CHURCH("Church", true, 100),
|
||||
VILLAGER_HOUSE("Villager house", true, 50),
|
||||
|
||||
PUB("Pub", true, 400),
|
||||
WINERY("Winery", true, 350),
|
||||
BAKERY("Bakery", true, 350),
|
||||
|
||||
WELL("Well", true, 30),
|
||||
|
||||
COAL_FACTORY("Coal factory", true, 200),
|
||||
CHEESE_FACTORY("Cheese factory", true, 200);
|
||||
|
||||
CHURCH("Church", true),
|
||||
VILLAGER_HOUSE("Villager house", true),
|
||||
PUB("Pub", true),
|
||||
WINERY("Winery", true),
|
||||
WELL("Well", true),
|
||||
COAL_FACTORY("Coal factory", true),;
|
||||
|
||||
static {
|
||||
WHEAT.function = game -> {
|
||||
if (game.getBuildings().stream().filter(building -> building == Item.FARMLAND).count() >= game.getBuildings().stream().filter(building -> building == Item.WHEAT || building == Item.HOPS).count() + 1) {
|
||||
WHEAT_SEEDS.function = game -> {
|
||||
if (game.getBuildings().stream().filter(building -> building == Item.WHEAT_FARMLAND).count() >= game.getBuildings().stream().filter(building -> building == Item.WHEAT_SEEDS || building == Item.HOPS_SEEDS).count() + 1) {
|
||||
return true;
|
||||
}
|
||||
System.out.println(" "); //TODO
|
||||
return false;
|
||||
};
|
||||
|
||||
HOPS.function = game -> {
|
||||
if (game.getBuildings().stream().filter(building -> building == Item.FARMLAND).count() >= game.getBuildings().stream().filter(building -> building == Item.WHEAT || building == Item.HOPS).count() + 1) {
|
||||
HOPS_SEEDS.function = game -> {
|
||||
if (game.getBuildings().stream().filter(building -> building == Item.WHEAT_FARMLAND).count() >= game.getBuildings().stream().filter(building -> building == Item.WHEAT_SEEDS || building == Item.HOPS_SEEDS).count() + 1) {
|
||||
return true;
|
||||
}
|
||||
System.out.println(" "); //TODO
|
||||
return false;
|
||||
};
|
||||
|
||||
GRAPES.function = game -> {
|
||||
if (game.getBuildings().stream().filter(building -> building == Item.VINEYARD).count() >= game.getBuildings().stream().filter(building -> building == Item.GRAPES || building == Item.HOPS).count() + 1) {
|
||||
GRAPEVINE_SEEDS.function = game -> {
|
||||
if (game.getBuildings().stream().filter(building -> building == Item.VINEYARD).count() >= game.getBuildings().stream().filter(building -> building == Item.GRAPEVINE_SEEDS || building == Item.HOPS_SEEDS).count() + 1) {
|
||||
return true;
|
||||
}
|
||||
System.out.println(" "); //TODO
|
||||
@@ -63,12 +71,12 @@ public enum Item implements Buildable {
|
||||
return false;
|
||||
};
|
||||
|
||||
FARMLAND.function = game -> {
|
||||
WHEAT_FARMLAND.function = game -> {
|
||||
if (!game.getBuildings().contains(Item.VILLAGER_HOUSE)) {
|
||||
System.out.println(" "); // TODO
|
||||
return false;
|
||||
}
|
||||
if (game.getBuildings().stream().filter(building -> building == Item.FARMLAND).count() >= game.getWaterType().getFarmlandAndVineyardCount()) {
|
||||
if (game.getBuildings().stream().filter(building -> building == Item.WHEAT_FARMLAND).count() >= game.getWaterType().getFarmlandAndVineyardCount()) {
|
||||
System.out.println(" "); // TODO
|
||||
return false;
|
||||
}
|
||||
@@ -99,13 +107,26 @@ public enum Item implements Buildable {
|
||||
return false;
|
||||
};
|
||||
|
||||
BAKERY.function = game -> {
|
||||
if (!game.getBuildings().contains(Item.VILLAGER_HOUSE)) {
|
||||
System.out.println(" "); // TODO
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!game.getBuildings().contains(Item.WHEAT_SEEDS)) {
|
||||
System.out.println(" "); // TODO
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
PUB.function = game -> {
|
||||
if (!game.getBuildings().contains(Item.VILLAGER_HOUSE)) {
|
||||
System.out.println(" "); // TODO
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!game.getBuildings().contains(Item.HOPS)) {
|
||||
if (!game.getBuildings().contains(Item.HOPS_SEEDS)) {
|
||||
System.out.println(" "); // TODO
|
||||
return false;
|
||||
}
|
||||
@@ -118,7 +139,7 @@ public enum Item implements Buildable {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!game.getBuildings().contains(Item.GRAPES)) {
|
||||
if (!game.getBuildings().contains(Item.GRAPEVINE_SEEDS)) {
|
||||
System.out.println(" "); // TODO
|
||||
return false;
|
||||
}
|
||||
@@ -132,6 +153,14 @@ public enum Item implements Buildable {
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
CHEESE_FACTORY.function = game -> {
|
||||
if (!game.getBuildings().contains(Item.VILLAGER_HOUSE)) {
|
||||
System.out.println(" "); // TODO
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
@Getter
|
||||
@@ -139,12 +168,15 @@ public enum Item implements Buildable {
|
||||
|
||||
private final boolean isPLaceable;
|
||||
|
||||
private final int price;
|
||||
|
||||
private Function<Game, Boolean> function;
|
||||
|
||||
Item(String name, boolean isPLaceable) {
|
||||
Item(String name, boolean isPLaceable, int price) {
|
||||
this.name = name;
|
||||
this.isPLaceable = isPLaceable;
|
||||
this.function = ignored -> isPLaceable;
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,6 +3,9 @@ package cz.jull.market;
|
||||
import cz.jull.Game;
|
||||
import cz.jull.Item;
|
||||
import cz.jull.Player;
|
||||
import cz.jull.surroundings.PathType;
|
||||
import cz.jull.surroundings.SoilType;
|
||||
import cz.jull.surroundings.WaterType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -10,11 +13,13 @@ 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, Item.WINERY
|
||||
Item.VILLAGER_HOUSE, Item.CHURCH
|
||||
));
|
||||
|
||||
private void play() {
|
||||
|
||||
}
|
||||
|
||||
public void sellItem(Player player, Item item) {
|
||||
player.getInventory().remove(item);
|
||||
}
|
||||
@@ -23,7 +28,95 @@ public class Market {
|
||||
if (availableItems.contains(item)) {
|
||||
game.getPlayer().getInventory().add(item);
|
||||
} else {
|
||||
if (item == Item.WHEAT_SEEDS) {
|
||||
for (int i = 0; i < game.getWaterType().getFarmlandAndVineyardCount() ; i++) {
|
||||
game.getPlayer().getInventory().add(Item.WHEAT_SEEDS);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (item == Item.HOPS_SEEDS) {
|
||||
for (int i = 0; i < game.getWaterType().getFarmlandAndVineyardCount() ; i++) {
|
||||
game.getPlayer().getInventory().add(Item.HOPS_SEEDS);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (item == Item.GRAPEVINE_SEEDS) {
|
||||
for (int i = 0; i < game.getWaterType().getFarmlandAndVineyardCount() ; i++) {
|
||||
game.getPlayer().getInventory().add(Item.GRAPEVINE_SEEDS);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (item == Item.WHEAT_FARMLAND) {
|
||||
for (int i = 0; i < game.getWaterType().getFarmlandAndVineyardCount() ; i++) {
|
||||
game.getPlayer().getInventory().add(Item.WHEAT_FARMLAND);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (item == Item.HOPS_FARMLAND) {
|
||||
for (int i = 0; i < game.getWaterType().getFarmlandAndVineyardCount() ; i++) {
|
||||
game.getPlayer().getInventory().add(Item.HOPS_FARMLAND);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (item == Item.VINEYARD) {
|
||||
for (int i = 0; i < game.getWaterType().getFarmlandAndVineyardCount() ; i++) {
|
||||
game.getPlayer().getInventory().add(Item.VINEYARD);
|
||||
}
|
||||
return;
|
||||
}
|
||||
throw new Exception("Item is not available");
|
||||
}
|
||||
}
|
||||
|
||||
public Market(Game game) {
|
||||
// Soil Type
|
||||
if (game.getSoilType() == SoilType.STONY) {
|
||||
availableItems.addAll(List.of(Item.FENCE_WITH_COWS, Item.VINEYARD));
|
||||
}
|
||||
|
||||
if (game.getSoilType() == SoilType.LESS_FERTILE) {
|
||||
availableItems.addAll(List.of(Item.FENCE_WITH_COWS, Item.WHEAT_FARMLAND));
|
||||
}
|
||||
|
||||
if (game.getSoilType() == SoilType.FERTILE) {
|
||||
availableItems.add(Item.WHEAT_FARMLAND);
|
||||
}
|
||||
|
||||
// Path Type
|
||||
if (game.getPathType() == PathType.DEAD_END) {
|
||||
if (availableItems.contains(Item.FENCE_WITH_COWS)) {
|
||||
availableItems.add(Item.CHEESE_FACTORY);
|
||||
}
|
||||
availableItems.add(Item.COAL_FACTORY);
|
||||
}
|
||||
|
||||
if (game.getPathType() == PathType.SIDE_PATH) {
|
||||
if (availableItems.contains(Item.VINEYARD)) {
|
||||
availableItems.add(Item.WINERY);
|
||||
}
|
||||
|
||||
if (availableItems.contains(Item.WHEAT_FARMLAND)) {
|
||||
availableItems.add(Item.BAKERY);
|
||||
}
|
||||
}
|
||||
|
||||
if (game.getPathType() == PathType.MAIN_PATH) {
|
||||
if (availableItems.contains(Item.VINEYARD)) {
|
||||
availableItems.add(Item.WINERY);
|
||||
}
|
||||
|
||||
if (availableItems.contains(Item.HOPS_FARMLAND)) {
|
||||
availableItems.add(Item.PUB);
|
||||
}
|
||||
|
||||
if (availableItems.contains(Item.WHEAT_FARMLAND)) {
|
||||
availableItems.add(Item.BAKERY);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
5
src/main/java/cz/jull/tui/Strings.java
Normal file
5
src/main/java/cz/jull/tui/Strings.java
Normal file
@@ -0,0 +1,5 @@
|
||||
package cz.jull.tui;
|
||||
|
||||
public class Strings {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user