OSDN Git Service

Merge pull request #2390 from Slimebreath6078/hotfix/random_quest_50F
[hengbandforosx/hengbandosx.git] / src / mutation / mutation-calculator.cpp
1 /*!
2  * @brief 突然変異の各種計算 / Calculations for mutation
3  * @date 2014/01/11
4  * @author
5  * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
6  *
7  * This software may be copied and distributed for educational, research,
8  * and not for profit purposes provided that this copyright and statement
9  * are included in all such copies.  Other copyrights may also apply
10  * 2014 Deskull rearranged comment for Doxygen
11  * 2020 Hourier rearranged for dividing processes.
12  */
13
14 #include "mutation/mutation-calculator.h"
15 #include "mutation/mutation-flag-types.h"
16 #include "player-base/player-race.h"
17 #include "system/player-type-definition.h"
18
19 /*!
20  * @brief 現在プレイヤー得ている突然変異の数を返す。
21  * @return 現在得ている突然変異の数
22  */
23 static int count_mutations(PlayerType *player_ptr)
24 {
25     return player_ptr->muta.count();
26 }
27
28 /*!
29  * @brief 突然変異による自然回復ペナルティをパーセント値で返す /
30  * Return the modifier to the regeneration rate (in percent)
31  * @return ペナルティ修正(%)
32  * @details
33  * Beastman get 10 "free" mutations and only 5% decrease per additional mutation.
34  * Max 90% decrease in regeneration speed.
35  */
36 int calc_mutant_regenerate_mod(PlayerType *player_ptr)
37 {
38     int regen;
39     int mod = 10;
40     int count = count_mutations(player_ptr);
41     if (player_ptr->ppersonality == PERSONALITY_LUCKY) {
42         count--;
43     }
44
45     if (PlayerRace(player_ptr).equals(PlayerRaceType::BEASTMAN)) {
46         count -= 10;
47         mod = 5;
48     }
49
50     if (count <= 0) {
51         return 100;
52     }
53
54     regen = 100 - count * mod;
55     if (regen < 10) {
56         regen = 10;
57     }
58
59     return regen;
60 }