From: Pasi Kallinen Date: Sat, 23 Apr 2016 09:00:02 +0000 (+0300) Subject: Unify piousness strings X-Git-Tag: NetHack-3.6.1_RC01~814 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=638aa6969c62319d0d2f5fa2b2a3905d6a5a6111;p=nethack Unify piousness strings --- diff --git a/include/extern.h b/include/extern.h index 3ac113ca8..57abce50d 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1791,6 +1791,7 @@ E const char *FDECL(align_str, (ALIGNTYP_P)); E void FDECL(mstatusline, (struct monst *)); E void NDECL(ustatusline); E void NDECL(self_invis_message); +E char *FDECL(piousness, (boolean, const char *)); E void FDECL(pudding_merge_message, (struct obj *, struct obj *)); /* ### polyself.c ### */ diff --git a/src/cmd.c b/src/cmd.c index 033e73cd6..061a3d59e 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -1950,27 +1950,12 @@ int final; you_are(hofe_titles[u.uevent.uhand_of_elbereth - 1], ""); } - /* note: piousness 20 matches MIN_QUEST_ALIGN (quest.h) */ - if (u.ualign.record >= 20) - you_are("piously aligned", ""); - else if (u.ualign.record > 13) - you_are("devoutly aligned", ""); - else if (u.ualign.record > 8) - you_are("fervently aligned", ""); - else if (u.ualign.record > 3) - you_are("stridently aligned", ""); - else if (u.ualign.record == 3) - you_are("aligned", ""); - else if (u.ualign.record > 0) - you_are("haltingly aligned", ""); - else if (u.ualign.record == 0) - you_are("nominally aligned", ""); - else if (u.ualign.record >= -3) - you_have("strayed", ""); - else if (u.ualign.record >= -8) - you_have("sinned", ""); + Sprintf(buf, "%s", piousness(TRUE, "aligned")); + if (u.ualign.record >= 0) + you_are(buf, ""); else - you_have("transgressed", ""); + you_have(buf, ""); + if (wizard) { Sprintf(buf, " %d", u.ualign.record); enl_msg("Your alignment ", "is", "was", buf, ""); diff --git a/src/pline.c b/src/pline.c index 3775a7c14..85df21188 100644 --- a/src/pline.c +++ b/src/pline.c @@ -538,23 +538,8 @@ ustatusline() Strcat(info, mon_nam(u.ustuck)); } - pline("Status of %s (%s%s): Level %d HP %d(%d) AC %d%s.", plname, - (u.ualign.record >= 20) - ? "piously " - : (u.ualign.record > 13) - ? "devoutly " - : (u.ualign.record > 8) - ? "fervently " - : (u.ualign.record > 3) - ? "stridently " - : (u.ualign.record == 3) - ? "" - : (u.ualign.record >= 1) - ? "haltingly " - : (u.ualign.record == 0) - ? "nominally " - : "insufficiently ", - align_str(u.ualign.type), + pline("Status of %s (%s): Level %d HP %d(%d) AC %d%s.", plname, + piousness(FALSE, align_str(u.ualign.type)), Upolyd ? mons[u.umonnum].mlevel : u.ulevel, Upolyd ? u.mh : u.uhp, Upolyd ? u.mhmax : u.uhpmax, u.uac, info); } @@ -568,6 +553,46 @@ self_invis_message() : "can't see yourself"); } +char * +piousness(showneg, suffix) +boolean showneg; +const char *suffix; +{ + static char buf[BUFSZ]; + char *pio; + /* note: piousness 20 matches MIN_QUEST_ALIGN (quest.h) */ + if (u.ualign.record >= 20) + pio = "piously"; + else if (u.ualign.record > 13) + pio = "devoutly"; + else if (u.ualign.record > 8) + pio = "fervently"; + else if (u.ualign.record > 3) + pio = "stridently"; + else if (u.ualign.record == 3) + pio = ""; + else if (u.ualign.record > 0) + pio = "haltingly"; + else if (u.ualign.record == 0) + pio = "nominally"; + else if (!showneg) + pio = "insufficiently"; + else if (u.ualign.record >= -3) + pio = "strayed"; + else if (u.ualign.record >= -8) + pio = "sinned"; + else + pio = "transgressed"; + + Sprintf(buf, "%s", pio); + if (suffix && (!showneg || u.ualign.record >= 0)) { + if (u.ualign.record != 3) + Strcat(buf, " "); + Strcat(buf, suffix); + } + return buf; +} + void pudding_merge_message(otmp, otmp2) struct obj *otmp;