summaryrefslogtreecommitdiff
path: root/src/wizard2.cc
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2016-09-17 09:58:15 +0200
committerBardur Arantsson <bardur@scientician.net>2016-09-17 09:58:15 +0200
commitb85a1f777946af3ba763942ee78a7a4bce2afdb0 (patch)
treef4b41468e525dcf78e9d7ed0df56cf344c87ad36 /src/wizard2.cc
parent8bf363159104aa0c87d8021e731022c41df8037f (diff)
Move player_hp[] into Game
Diffstat (limited to 'src/wizard2.cc')
-rw-r--r--src/wizard2.cc31
1 files changed, 7 insertions, 24 deletions
diff --git a/src/wizard2.cc b/src/wizard2.cc
index 359d5c5a..dd0d50e8 100644
--- a/src/wizard2.cc
+++ b/src/wizard2.cc
@@ -9,6 +9,7 @@
#include "wizard2.hpp"
#include "artifact_type.hpp"
+#include "birth.hpp"
#include "cave.hpp"
#include "cave_type.hpp"
#include "cmd4.hpp"
@@ -116,32 +117,14 @@ static void teleport_player_town(int town)
*/
void do_cmd_rerate(void)
{
- int min_value, max_value, i, percent;
+ auto &player_hp = game->player_hp;
- min_value = (PY_MAX_LEVEL * 3 * (p_ptr->hitdie - 1)) / 8;
- min_value += PY_MAX_LEVEL;
+ // Force HP re-roll
+ roll_player_hp();
- max_value = (PY_MAX_LEVEL * 5 * (p_ptr->hitdie - 1)) / 8;
- max_value += PY_MAX_LEVEL;
-
- player_hp[0] = p_ptr->hitdie;
-
- /* Rerate */
- while (1)
- {
- /* Collect values */
- for (i = 1; i < PY_MAX_LEVEL; i++)
- {
- player_hp[i] = randint(p_ptr->hitdie);
- player_hp[i] += player_hp[i - 1];
- }
-
- /* Legal values */
- if ((player_hp[PY_MAX_LEVEL - 1] >= min_value) &&
- (player_hp[PY_MAX_LEVEL - 1] <= max_value)) break;
- }
-
- percent = (int)(((long)player_hp[PY_MAX_LEVEL - 1] * 200L) /
+ // Calculate life rating
+ int percent = static_cast<int>(
+ (static_cast<long>(player_hp[PY_MAX_LEVEL - 1]) * 200L) /
(p_ptr->hitdie + ((PY_MAX_LEVEL - 1) * p_ptr->hitdie)));
/* Update and redraw hitpoints */