#include "player/player-skill.h"
#include "spell/spells-status.h"
#include "sv-definition/sv-weapon-types.h"
+#include "system/inner-game-data.h"
#include "system/player-type-definition.h"
#include "system/redrawing-flags-updater.h"
#include <array>
player_ptr->expfact = get_expfact(player_ptr);
/* Reset record of race/realm changes */
- player_ptr->start_race = player_ptr->prace;
+ InnerGameData::get_instance().set_start_race(player_ptr->prace);
player_ptr->old_race1 = 0L;
player_ptr->old_race2 = 0L;
player_ptr->old_realm = 0;
#include "system/baseitem-info.h"
#include "system/dungeon-info.h"
#include "system/floor-type-definition.h"
+#include "system/inner-game-data.h"
#include "system/item-entity.h"
#include "system/monster-race-info.h"
#include "system/player-type-definition.h"
{
if (PlayerRace(player_ptr).life() == PlayerRaceLifeType::UNDEAD) {
w_ptr->game_turn = (TURNS_PER_TICK * 3 * TOWN_DAWN) / 4 + 1;
- w_ptr->game_turn_limit = TURNS_PER_TICK * TOWN_DAWN * MAX_DAYS + TURNS_PER_TICK * TOWN_DAWN * 3 / 4;
} else {
w_ptr->game_turn = 1;
- w_ptr->game_turn_limit = TURNS_PER_TICK * TOWN_DAWN * (MAX_DAYS - 1) + TURNS_PER_TICK * TOWN_DAWN * 3 / 4;
}
+ InnerGameData::get_instance().init_turn_limit();
w_ptr->dungeon_turn = 1;
w_ptr->dungeon_turn_limit = TURNS_PER_TICK * TOWN_DAWN * (MAX_DAYS - 1) + TURNS_PER_TICK * TOWN_DAWN * 3 / 4;
}
#include "player/eldritch-horror.h"
#include "status/bad-status-setter.h"
#include "store/rumor.h"
+#include "system/inner-game-data.h"
#include "system/player-type-definition.h"
#include "timed-effect/timed-effects.h"
#include "view/display-messages.h"
return false;
}
- const auto &[prev_day, prev_hour, prev_min] = w_ptr->extract_date_time(player_ptr->start_race);
+ const auto &[prev_day, prev_hour, prev_min] = w_ptr->extract_date_time(InnerGameData::get_instance().get_start_race());
write_diary_stay_inn(player_ptr, prev_hour);
pass_game_turn_by_stay();
#include "system/angband-version.h"
#include "system/dungeon-info.h"
#include "system/floor-type-definition.h"
+#include "system/inner-game-data.h"
#include "system/player-type-definition.h"
#include "term/gameterm.h"
#include "term/screen-processor.h"
*/
void do_cmd_time(PlayerType *player_ptr)
{
- const auto &[day, hour, min] = w_ptr->extract_date_time(player_ptr->start_race);
+ const auto &[day, hour, min] = w_ptr->extract_date_time(InnerGameData::get_instance().get_start_race());
std::string day_buf = (day < MAX_DAYS) ? std::to_string(day) : "*****";
constexpr auto mes = _("%s日目, 時刻は%d:%02d %sです。", "This is day %s. The time is %d:%02d %s.");
msg_format(mes, day_buf.data(), (hour % 12 == 0) ? 12 : (hour % 12), min, (hour < 12) ? "AM" : "PM");
#include "player/player-status.h"
#include "player/race-info-table.h"
#include "system/angband-version.h"
+#include "system/inner-game-data.h"
#include "system/player-type-definition.h"
#include "term/screen-processor.h"
#include "term/term-color-types.h"
snprintf(the_score.gold, sizeof(the_score.gold), "%9lu", (long)player_ptr->au);
the_score.gold[9] = '\0';
- snprintf(the_score.turns, sizeof(the_score.turns), "%9lu", (long)turn_real(player_ptr, w_ptr->game_turn));
+ const auto &igd = InnerGameData::get_instance();
+ snprintf(the_score.turns, sizeof(the_score.turns), "%9d", igd.get_real_turns(w_ptr->game_turn));
the_score.turns[9] = '\0';
auto ct = time((time_t *)0);
return 0;
}
+ const auto &igd = InnerGameData::get_instance();
snprintf(the_score.what, sizeof(the_score.what), "%u.%u.%u", H_VER_MAJOR, H_VER_MINOR, H_VER_PATCH);
snprintf(the_score.pts, sizeof(the_score.pts), "%9ld", (long)calc_score(player_ptr));
snprintf(the_score.gold, sizeof(the_score.gold), "%9lu", (long)player_ptr->au);
- snprintf(the_score.turns, sizeof(the_score.turns), "%9lu", (long)turn_real(player_ptr, w_ptr->game_turn));
+ snprintf(the_score.turns, sizeof(the_score.turns), "%9d", igd.get_real_turns(w_ptr->game_turn));
angband_strcpy(the_score.day, _("今日", "TODAY"), sizeof(the_score.day));
the_score.copy_info(*player_ptr);
strcpy(the_score.how, _("yet", "nobody (yet!)"));
#include "store/store-util.h"
#include "store/store.h"
#include "system/floor-type-definition.h"
+#include "system/inner-game-data.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
#include "world/world.h"
/*!
- * @brief ゲームターンからの実時間換算を行うための補正をかける
- * @param hoge ゲームターン
- * @details アンデッド種族は18:00からゲームを開始するので、この修正を予め行う。
- * @return 修正をかけた後のゲームターン
- */
-int32_t turn_real(PlayerType *player_ptr, int32_t hoge)
-{
- switch (player_ptr->start_race) {
- case PlayerRaceType::VAMPIRE:
- case PlayerRaceType::SKELETON:
- case PlayerRaceType::ZOMBIE:
- case PlayerRaceType::SPECTRE:
- return hoge - (TURNS_PER_TICK * TOWN_DAWN * 3 / 4);
- default:
- return hoge;
- }
-}
-
-/*!
* @brief ターンのオーバーフローに対する対処
* @param player_ptr プレイヤーへの参照ポインタ
* @details ターン及びターンを記録する変数をターンの限界の1日前まで巻き戻す.
*/
void prevent_turn_overflow(PlayerType *player_ptr)
{
- if (w_ptr->game_turn < w_ptr->game_turn_limit) {
+ const auto &igd = InnerGameData::get_instance();
+ const auto game_turn_limit = igd.get_game_turn_limit();
+ if (w_ptr->game_turn < game_turn_limit) {
return;
}
- int rollback_days = 1 + (w_ptr->game_turn - w_ptr->game_turn_limit) / (TURNS_PER_TICK * TOWN_DAWN);
+ int rollback_days = 1 + (w_ptr->game_turn - game_turn_limit) / (TURNS_PER_TICK * TOWN_DAWN);
int32_t rollback_turns = TURNS_PER_TICK * TOWN_DAWN * rollback_days;
if (w_ptr->game_turn > rollback_turns) {
#include "system/angband.h"
class PlayerType;
-int32_t turn_real(PlayerType *player_ptr, int32_t hoge);
void prevent_turn_overflow(PlayerType *player_ptr);
#include "system/building-type-definition.h"
#include "system/dungeon-info.h"
#include "system/floor-type-definition.h"
+#include "system/inner-game-data.h"
#include "system/item-entity.h"
#include "system/monster-entity.h"
#include "system/monster-race-info.h"
return;
}
- fprintf(fff, _("\n\n あなたは%sとして生まれた。", "\n\n You were born as %s."), race_info[enum2i(player_ptr->start_race)].title);
+ const auto start_race = InnerGameData::get_instance().get_start_race();
+ fprintf(fff, _("\n\n あなたは%sとして生まれた。", "\n\n You were born as %s."), race_info[enum2i(start_race)].title);
for (int i = 0; i < MAX_RACES; i++) {
- if (enum2i(player_ptr->start_race) == i) {
+ if (enum2i(start_race) == i) {
continue;
}
if (i < 32) {
#include "system/angband-version.h"
#include "system/dungeon-info.h"
#include "system/floor-type-definition.h"
+#include "system/inner-game-data.h"
#include "system/player-type-definition.h"
#include "system/redrawing-flags-updater.h"
#include "system/system-variables.h"
<< format("depth: %d\n", player_ptr->current_floor_ptr->dun_level)
<< format("maxlv: %d\n", player_ptr->max_plv)
<< format("maxdp: %d\n", max_dlv[DUNGEON_ANGBAND])
- << format("au: %d\n", player_ptr->au)
- << format("turns: %d\n", turn_real(player_ptr, w_ptr->game_turn))
+ << format("au: %d\n", player_ptr->au);
+ const auto &igd = InnerGameData::get_instance();
+ score_ss << format("turns: %d\n", igd.get_real_turns(w_ptr->game_turn))
<< format("sex: %d\n", player_ptr->psex)
<< format("race: %s\n", rp_ptr->title)
<< format("class: %s\n", cp_ptr->title)
#include "player/player-status.h"
#include "system/dungeon-info.h"
#include "system/floor-type-definition.h"
+#include "system/inner-game-data.h"
#include "system/monster-race-info.h"
#include "system/player-type-definition.h"
#include "term/z-form.h"
int exe_write_diary_quest(PlayerType *player_ptr, DiaryKind dk, QuestId quest_id)
{
static auto disable_diary = false;
- const auto &[day, hour, min] = w_ptr->extract_date_time(player_ptr->start_race);
+ const auto &[day, hour, min] = w_ptr->extract_date_time(InnerGameData::get_instance().get_start_race());
if (disable_diary) {
return -1;
}
void exe_write_diary(PlayerType *player_ptr, DiaryKind dk, int num, std::string_view note)
{
static auto disable_diary = false;
- const auto &[day, hour, min] = w_ptr->extract_date_time(player_ptr->start_race);
+ const auto &[day, hour, min] = w_ptr->extract_date_time(InnerGameData::get_instance().get_start_race());
if (disable_diary) {
return;
}
#include "spell/spells-status.h"
#include "system/dungeon-info.h"
#include "system/floor-type-definition.h"
+#include "system/inner-game-data.h"
#include "system/monster-race-info.h"
#include "system/player-type-definition.h"
#include "system/system-variables.h"
void set_zangband_race(PlayerType *player_ptr)
{
- player_ptr->start_race = player_ptr->prace;
+ InnerGameData::get_instance().set_start_race(player_ptr->prace);
player_ptr->old_race1 = 0L;
player_ptr->old_race2 = 0L;
player_ptr->old_realm = 0;
#include "system/angband-system.h"
#include "system/dungeon-info.h"
#include "system/floor-type-definition.h"
+#include "system/inner-game-data.h"
#include "system/player-type-definition.h"
#include "timed-effect/timed-effects.h"
#include "world/world.h"
static void set_race(PlayerType *player_ptr)
{
- player_ptr->start_race = i2enum<PlayerRaceType>(rd_byte());
+ InnerGameData::get_instance().set_start_race(i2enum<PlayerRaceType>(rd_byte()));
player_ptr->old_race1 = rd_u32b();
player_ptr->old_race2 = rd_u32b();
player_ptr->old_realm = rd_s16b();
#include "system/building-type-definition.h"
#include "system/dungeon-info.h"
#include "system/floor-type-definition.h"
+#include "system/inner-game-data.h"
#include "system/player-type-definition.h"
#include "world/world.h"
player_ptr->autopick_autoregister = rd_bool();
}
-static void set_undead_turn_limit(PlayerType *player_ptr)
-{
- switch (player_ptr->start_race) {
- case PlayerRaceType::VAMPIRE:
- case PlayerRaceType::SKELETON:
- case PlayerRaceType::ZOMBIE:
- case PlayerRaceType::SPECTRE:
- w_ptr->game_turn_limit = TURNS_PER_TICK * TOWN_DAWN * MAX_DAYS + TURNS_PER_TICK * TOWN_DAWN * 3 / 4;
- break;
- default:
- w_ptr->game_turn_limit = TURNS_PER_TICK * TOWN_DAWN * (MAX_DAYS - 1) + TURNS_PER_TICK * TOWN_DAWN * 3 / 4;
- break;
- }
-}
-
static void rd_world_info(PlayerType *player_ptr)
{
- set_undead_turn_limit(player_ptr);
+ auto &igd = InnerGameData::get_instance();
+ igd.init_turn_limit();
w_ptr->dungeon_turn_limit = TURNS_PER_TICK * TOWN_DAWN * (MAX_DAYS - 1) + TURNS_PER_TICK * TOWN_DAWN * 3 / 4;
player_ptr->current_floor_ptr->generated_turn = rd_s32b();
if (h_older_than(1, 7, 0, 4)) {
#include "main/music-definitions-table.h"
#include "monster-race/monster-race.h"
#include "system/floor-type-definition.h"
+#include "system/inner-game-data.h"
#include "system/monster-entity.h"
#include "system/monster-race-info.h"
#include "system/player-type-definition.h"
scene_target_monster.ap_r_ptr = nullptr;
}
-static GAME_TURN get_game_turn()
+static int get_game_turn()
{
- GAME_TURN ret = w_ptr->game_turn;
- if (ret == w_ptr->game_turn_limit) {
- ret = 0;
+ auto turns = w_ptr->game_turn;
+ if (turns == InnerGameData::get_instance().get_game_turn_limit()) {
+ return 0;
}
- return ret;
+
+ return turns;
}
/*!
/*!
* @details 既にplayer_raceが存在するので_typeと付けた
*/
-enum class PlayerRaceType {
+enum class PlayerRaceType : int {
HUMAN = 0,
HALF_ELF = 1,
ELF = 2,
#include "system/building-type-definition.h"
#include "system/dungeon-info.h"
#include "system/floor-type-definition.h"
+#include "system/inner-game-data.h"
#include "system/player-type-definition.h"
#include "timed-effect/timed-effects.h"
#include "world/world.h"
std::visit(PlayerClassSpecificDataWriter(), player_ptr->class_specific_data);
- wr_byte((byte)player_ptr->start_race);
+ wr_byte(static_cast<uint8_t>(InnerGameData::get_instance().get_start_race()));
wr_s32b(player_ptr->old_race1);
wr_s32b(player_ptr->old_race2);
wr_s16b(player_ptr->old_realm);
*/
#include "system/inner-game-data.h"
+#include "player-info/race-types.h"
+#include "system/gamevalue.h"
InnerGameData InnerGameData::instance{};
+InnerGameData::InnerGameData()
+ : start_race(PlayerRaceType::HUMAN)
+{
+}
+
InnerGameData &InnerGameData::get_instance()
{
return instance;
}
+
+PlayerRaceType InnerGameData::get_start_race() const
+{
+ return this->start_race;
+}
+
+int InnerGameData::get_game_turn_limit() const
+{
+ return this->game_turn_limit;
+}
+
+void InnerGameData::init_turn_limit()
+{
+ switch (this->start_race) {
+ case PlayerRaceType::VAMPIRE:
+ case PlayerRaceType::SKELETON:
+ case PlayerRaceType::ZOMBIE:
+ case PlayerRaceType::SPECTRE:
+ this->game_turn_limit = TURNS_PER_TICK * TOWN_DAWN * MAX_DAYS + TURNS_PER_TICK * TOWN_DAWN * 3 / 4;
+ return;
+ default:
+ this->game_turn_limit = TURNS_PER_TICK * TOWN_DAWN * (MAX_DAYS - 1) + TURNS_PER_TICK * TOWN_DAWN * 3 / 4;
+ return;
+ }
+}
+
+void InnerGameData::set_start_race(PlayerRaceType race)
+{
+ this->start_race = race;
+}
+
+/*!
+ * @brief ゲームターンからの実時間換算を行うための補正をかける
+ * @param turns ゲームターン
+ * @details アンデッド種族は18:00からゲームを開始するので、この修正を予め行う。
+ * @return 修正をかけた後のゲームターン
+ */
+int InnerGameData::get_real_turns(int turns) const
+{
+ switch (this->start_race) {
+ case PlayerRaceType::VAMPIRE:
+ case PlayerRaceType::SKELETON:
+ case PlayerRaceType::ZOMBIE:
+ case PlayerRaceType::SPECTRE:
+ return turns - (TURNS_PER_TICK * TOWN_DAWN * 3 / 4);
+ default:
+ return turns;
+ }
+}
#pragma once
+enum class PlayerRaceType : int;
class InnerGameData {
public:
InnerGameData(InnerGameData &&) = delete;
~InnerGameData() = default;
static InnerGameData &get_instance();
+ PlayerRaceType get_start_race() const;
+ int get_game_turn_limit() const;
+ int get_real_turns(int turns) const;
+ void set_start_race(PlayerRaceType race);
+ void init_turn_limit();
+
private:
- InnerGameData() = default;
+ InnerGameData();
static InnerGameData instance;
+
+ PlayerRaceType start_race; //!< ゲーム開始時の種族.
+ int game_turn_limit = 0; //!< 最大ゲームターン
};
BIT_FLAGS8 knowledge{}; /* Knowledge about yourself */
BIT_FLAGS visit{}; /* Visited towns */
- PlayerRaceType start_race{}; /* Race at birth */
BIT_FLAGS old_race1{}; /* Record of race changes */
BIT_FLAGS old_race2{}; /* Record of race changes */
int16_t old_realm{}; /* Record of realm changes */
#include "player/player-status.h"
#include "sv-definition/sv-bow-types.h"
#include "system/floor-type-definition.h"
+#include "system/inner-game-data.h"
#include "system/item-entity.h"
#include "system/monster-entity.h"
#include "system/player-type-definition.h"
*/
static void display_playtime_in_game(PlayerType *player_ptr)
{
- const auto &[day, hour, min] = w_ptr->extract_date_time(player_ptr->start_race);
+ const auto &[day, hour, min] = w_ptr->extract_date_time(InnerGameData::get_instance().get_start_race());
const auto is_days_countable = day < MAX_DAYS;
const std::string fmt = is_days_countable ? _("%d日目 %2d:%02d", "Day %d %2d:%02d") : _("*****日目 %2d:%02d", "Day ***** %2d:%02d");
const auto mes = is_days_countable ? format(fmt.data(), day, hour, min) : format(fmt.data(), hour, min);
#include "system/dungeon-info.h"
#include "system/floor-type-definition.h"
#include "system/grid-type-definition.h"
+#include "system/inner-game-data.h"
#include "system/monster-entity.h"
#include "system/player-type-definition.h"
#include "system/terrain-type-definition.h"
const int a_day = TURNS_PER_TICK * TOWN_DAWN;
const int prev_turn_in_today = ((w_ptr->game_turn - TURNS_PER_TICK) % a_day + a_day / 4) % a_day;
const int prev_min = (1440 * prev_turn_in_today / a_day) % 60;
- std::tie(std::ignore, this->hour, this->min) = w_ptr->extract_date_time(this->player_ptr->start_race);
+ std::tie(std::ignore, this->hour, this->min) = w_ptr->extract_date_time(InnerGameData::get_instance().get_start_race());
update_dungeon_feeling(this->player_ptr);
process_downward();
process_monster_arena();
c_put_str(TERM_WHITE, " ", row, COL_DAY);
auto day = 0;
- std::tie(day, this->hour, this->min) = w_ptr->extract_date_time(this->player_ptr->start_race);
+ std::tie(day, this->hour, this->min) = w_ptr->extract_date_time(InnerGameData::get_instance().get_start_race());
if (day < 1000) {
c_put_str(TERM_WHITE, format(_("%2d日目", "Day%3d"), day), row, COL_DAY);
} else {
POSITION max_wild_x{}; /*!< Maximum size of the wilderness */
POSITION max_wild_y{}; /*!< Maximum size of the wilderness */
GAME_TURN game_turn{}; /*!< 画面表示上のゲーム時間基準となるターン / Current game turn */
- GAME_TURN game_turn_limit{}; /*!< game_turnの最大値 / Limit of game_turn */
GAME_TURN dungeon_turn{}; /*!< NASTY生成の計算に関わる内部ターン値 / Game turn in dungeon */
GAME_TURN dungeon_turn_limit{}; /*!< dungeon_turnの最大値 / Limit of game_turn in dungeon */
GAME_TURN arena_start_turn{}; /*!< 闘技場賭博の開始ターン値 */