Skip to content

Commit

Permalink
Warning if zero keys and player has gold or bag of gold
Browse files Browse the repository at this point in the history
  • Loading branch information
msx80 committed Aug 19, 2024
1 parent 0bbff15 commit 0b59214
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -471,15 +471,35 @@ private void toggleCursor() {

void openDoor() {
if (run.pg.getInvCount(Item.Key) == 0) {
log.add(5,"NO MORE KEYS!", 15, " You can not continue and");
log.add(15," soon die of starvation, lost");
log.add(15," in the dungeon!");

enterStep(DEATH);
boolean keyWarning = run.pg.getInvCount(Item.Gold) >= Craft.KEY_COST || run.pg.getInvCount(Item.BagOfGold)>0 ;

if(keyWarning)
{
confirm("No keys! Continue?", () -> {
dieOfKeys();
}, () -> {
doSound(6, 1f, 1f);
log.add(15, "Go purchase some keys..");
});

}
else
{
dieOfKeys();
}
} else {
enterStep(OPENING);
}
}

private void dieOfKeys() {
log.add(5,"NO MORE KEYS!", 15, " You can not continue and");
log.add(15," soon die of starvation, lost");
log.add(15," in the dungeon!");

enterStep(DEATH);
}

private void useItem(Item i) {
doSound(11, 1f, 1f);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@

public class Craft {

public static final int KEY_COST = 15;


private Item output;
private Map<Item, Integer> ingredients;

Expand All @@ -30,7 +33,7 @@ private boolean visibleBy(Pg pg) {
}

public static final List<Craft> ALL = Arrays.asList(
Craft.of(Item.Key, Item.Gold, 15),
Craft.of(Item.Key, Item.Gold, KEY_COST),
Craft.of(Item.SmallPotion, Item.Gold, 10),
Craft.of(Item.MediumPotion, Item.Gold, 19),
Craft.of(Item.Knife, Item.Gold, 30),
Expand Down

0 comments on commit 0b59214

Please sign in to comment.