#enhance feedback

In the skills list shown by #enhance, add an annotation
for skills that have had enough practive to be advanced but
can't be because there aren't enough slots available or the
role-specific limit has been reached.
This commit is contained in:
nethack.rankin
2002-02-13 06:36:31 +00:00
parent aa989f2452
commit 5798dcc3e7
2 changed files with 88 additions and 20 deletions
+1
View File
@@ -542,6 +542,7 @@ made each of the end disclosure options customizable to "prompt;default no",
"don't show it and don't prompt" "don't show it and don't prompt"
add female role level names "Medica ossium", "Magistra", "Chevaliere", add female role level names "Medica ossium", "Magistra", "Chevaliere",
and "Dame" and "Dame"
more feedback about skill advancement from #enhance command
Platform- and/or Interface-Specific New Features Platform- and/or Interface-Specific New Features
+87 -20
View File
@@ -95,6 +95,8 @@ int skill;
#endif /* OVLB */ #endif /* OVLB */
STATIC_DCL boolean FDECL(can_advance, (int, BOOLEAN_P)); STATIC_DCL boolean FDECL(can_advance, (int, BOOLEAN_P));
STATIC_DCL boolean FDECL(could_advance, (int));
STATIC_DCL boolean FDECL(peaked_skill, (int));
STATIC_DCL int FDECL(slots_required, (int)); STATIC_DCL int FDECL(slots_required, (int));
#ifdef OVL1 #ifdef OVL1
@@ -763,6 +765,7 @@ int skill;
} }
/* return true if this skill can be advanced */ /* return true if this skill can be advanced */
/*ARGSUSED*/
STATIC_OVL boolean STATIC_OVL boolean
can_advance(skill, speedy) can_advance(skill, speedy)
int skill; int skill;
@@ -779,6 +782,30 @@ boolean speedy;
&& u.weapon_slots >= slots_required(skill))); && u.weapon_slots >= slots_required(skill)));
} }
/* return true if this skill could be advanced if more slots were available */
STATIC_OVL boolean
could_advance(skill)
int skill;
{
return !P_RESTRICTED(skill)
&& P_SKILL(skill) < P_MAX_SKILL(skill) && (
(P_ADVANCE(skill) >=
(unsigned) practice_needed_to_advance(P_SKILL(skill))
&& u.skills_advanced < P_SKILL_LIMIT));
}
/* return true if this skill has reached its maximum and there's been enough
practice to become eligible for the next step if that had been possible */
STATIC_OVL boolean
peaked_skill(skill)
int skill;
{
return !P_RESTRICTED(skill)
&& P_SKILL(skill) >= P_MAX_SKILL(skill) && (
(P_ADVANCE(skill) >=
(unsigned) practice_needed_to_advance(P_SKILL(skill))));
}
STATIC_OVL void STATIC_OVL void
skill_advance(skill) skill_advance(skill)
int skill; int skill;
@@ -788,8 +815,8 @@ int skill;
u.skill_record[u.skills_advanced++] = skill; u.skill_record[u.skills_advanced++] = skill;
/* subtly change the advance message to indicate no more advancement */ /* subtly change the advance message to indicate no more advancement */
You("are now %s skilled in %s.", You("are now %s skilled in %s.",
P_SKILL(skill) >= P_MAX_SKILL(skill) ? "most" : "more", P_SKILL(skill) >= P_MAX_SKILL(skill) ? "most" : "more",
P_NAME(skill)); P_NAME(skill));
} }
static struct skill_range { static struct skill_range {
@@ -812,14 +839,15 @@ static struct skill_range {
int int
enhance_weapon_skill() enhance_weapon_skill()
{ {
int pass, i, n, len, longest, to_advance; int pass, i, n, len, longest,
char buf[BUFSZ], buf2[BUFSZ]; to_advance, eventually_advance, maxxed_cnt;
char buf[BUFSZ], sklnambuf[BUFSZ];
const char *prefix;
menu_item *selected; menu_item *selected;
anything any; anything any;
winid win; winid win;
boolean speedy = FALSE; boolean speedy = FALSE;
#ifdef WIZARD #ifdef WIZARD
if (wizard && yn("Advance skills without practice?") == 'y') if (wizard && yn("Advance skills without practice?") == 'y')
speedy = TRUE; speedy = TRUE;
@@ -827,15 +855,44 @@ enhance_weapon_skill()
do { do {
/* find longest available skill name, count those that can advance */ /* find longest available skill name, count those that can advance */
for (longest = 0, to_advance = 0, i = 0; i < P_NUM_SKILLS; i++) { to_advance = eventually_advance = maxxed_cnt = 0;
if (!P_RESTRICTED(i) && (len = strlen(P_NAME(i))) > longest) for (longest = 0, i = 0; i < P_NUM_SKILLS; i++) {
if (P_RESTRICTED(i)) continue;
if ((len = strlen(P_NAME(i))) > longest)
longest = len; longest = len;
if (can_advance(i, speedy)) to_advance++; if (can_advance(i, speedy)) to_advance++;
else if (could_advance(i)) eventually_advance++;
else if (peaked_skill(i)) maxxed_cnt++;
} }
win = create_nhwindow(NHW_MENU); win = create_nhwindow(NHW_MENU);
start_menu(win); start_menu(win);
/* start with a legend if any entries will be annotated
with "*" or "#" below */
if (eventually_advance > 0 || maxxed_cnt > 0) {
any.a_int = 0;
if (eventually_advance > 0) {
Sprintf(buf,
"(Skill%s flagged by \"*\" may be enhanced %s.)",
plur(eventually_advance),
(u.ulevel < MAXULEV) ?
"when you're more experienced" :
"if skill slots become available");
add_menu(win, NO_GLYPH, &any, 0, 0, ATR_NONE,
buf, MENU_UNSELECTED);
}
if (maxxed_cnt > 0) {
Sprintf(buf,
"(Skill%s flagged by \"#\" cannot be enhanced any further.)",
plur(maxxed_cnt));
add_menu(win, NO_GLYPH, &any, 0, 0, ATR_NONE,
buf, MENU_UNSELECTED);
}
add_menu(win, NO_GLYPH, &any, 0, 0, ATR_NONE,
"", MENU_UNSELECTED);
}
/* List the skills, making ones that could be advanced /* List the skills, making ones that could be advanced
selectable. List the miscellaneous skills first. selectable. List the miscellaneous skills first.
Possible future enhancement: list spell skills before Possible future enhancement: list spell skills before
@@ -855,28 +912,38 @@ enhance_weapon_skill()
* The 12 is the longest skill level name. * The 12 is the longest skill level name.
* The " " is room for a selection letter and dash, "a - ". * The " " is room for a selection letter and dash, "a - ".
*/ */
if (can_advance(i, speedy))
prefix = ""; /* will be preceded by menu choice */
else if (could_advance(i))
prefix = " * ";
else if (peaked_skill(i))
prefix = " # ";
else
prefix = (to_advance + eventually_advance +
maxxed_cnt > 0) ? " " : "";
(void) skill_level_name(i, sklnambuf);
#ifdef WIZARD #ifdef WIZARD
if (wizard) if (wizard)
Sprintf(buf2, " %s%-*s %-12s %4d(%4d)", Sprintf(buf, " %s%-*s %-12s %5d(%4d)",
to_advance == 0 || can_advance(i, speedy) ? "" : " " , prefix, longest, P_NAME(i), sklnambuf,
longest, P_NAME(i), P_ADVANCE(i),
skill_level_name(i, buf), practice_needed_to_advance(P_SKILL(i)));
P_ADVANCE(i), practice_needed_to_advance(P_SKILL(i)));
else else
#endif #endif
Sprintf(buf2, " %s %-*s [%s]", Sprintf(buf, " %s %-*s [%s]",
to_advance == 0 || can_advance(i, speedy) ? "" : " ", prefix, longest, P_NAME(i), sklnambuf);
longest, P_NAME(i),
skill_level_name(i, buf));
any.a_int = can_advance(i, speedy) ? i+1 : 0; any.a_int = can_advance(i, speedy) ? i+1 : 0;
add_menu(win, NO_GLYPH, &any, 0, 0, ATR_NONE, buf2, MENU_UNSELECTED); add_menu(win, NO_GLYPH, &any, 0, 0, ATR_NONE,
buf, MENU_UNSELECTED);
} }
Strcpy(buf, to_advance ? "Pick a skill to advance:" : "Current skills:"); Strcpy(buf, (to_advance > 0) ? "Pick a skill to advance:" :
"Current skills:");
#ifdef WIZARD #ifdef WIZARD
if (wizard && !speedy) Sprintf(eos(buf), " (%d slot%s available)", if (wizard && !speedy)
u.weapon_slots, plur(u.weapon_slots)); Sprintf(eos(buf), " (%d slot%s available)",
u.weapon_slots, plur(u.weapon_slots));
#endif #endif
end_menu(win, buf); end_menu(win, buf);
n = select_menu(win, to_advance ? PICK_ONE : PICK_NONE, &selected); n = select_menu(win, to_advance ? PICK_ONE : PICK_NONE, &selected);