feat: strings
This commit is contained in:
@@ -39,6 +39,9 @@ public class Game {
|
|||||||
this.strings = strings;
|
this.strings = strings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Game() {
|
||||||
|
}
|
||||||
|
|
||||||
public void play() {
|
public void play() {
|
||||||
strings.print("welcome");
|
strings.print("welcome");
|
||||||
Cli.pressEnter();
|
Cli.pressEnter();
|
||||||
@@ -88,7 +91,7 @@ public class Game {
|
|||||||
|
|
||||||
public void build(Item item) {
|
public void build(Item item) {
|
||||||
if (!player.getInventory().contains(item)) {
|
if (!player.getInventory().contains(item)) {
|
||||||
System.out.println(" never "); // TODO
|
strings.print("cantBuild");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,7 +111,7 @@ public class Game {
|
|||||||
public void cutTrees() {
|
public void cutTrees() {
|
||||||
long axeCount = player.getInventory().stream().filter(item -> item == Item.AXE).count();
|
long axeCount = player.getInventory().stream().filter(item -> item == Item.AXE).count();
|
||||||
if (axeCount < forestType.getAxesNeeded()) {
|
if (axeCount < forestType.getAxesNeeded()) {
|
||||||
System.out.println(" "); //TODO
|
strings.print("cantCutTrees", forestType.getAxesNeeded());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
forestType.setSize(forestType.getSize() - 1);
|
forestType.setSize(forestType.getSize() - 1);
|
||||||
@@ -145,7 +148,7 @@ public class Game {
|
|||||||
|
|
||||||
public void milkCow(Game game) {
|
public void milkCow(Game game) {
|
||||||
if (!game.getBuildings().contains(Item.FENCE_WITH_COWS)) {
|
if (!game.getBuildings().contains(Item.FENCE_WITH_COWS)) {
|
||||||
System.out.println(" "); //TODO
|
strings.print("cantMilkCows");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,7 +163,7 @@ public class Game {
|
|||||||
long cheeseFactoryProducedMoney;
|
long cheeseFactoryProducedMoney;
|
||||||
|
|
||||||
if (!buildings.contains(item)) {
|
if (!buildings.contains(item)) {
|
||||||
System.out.println(" cant produce"); //TODO
|
strings.print("cantProduce", item);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (item) {
|
switch (item) {
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ public enum Item implements Buildable {
|
|||||||
if (game.getBuildings().stream().filter(building -> building == Item.VILLAGER_HOUSE).count() >= (game.getBuildings().stream().filter(building -> building == Item.FENCE_WITH_COWS).count() + 1) * 3) {
|
if (game.getBuildings().stream().filter(building -> building == Item.VILLAGER_HOUSE).count() >= (game.getBuildings().stream().filter(building -> building == Item.FENCE_WITH_COWS).count() + 1) * 3) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
System.out.println(" "); //TODO
|
game.getStrings().print("cantBeBuiltCows");
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -104,7 +104,7 @@ public enum Item implements Buildable {
|
|||||||
if (!game.getBuildings().contains(Item.CHURCH)) {
|
if (!game.getBuildings().contains(Item.CHURCH)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
System.out.println(" "); //TODO
|
game.getStrings().print("cantBeBuiltChurch");
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -112,13 +112,13 @@ public enum Item implements Buildable {
|
|||||||
if (game.getBuildings().contains(Item.CHURCH)) {
|
if (game.getBuildings().contains(Item.CHURCH)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
System.out.println(" "); //TODO
|
game.getStrings().print("cantBeBuiltVillagerHouse");
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
BAKERY.canBeBuiltFunction = game -> {
|
BAKERY.canBeBuiltFunction = game -> {
|
||||||
if (!game.getBuildings().contains(Item.WHEAT_FARMLAND)) {
|
if (!game.getBuildings().contains(Item.WHEAT_FARMLAND)) {
|
||||||
System.out.println(" "); // TODO
|
game.getStrings().print("cantBeBuiltBakery");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -126,7 +126,7 @@ public enum Item implements Buildable {
|
|||||||
|
|
||||||
PUB.canBeBuiltFunction = game -> {
|
PUB.canBeBuiltFunction = game -> {
|
||||||
if (!game.getBuildings().contains(Item.HOPS_FARMLAND)) {
|
if (!game.getBuildings().contains(Item.HOPS_FARMLAND)) {
|
||||||
System.out.println(" "); // TODO
|
game.getStrings().print("cantBeBuiltPub");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -134,7 +134,7 @@ public enum Item implements Buildable {
|
|||||||
|
|
||||||
WINERY.canBeBuiltFunction = game -> {
|
WINERY.canBeBuiltFunction = game -> {
|
||||||
if (!game.getBuildings().contains(Item.VINEYARD)) {
|
if (!game.getBuildings().contains(Item.VINEYARD)) {
|
||||||
System.out.println(" "); // TODO
|
game.getStrings().print("cantBeBuiltWinery");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -142,7 +142,7 @@ public enum Item implements Buildable {
|
|||||||
|
|
||||||
CHEESE_FACTORY.canBeBuiltFunction = game -> {
|
CHEESE_FACTORY.canBeBuiltFunction = game -> {
|
||||||
if (!game.getBuildings().contains(Item.FENCE_WITH_COWS)) {
|
if (!game.getBuildings().contains(Item.FENCE_WITH_COWS)) {
|
||||||
System.out.println(" "); // TODO
|
game.getStrings().print("cantBeBuiltCheeseFactory");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -152,7 +152,7 @@ public enum Item implements Buildable {
|
|||||||
static {
|
static {
|
||||||
VILLAGER_HOUSE.canBeBoughtFunction = game -> {
|
VILLAGER_HOUSE.canBeBoughtFunction = game -> {
|
||||||
if (!game.getBuildings().contains(Item.CHURCH)) {
|
if (!game.getBuildings().contains(Item.CHURCH)) {
|
||||||
System.out.println(" "); //TODO
|
game.getStrings().print("cantBeBoughtVillagerHouse");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -160,7 +160,7 @@ public enum Item implements Buildable {
|
|||||||
|
|
||||||
Function<Game, Boolean> func = game -> {
|
Function<Game, Boolean> func = game -> {
|
||||||
if (!game.getBuildings().contains(Item.VILLAGER_HOUSE)) {
|
if (!game.getBuildings().contains(Item.VILLAGER_HOUSE)) {
|
||||||
System.out.println(" "); // TODO
|
game.getStrings().print("cantBeBoughtAll");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public class Market {
|
|||||||
|
|
||||||
public void sellItem(Game game, Item item) {
|
public void sellItem(Game game, Item item) {
|
||||||
if (!game.getPlayer().getInventory().contains(item)) {
|
if (!game.getPlayer().getInventory().contains(item)) {
|
||||||
System.out.println(" "); // TODO
|
game.getStrings().print("cantSell");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ public class Market {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!item.getCanBeBoughtFunction().apply(game)) {
|
if (!item.getCanBeBoughtFunction().apply(game)) {
|
||||||
System.out.println(" "); //TODO
|
game.getStrings().print("cantBuy");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (availableItems.contains(item)) {
|
if (availableItems.contains(item)) {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ public enum ForestType {
|
|||||||
MEDIUM("Medium",50, 3),
|
MEDIUM("Medium",50, 3),
|
||||||
LARGE("Large", 100, 5);
|
LARGE("Large", 100, 5);
|
||||||
|
|
||||||
private String name;
|
private final String name;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
|
|||||||
@@ -23,6 +23,22 @@ public class Strings {
|
|||||||
private String marketBuyMessage;
|
private String marketBuyMessage;
|
||||||
private String marketSell;
|
private String marketSell;
|
||||||
private String marketSellMessage;
|
private String marketSellMessage;
|
||||||
|
private String cantBeBuiltCows;
|
||||||
|
private String cantBeBuiltChurch;
|
||||||
|
private String cantBeBuiltVillagerHouse;
|
||||||
|
private String cantBeBuiltBakery;
|
||||||
|
private String cantBeBuiltPub;
|
||||||
|
private String cantBeBuiltWinery;
|
||||||
|
private String cantBeBuiltCheeseFactory;
|
||||||
|
private String cantBeBoughtVillagerHouse;
|
||||||
|
private String cantBeBoughtAll;
|
||||||
|
private String cantBuild;
|
||||||
|
private String cantCutTrees;
|
||||||
|
private String cantMilkCows;
|
||||||
|
private String cantProduce;
|
||||||
|
private String cantSell;
|
||||||
|
private String cantBuy;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads strings from json file
|
* Loads strings from json file
|
||||||
|
|||||||
17
strings.json
17
strings.json
@@ -9,5 +9,20 @@
|
|||||||
"marketBuy": "Pick which item you want to buy",
|
"marketBuy": "Pick which item you want to buy",
|
||||||
"marketBuyMessage": "You bought: {0}",
|
"marketBuyMessage": "You bought: {0}",
|
||||||
"marketSell": "Pick which item you want to sell",
|
"marketSell": "Pick which item you want to sell",
|
||||||
"marketSellMessage": "You sold: {0}"
|
"marketSellMessage": "You sold: {0}",
|
||||||
|
"cantBeBuiltCows": "First you need to build 3 villager houses before owning cows!",
|
||||||
|
"cantBeBuiltChurch": "You can`t have more than 1 church!",
|
||||||
|
"cantBeBuiltVillagerHouse": "First you need to built church before villager houses!",
|
||||||
|
"cantBeBuiltBakery": "First you need to built wheat farmland before a bakery! You need wheat you know!",
|
||||||
|
"cantBeBuiltPub": "First you need to built hops farmland before a pub! You need hops you know!",
|
||||||
|
"cantBeBuiltWinery": "First you need to built vineyard before a winery! You need grapevines you know!",
|
||||||
|
"cantBeBuiltCheeseFactory": "First you need to own cows before a cheese factory! You need milk you know!",
|
||||||
|
"cantBeBoughtVillagerHouse": "First you need to buy a church before villager houses!",
|
||||||
|
"cantBeBoughtAll": "Buy a villager house first!",
|
||||||
|
"cantBuild": "You don`t have that item in your inventory!",
|
||||||
|
"cantCutTrees": "You need {0} axes to cut trees!",
|
||||||
|
"cantMilkCows": "You don`t own any cows!",
|
||||||
|
"cantProduce": "You can`t produce when you dont have {0}",
|
||||||
|
"cantSell": "You can`t sell this item! You don`t have it!",
|
||||||
|
"cantBuy": "You can`t buy this item!"
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user