From: Pasi Kallinen Date: Mon, 28 Feb 2022 20:21:37 +0000 (+0200) Subject: Use macro for spell pw cost per spell level X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b1729578313518bb4b0c867ae719e88af879d504;p=nethack Use macro for spell pw cost per spell level --- diff --git a/include/spell.h b/include/spell.h index 4090850b9..095e6605d 100644 --- a/include/spell.h +++ b/include/spell.h @@ -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 */ diff --git a/src/spell.c b/src/spell.c index 76de4c57d..ad4aee725 100644 --- a/src/spell.c +++ b/src/spell.c @@ -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 diff --git a/src/u_init.c b/src/u_init.c index cc5e5086f..575eea60d 100644 --- a/src/u_init.c +++ b/src/u_init.c @@ -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; }