]> granicus.if.org Git - nethack/commitdiff
Use macro for spell pw cost per spell level
authorPasi Kallinen <paxed@alt.org>
Mon, 28 Feb 2022 20:21:37 +0000 (22:21 +0200)
committerPasi Kallinen <paxed@alt.org>
Mon, 28 Feb 2022 20:21:37 +0000 (22:21 +0200)
include/spell.h
src/spell.c
src/u_init.c

index 4090850b9ac9be82de9688fa608a1302158b3567..095e6605dca5e81ecb3a501163742ab4398b9b96 100644 (file)
@@ -25,4 +25,7 @@ struct spell {
 #define spellid(spell) g.spl_book[spell].sp_id
 #define spellknow(spell) g.spl_book[spell].sp_know
 
+/* how much Pw a spell of level lvl costs to cast? */
+#define SPELL_LEV_PW(lvl) ((lvl) * 5)
+
 #endif /* SPELL_H */
index 76de4c57d3ee0aedb32d9e782fd2c367f8585231..ad4aee72503dca9b1146cf7f4d0713a9d6485e60 100644 (file)
@@ -924,7 +924,7 @@ spelleffects(int spell_otyp, boolean atme)
      *  Note: dotele() also calculates energy use and checks nutrition
      *  and strength requirements; if any of these change, update it too.
      */
-    energy = (spellev(spell) * 5); /* 5 <= energy <= 35 */
+    energy = SPELL_LEV_PW(spellev(spell)); /* 5 <= energy <= 35 */
 
     /*
      * Spell casting no longer affects knowledge of the spell. A
index cc5e5086fced2adf97d430e8cc9076259a5ad97f..575eea60d5ed016624b4045ed817615569796816 100644 (file)
@@ -932,10 +932,10 @@ u_init(void)
         break;
     }
 
-    /* If we have at least one spell, force starting Pw to be 5,
+    /* If we have at least one spell, force starting Pw to be enough,
        so hero can cast the level 1 spell they should have */
-    if (num_spells() && (u.uenmax < 5))
-        u.uen = u.uenmax = u.uenpeak = u.ueninc[u.ulevel] = 5;
+    if (num_spells() && (u.uenmax < SPELL_LEV_PW(1)))
+        u.uen = u.uenmax = u.uenpeak = u.ueninc[u.ulevel] = SPELL_LEV_PW(1);
 
     return;
 }