}
difficulty = difficulty / 2;
- const BASE_STATUS stat = player_ptr->stat_cur[rpi_ptr->stat];
- int sum = 0;
- for (int i = 1; i <= stat; i++) {
+ const auto stat = player_ptr->stat_cur[rpi_ptr->stat];
+ auto sum = 0;
+ for (auto i = 1; i <= stat; i++) {
int val = i - difficulty;
if (val > 0) {
sum += (val <= difficulty) ? val : difficulty;
#include "system/player-type-definition.h"
/*! オートロール能力値の乱数分布 / emulate 5 + 1d3 + 1d4 + 1d5 by randint0(60) */
-BASE_STATUS rand3_4_5[60] = {
+short rand3_4_5[60] = {
8, 9, 9, 9, 10, 10, 10, 10, 10, 10, /*00-09*/
11, 11, 11, 11, 11, 11, 11, 11, 11, 12, /*10-19*/
12, 12, 12, 12, 12, 12, 12, 12, 12, 12, /*20-29*/
while (true) {
int sum = 0;
for (int i = 0; i < 2; i++) {
- int32_t tmp = randint0(60 * 60 * 60);
- BASE_STATUS val;
-
+ auto tmp = randint0(60 * 60 * 60);
for (int j = 0; j < 3; j++) {
int stat = i * 3 + j;
/* Extract 5 + 1d3 + 1d4 + 1d5 */
- val = rand3_4_5[tmp % 60];
+ auto val = rand3_4_5[tmp % 60];
sum += val;
player_ptr->stat_cur[stat] = player_ptr->stat_max[stat] = val;
*/
void get_max_stats(PlayerType *player_ptr)
{
- int dice[6];
+ int dice[6]{};
while (true) {
- int j = 0;
- for (int i = 0; i < A_MAX; i++) {
+ auto j = 0;
+ for (auto i = 0; i < A_MAX; i++) {
dice[i] = randint1(7);
j += dice[i];
}
}
}
- for (int i = 0; i < A_MAX; i++) {
- BASE_STATUS max_max = 18 + 60 + dice[i] * 10;
+ for (auto i = 0; i < A_MAX; i++) {
+ short max_max = 18 + 60 + dice[i] * 10;
player_ptr->stat_max_max[i] = max_max;
if (player_ptr->stat_max[i] > max_max) {
player_ptr->stat_max[i] = max_max;
PRICE au{}; /*!< 初期の所持金 */
- BASE_STATUS stat_max[6]{}; /* Current "maximal" stat values */
- BASE_STATUS stat_max_max[6]{}; /* Maximal "maximal" stat values */
+ short stat_max[6]{}; /* Current "maximal" stat values */
+ short stat_max_max[6]{}; /* Maximal "maximal" stat values */
int player_hp[PY_MAX_LEVEL]{};
int16_t chaos_patron{}; /*! カオスパトロンのID */
;
}
- BASE_STATUS max1 = player_ptr->stat_max[i];
- BASE_STATUS cur1 = player_ptr->stat_cur[i];
- BASE_STATUS max2 = player_ptr->stat_max[j];
- BASE_STATUS cur2 = player_ptr->stat_cur[j];
+ const auto max1 = player_ptr->stat_max[i];
+ const auto cur1 = player_ptr->stat_cur[i];
+ const auto max2 = player_ptr->stat_max[j];
+ const auto cur2 = player_ptr->stat_cur[j];
player_ptr->stat_max[i] = max2;
player_ptr->stat_cur[i] = cur2;
*/
bool inc_stat(PlayerType *player_ptr, int stat)
{
- BASE_STATUS gain;
- BASE_STATUS value = player_ptr->stat_cur[stat];
+ auto value = player_ptr->stat_cur[stat];
if (value >= player_ptr->stat_max_max[stat]) {
return false;
}
if (value < 18) {
- gain = ((randint0(100) < 75) ? 1 : 2);
- value += gain;
+ value += (randint0(100) < 75) ? 1 : 2;
} else if (value < (player_ptr->stat_max_max[stat] - 2)) {
- gain = (((player_ptr->stat_max_max[stat]) - value) / 2 + 3) / 2;
+ auto gain = (((player_ptr->stat_max_max[stat]) - value) / 2 + 3) / 2;
if (gain < 1) {
gain = 1;
}
*/
bool dec_stat(PlayerType *player_ptr, int stat, int amount, int permanent)
{
- bool res = false;
- BASE_STATUS cur = player_ptr->stat_cur[stat];
- BASE_STATUS max = player_ptr->stat_max[stat];
+ auto res = false;
+ auto cur = player_ptr->stat_cur[stat];
+ auto max = player_ptr->stat_max[stat];
int same = (cur == max);
if (cur > 3) {
if (cur <= 18) {
typedef int32_t MANA_POINT; /*!< ゲーム中のMP型を定義 */
typedef int16_t HIT_PROB; /*!< ゲーム中の装備命中修正値を定義 */
-typedef int16_t BASE_STATUS; /*!< ゲーム中の基礎能力値型を定義 */
typedef int32_t MONSTER_NUMBER; /*!< ゲーム中のモンスター数型を定義 */
typedef int32_t ITEM_NUMBER; /*!< ゲーム中のアイテム数型を定義 */
int16_t max_plv{}; /* Max Player Level */
- BASE_STATUS stat_max[A_MAX]{}; /* Current "maximal" stat values */
- BASE_STATUS stat_max_max[A_MAX]{}; /* Maximal "maximal" stat values */
- BASE_STATUS stat_cur[A_MAX]{}; /* Current "natural" stat values */
+ short stat_max[A_MAX]{}; /* Current "maximal" stat values */
+ short stat_max_max[A_MAX]{}; /* Maximal "maximal" stat values */
+ short stat_cur[A_MAX]{}; /* Current "natural" stat values */
int16_t learned_spells{};
int16_t add_spells{};
*/
void wiz_change_status(PlayerType *player_ptr)
{
- int tmp_int;
+ short stat;
char tmp_val[160];
char ppp[80];
for (int i = 0; i < A_MAX; i++) {
return;
}
- tmp_int = atoi(tmp_val);
- if (tmp_int > player_ptr->stat_max_max[i]) {
- tmp_int = player_ptr->stat_max_max[i];
- } else if (tmp_int < 3) {
- tmp_int = 3;
+ stat = static_cast<short>(atoi(tmp_val));
+ if (stat > player_ptr->stat_max_max[i]) {
+ stat = player_ptr->stat_max_max[i];
+ } else if (stat < 3) {
+ stat = 3;
}
- player_ptr->stat_cur[i] = player_ptr->stat_max[i] = (BASE_STATUS)tmp_int;
+ player_ptr->stat_cur[i] = player_ptr->stat_max[i] = stat;
}
strnfmt(tmp_val, sizeof(tmp_val), "%d", PlayerSkill::weapon_exp_at(PlayerSkillRank::MASTER));