fix: coins
This commit is contained in:
@@ -140,6 +140,14 @@ public enum Item implements Buildable {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
COAL_FACTORY.canBeBuiltFunction = game -> {
|
||||||
|
if (game.getBuildings().contains(Item.VILLAGER_HOUSE)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
game.getStrings().print("noVillagerHouseMessage");
|
||||||
|
return false;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package cz.jull.tui;
|
|||||||
import cz.jull.Game;
|
import cz.jull.Game;
|
||||||
import cz.jull.Item;
|
import cz.jull.Item;
|
||||||
import cz.jull.actions.Action;
|
import cz.jull.actions.Action;
|
||||||
|
import cz.jull.exceptions.ItemNotAvailableException;
|
||||||
|
import cz.jull.exceptions.NotSufficientsCoinsException;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -94,7 +96,12 @@ public class Menu {
|
|||||||
List<String> availableItems = game.getMarket().getAvailableItems().stream().map(item -> item + ": " + "\u001B[0;33m" + item.getPrice() + " Coins\u001B[0m").toList();
|
List<String> availableItems = game.getMarket().getAvailableItems().stream().map(item -> item + ": " + "\u001B[0;33m" + item.getPrice() + " Coins\u001B[0m").toList();
|
||||||
int itemIndex = Cli.selectOptionIndex(availableItems);
|
int itemIndex = Cli.selectOptionIndex(availableItems);
|
||||||
Item item = game.getMarket().getAvailableItems().get(itemIndex);
|
Item item = game.getMarket().getAvailableItems().get(itemIndex);
|
||||||
game.getMarket().buyItem(game, item);
|
try {
|
||||||
|
game.getMarket().buyItem(game, item);
|
||||||
|
} catch (NotSufficientsCoinsException | ItemNotAvailableException e) {
|
||||||
|
System.out.println("Error: " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
case 1 -> {
|
case 1 -> {
|
||||||
game.getStrings().print("marketSell");
|
game.getStrings().print("marketSell");
|
||||||
|
|||||||
Reference in New Issue
Block a user