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

Function basics_enlightenment

src/insight.c:727–823  ·  view source on GitHub ↗

hit points, energy points, armor class -- essential information which doesn't fit very well in other categories */ ARGSUSED*/

Source from the content-addressed store, hash-verified

725 doesn't fit very well in other categories */
726/*ARGSUSED*/
727staticfn void
728basics_enlightenment(int mode UNUSED, int final)
729{
730 static char Power[] = "energy points (spell power)";
731 char buf[BUFSZ];
732 int pw = u.uen, hp = (Upolyd ? u.mh : u.uhp),
733 pwmax = u.uenmax, hpmax = (Upolyd ? u.mhmax : u.uhpmax);
734
735 enlght_out(""); /* separator after background */
736 enlght_out("Basics:");
737
738 if (hp < 0)
739 hp = 0;
740 /* "1 out of 1" rather than "all" if max is only 1; should never happen */
741 if (hp == hpmax && hpmax > 1)
742 Sprintf(buf, "all %d hit points", hpmax);
743 else
744 Sprintf(buf, "%d out of %d hit point%s", hp, hpmax, plur(hpmax));
745 you_have(buf, "");
746
747 /* low max energy is feasible, so handle couple of extra special cases */
748 if (pwmax == 0 || (pw == pwmax && pwmax == 2)) /* both: not "all 2" */
749 Sprintf(buf, "%s %s", !pwmax ? "no" : "both", Power);
750 else if (pw == pwmax && pwmax > 2)
751 Sprintf(buf, "all %d %s", pwmax, Power);
752 else
753 Sprintf(buf, "%d out of %d %s", pw, pwmax, Power);
754 you_have(buf, "");
755
756 if (Upolyd) {
757 switch (mons[u.umonnum].mlevel) {
758 case 0:
759 /* status line currently being explained shows "HD:0" */
760 Strcpy(buf, "0 hit dice (actually 1/2)");
761 break;
762 case 1:
763 Strcpy(buf, "1 hit die");
764 break;
765 default:
766 Sprintf(buf, "%d hit dice", mons[u.umonnum].mlevel);
767 break;
768 }
769 you_have(buf, "");
770 }
771
772 find_ac(); /* enforces AC_MAX cap */
773 Sprintf(buf, "%d", u.uac);
774 if (abs(u.uac) == AC_MAX)
775 Sprintf(eos(buf), ", the %s possible",
776 (u.uac < 0) ? "best" : "worst");
777 enl_msg("Your armor class ", "is ", "was ", buf, "");
778
779 /* gold; similar to doprgold (#showgold) but without shop billing info;
780 includes container contents, unlike status line but like doprgold */
781 {
782 long umoney = money_cnt(gi.invent), hmoney = hidden_gold(final);
783
784 if (!umoney) {

Callers 1

enlightenmentFunction · 0.85

Calls 9

enlght_outFunction · 0.85
you_haveFunction · 0.85
find_acFunction · 0.85
eosFunction · 0.85
money_cntFunction · 0.85
hidden_goldFunction · 0.85
currencyFunction · 0.85
costly_spotFunction · 0.85
oc_to_strFunction · 0.85

Tested by

no test coverage detected