MCPcopy Create free account
hub / github.com/NetHack/NetHack / enhance_weapon_skill

Function enhance_weapon_skill

src/weapon.c:1328–1407  ·  view source on GitHub ↗

* The `#enhance' extended command. What we _really_ would like is * to keep being able to pick things to advance until we couldn't any * more. This is currently not possible -- the menu code has no way * to call us back for instant action. Even if it did, we would also need * to be able to update the menu since selecting one item could make * others unselectable. */

Source from the content-addressed store, hash-verified

1326 * others unselectable.
1327 */
1328int
1329enhance_weapon_skill(void)
1330{
1331 int i, n, to_advance, eventually_advance, maxxed_cnt;
1332 char buf[BUFSZ];
1333 menu_item *selected;
1334 winid win;
1335 boolean speedy = FALSE;
1336
1337 /* player knows about #enhance, don't show tip anymore */
1338 svc.context.tips |= (1 << TIP_ENHANCE);
1339
1340 if (wizard && y_n("Advance skills without practice?") == 'y')
1341 speedy = TRUE;
1342
1343 do {
1344 /* count advanceable skills */
1345 to_advance = eventually_advance = maxxed_cnt = 0;
1346 for (i = 0; i < P_NUM_SKILLS; i++) {
1347 if (P_RESTRICTED(i))
1348 continue;
1349 if (can_advance(i, speedy))
1350 to_advance++;
1351 else if (could_advance(i))
1352 eventually_advance++;
1353 else if (peaked_skill(i))
1354 maxxed_cnt++;
1355 }
1356
1357 win = create_nhwindow(NHW_MENU);
1358 start_menu(win, MENU_BEHAVE_STANDARD);
1359
1360 /* start with a legend if any entries will be annotated
1361 with "*" or "#" below */
1362 if (eventually_advance > 0 || maxxed_cnt > 0) {
1363 if (eventually_advance > 0) {
1364 Sprintf(buf, "(Skill%s flagged by \"*\" may be enhanced %s.)",
1365 plur(eventually_advance),
1366 (u.ulevel < MAXULEV)
1367 ? "when you're more experienced"
1368 : "if skill slots become available");
1369 add_menu_str(win, buf);
1370 }
1371 if (maxxed_cnt > 0) {
1372 Sprintf(buf,
1373 "(Skill%s flagged by \"#\" cannot be enhanced any further.)",
1374 plur(maxxed_cnt));
1375 add_menu_str(win, buf);
1376 }
1377 add_menu_str(win, "");
1378 }
1379
1380 add_skills_to_menu(
1381 win, to_advance + eventually_advance + maxxed_cnt > 0, speedy);
1382
1383 Strcpy(buf, (to_advance > 0) ? "Pick a skill to advance:"
1384 : "Current skills:");
1385 if (wizard && !speedy)

Callers

nothing calls this directly

Calls 9

can_advanceFunction · 0.85
could_advanceFunction · 0.85
peaked_skillFunction · 0.85
add_menu_strFunction · 0.85
add_skills_to_menuFunction · 0.85
eosFunction · 0.85
select_menuFunction · 0.85
skill_advanceFunction · 0.85
You_feelFunction · 0.85

Tested by

no test coverage detected