Skip to content

Commit

Permalink
Give the player multiple tries for messing up the input for scrolls o…
Browse files Browse the repository at this point in the history
…f acquirement. Noticed this while reviewing a game by mobileuser, the scroll exited out of the prompt window from a mistaken input. Now it gives the player 5 tries similar to wishing prompts.
  • Loading branch information
elunna committed Nov 19, 2023
1 parent 8aaece1 commit c993a54
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/read.c
Original file line number Diff line number Diff line change
Expand Up @@ -4241,17 +4241,19 @@ int class_type;
}

static void do_acquirement() {
winid win = create_nhwindow(NHW_MENU);
winid win;
anything any;
int i;
int i, tries = 0;
char ch = 'q';
char item_chars[] = { 'r', '"', ')', '[', '%', '?', '+', '!', '=', '/', '(', '*' };
menu_item *pick_list = NULL;
const char *item_names[] = {
"Random item", "Amulet", "Weapon", "Armor", "Comestible", "Scroll",
"Spellbook", "Potion", "Ring", "Wand", "Tool", "Gem"
};


retry:
win = create_nhwindow(NHW_MENU);
start_menu(win);

for (i = 0; i < (int) sizeof(item_chars); i++) {
Expand All @@ -4261,14 +4263,12 @@ static void do_acquirement() {
}

end_menu(win, "Select a type of item to create:");


if (select_menu(win, PICK_ONE, &pick_list) > 0) {
ch = pick_list->item.a_char;
free(pick_list);
}
destroy_nhwindow(win);

switch (ch) {
case 'r': mk_acquired_item(RANDOM_CLASS); break;
case ')': mk_acquired_item(WEAPON_CLASS); break;
Expand All @@ -4282,6 +4282,14 @@ static void do_acquirement() {
case '/': mk_acquired_item(WAND_CLASS); break;
case '(': mk_acquired_item(TOOL_CLASS); break;
case '*': mk_acquired_item(GEM_CLASS); break;
default:
if (++tries < 5) {
pline("Try again.");
goto retry;
} else {
pline1(thats_enough_tries);
}
break;
}
}

Expand Down

0 comments on commit c993a54

Please sign in to comment.