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

Function one_characteristic

src/insight.c:845–936  ·  view source on GitHub ↗

display one attribute value for characteristics_enlightenment() */

Source from the content-addressed store, hash-verified

843
844/* display one attribute value for characteristics_enlightenment() */
845staticfn void
846one_characteristic(int mode, int final, int attrindx)
847{
848 extern const char *const attrname[]; /* attrib.c */
849 boolean hide_innate_value = FALSE, interesting_alimit;
850 int acurrent, abase, apeak, alimit;
851 const char *paren_pfx;
852 char subjbuf[BUFSZ], valubuf[BUFSZ], valstring[32];
853
854 /* being polymorphed or wearing certain cursed items prevents
855 hero from reliably tracking changes to characteristics so
856 we don't show base & peak values then; when the items aren't
857 cursed, hero could take them off to check underlying values
858 and we show those in such case so that player doesn't need
859 to actually resort to doing that */
860 if (Upolyd) {
861 hide_innate_value = TRUE;
862 } else if (Fixed_abil) {
863 if (stuck_ring(uleft, RIN_SUSTAIN_ABILITY)
864 || stuck_ring(uright, RIN_SUSTAIN_ABILITY))
865 hide_innate_value = TRUE;
866 }
867 switch (attrindx) {
868 case A_STR:
869 if (uarmg && uarmg->otyp == GAUNTLETS_OF_POWER && uarmg->cursed)
870 hide_innate_value = TRUE;
871 break;
872 case A_DEX:
873 break;
874 case A_CON:
875 if (u_wield_art(ART_OGRESMASHER) && uwep->cursed)
876 hide_innate_value = TRUE;
877 break;
878 case A_INT:
879 if (uarmh && uarmh->otyp == DUNCE_CAP && uarmh->cursed)
880 hide_innate_value = TRUE;
881 break;
882 case A_WIS:
883 if (uarmh && uarmh->otyp == DUNCE_CAP && uarmh->cursed)
884 hide_innate_value = TRUE;
885 break;
886 case A_CHA:
887 break;
888 default:
889 return; /* impossible */
890 };
891 /* note: final disclosure includes MAGICENLIGHTENTMENT */
892 if ((mode & MAGICENLIGHTENMENT) && !Upolyd)
893 hide_innate_value = FALSE;
894
895 acurrent = ACURR(attrindx);
896 (void) attrval(attrindx, acurrent, valubuf); /* Sprintf(valubuf,"%d",) */
897 Sprintf(subjbuf, "Your %s ", attrname[attrindx]);
898
899 if (!hide_innate_value) {
900 /* show abase, amax, and/or attrmax if acurr doesn't match abase
901 (a magic bonus or penalty is in effect) or abase doesn't match
902 amax (some points have been lost to poison or exercise abuse

Callers 1

Calls 3

stuck_ringFunction · 0.85
attrvalFunction · 0.85
eosFunction · 0.85

Tested by

no test coverage detected