]> granicus.if.org Git - nethack/commitdiff
protection enlightenment (trunk only)
authornethack.rankin <nethack.rankin>
Sat, 27 May 2006 01:26:50 +0000 (01:26 +0000)
committernethack.rankin <nethack.rankin>
Sat, 27 May 2006 01:26:50 +0000 (01:26 +0000)
     Yesterday's change to have enlightenment give "you have a <small,
moderate,&> defense bonus" instead of "you are protected" would yield
"you have a small defense penalty" if the combined protection value (from
rings, divine gift, and spell) was 0.  This changes the formatting routine
to give "you have no defense bonus" in that situation, then changes the
caller to only display the protection/defense attribute when non-zero so
the "no bonus" case will never actually happen.

src/cmd.c

index 2388a0421a3fa3266f570f22c24fb55c7cc45679..23ddcba6f560c25447653e828857e4132b359d73 100644 (file)
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -1008,11 +1008,12 @@ char *outbuf;
        else if (absamt <= 12) modif = "large";
        else modif = "huge";
 
-       bonus = (incamt > 0) ? "bonus" : "penalty";
+       modif = !incamt ? "no" : an(modif); /* ("no" case shouldn't happen) */
+       bonus = (incamt >= 0) ? "bonus" : "penalty";
        /* "bonus <foo>" (to hit) vs "<bar> bonus" (damage, defense) */
        invrt = strcmp(inctyp, "to hit") ? TRUE : FALSE;
 
-       Sprintf(outbuf, "%s %s %s", an(modif),
+       Sprintf(outbuf, "%s %s %s", modif,
                invrt ? inctyp : bonus, invrt ? bonus : inctyp);
        if (final || wizard)
            Sprintf(eos(outbuf), " (%s%d)",
@@ -1235,7 +1236,8 @@ int final;        /* 0 => still in progress; 1 => over, survived; 2 => dead */
            if(uright && uright->otyp == RIN_PROTECTION) prot += uright->spe;
            if (HProtection & INTRINSIC) prot += u.ublessed;
            prot += u.uspellprot;
-           you_have(enlght_combatinc("defense", prot, final, buf), "");
+           if (prot)
+               you_have(enlght_combatinc("defense", prot, final, buf), "");
        }
        if ((armpro = magic_negation(&youmonst)) > 0) {
            /* magic cancellation factor, conferred by worn armor */