From a024266098e69f22e65c2d2010472d86da73b2f6 Mon Sep 17 00:00:00 2001 From: Hourier Date: Fri, 21 Aug 2020 12:10:13 +0900 Subject: [PATCH] [Refactor] #40647 Separated resistance-info.c/h from self-info.c --- Hengband/Hengband/Hengband.vcxproj | 2 ++ Hengband/Hengband/Hengband.vcxproj.filters | 6 ++++ src/Makefile.am | 1 + src/player-info/resistance-info.c | 53 ++++++++++++++++++++++++++++++ src/player-info/resistance-info.h | 6 ++++ src/player-info/self-info.c | 48 ++------------------------- 6 files changed, 70 insertions(+), 46 deletions(-) create mode 100644 src/player-info/resistance-info.c create mode 100644 src/player-info/resistance-info.h diff --git a/Hengband/Hengband/Hengband.vcxproj b/Hengband/Hengband/Hengband.vcxproj index 6d40cdff8..081b5eba4 100644 --- a/Hengband/Hengband/Hengband.vcxproj +++ b/Hengband/Hengband/Hengband.vcxproj @@ -327,6 +327,7 @@ + @@ -969,6 +970,7 @@ + diff --git a/Hengband/Hengband/Hengband.vcxproj.filters b/Hengband/Hengband/Hengband.vcxproj.filters index 1bbdd4dc4..01b989b37 100644 --- a/Hengband/Hengband/Hengband.vcxproj.filters +++ b/Hengband/Hengband/Hengband.vcxproj.filters @@ -2141,6 +2141,9 @@ player-info + + player-info + @@ -4636,6 +4639,9 @@ player-info + + player-info + diff --git a/src/Makefile.am b/src/Makefile.am index 421337ba7..cb6b3dc6b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -636,6 +636,7 @@ hengband_SOURCES = \ player-info/class-ability-info.c player-info/class-ability-info.h \ player-info/mutation-info.c player-info/mutation-info.h \ player-info/race-ability-info.c player-info/race-ability-info.h \ + player-info/resistance-info.c player-info/resistance-info.h \ player-info/self-info.c player-info/self-info.h \ player-info/self-info-util.c player-info/self-info-util.h \ \ diff --git a/src/player-info/resistance-info.c b/src/player-info/resistance-info.c new file mode 100644 index 000000000..a031de747 --- /dev/null +++ b/src/player-info/resistance-info.c @@ -0,0 +1,53 @@ +#include "player-info/resistance-info.h" +#include "player-info/self-info-util.h" +#include "player/player-race.h" +#include "status/element-resistance.h" + +void set_element_resistance_info(player_type* creature_ptr, self_info_type* si_ptr) +{ + if (creature_ptr->immune_acid) { + si_ptr->info[si_ptr->line++] = _("‚ ‚È‚½‚ÍŽ_‚ɑ΂·‚銮‘S‚È‚é–Ɖu‚ðŽ‚Á‚Ä‚¢‚éB", "You are completely immune to acid."); + } else if (creature_ptr->resist_acid && is_oppose_acid(creature_ptr)) { + si_ptr->info[si_ptr->line++] = _("‚ ‚È‚½‚ÍŽ_‚Ö‚Ì‹­—͂ȑϐ«‚ðŽ‚Á‚Ä‚¢‚éB", "You resist acid exceptionally well."); + } else if (creature_ptr->resist_acid || is_oppose_acid(creature_ptr)) { + si_ptr->info[si_ptr->line++] = _("‚ ‚È‚½‚ÍŽ_‚ւ̑ϐ«‚ðŽ‚Á‚Ä‚¢‚éB", "You are resistant to acid."); + } + + if (creature_ptr->immune_elec) { + si_ptr->info[si_ptr->line++] = _("‚ ‚È‚½‚Í“dŒ‚‚ɑ΂·‚銮‘S‚È‚é–Ɖu‚ðŽ‚Á‚Ä‚¢‚éB", "You are completely immune to lightning."); + } else if (creature_ptr->resist_elec && is_oppose_elec(creature_ptr)) { + si_ptr->info[si_ptr->line++] = _("‚ ‚È‚½‚Í“dŒ‚‚Ö‚Ì‹­—͂ȑϐ«‚ðŽ‚Á‚Ä‚¢‚éB", "You resist lightning exceptionally well."); + } else if (creature_ptr->resist_elec || is_oppose_elec(creature_ptr)) { + si_ptr->info[si_ptr->line++] = _("‚ ‚È‚½‚Í“dŒ‚‚ւ̑ϐ«‚ðŽ‚Á‚Ä‚¢‚éB", "You are resistant to lightning."); + } + + if (is_specific_player_race(creature_ptr, RACE_ANDROID) && !creature_ptr->immune_elec) { + si_ptr->info[si_ptr->line++] = _("‚ ‚È‚½‚Í“dŒ‚‚ÉŽã‚¢B", "You are susceptible to damage from lightning."); + } + + if (creature_ptr->immune_fire) { + si_ptr->info[si_ptr->line++] = _("‚ ‚È‚½‚͉΂ɑ΂·‚銮‘S‚È‚é–Ɖu‚ðŽ‚Á‚Ä‚¢‚éB", "You are completely immune to fire."); + } else if (creature_ptr->resist_fire && is_oppose_fire(creature_ptr)) { + si_ptr->info[si_ptr->line++] = _("‚ ‚È‚½‚͉΂ւ̋­—͂ȑϐ«‚ðŽ‚Á‚Ä‚¢‚éB", "You resist fire exceptionally well."); + } else if (creature_ptr->resist_fire || is_oppose_fire(creature_ptr)) { + si_ptr->info[si_ptr->line++] = _("‚ ‚È‚½‚͉΂ւ̑ϐ«‚ðŽ‚Á‚Ä‚¢‚éB", "You are resistant to fire."); + } + + if (is_specific_player_race(creature_ptr, RACE_ENT) && !creature_ptr->immune_fire) { + si_ptr->info[si_ptr->line++] = _("‚ ‚È‚½‚͉΂ɎアB", "You are susceptible to damage from fire."); + } + + if (creature_ptr->immune_cold) { + si_ptr->info[si_ptr->line++] = _("‚ ‚È‚½‚Í—â‹C‚ɑ΂·‚銮‘S‚È‚é–Ɖu‚ðŽ‚Á‚Ä‚¢‚éB", "You are completely immune to cold."); + } else if (creature_ptr->resist_cold && is_oppose_cold(creature_ptr)) { + si_ptr->info[si_ptr->line++] = _("‚ ‚È‚½‚Í—â‹C‚Ö‚Ì‹­—͂ȑϐ«‚ðŽ‚Á‚Ä‚¢‚éB", "You resist cold exceptionally well."); + } else if (creature_ptr->resist_cold || is_oppose_cold(creature_ptr)) { + si_ptr->info[si_ptr->line++] = _("‚ ‚È‚½‚Í—â‹C‚ւ̑ϐ«‚ðŽ‚Á‚Ä‚¢‚éB", "You are resistant to cold."); + } + + if (creature_ptr->resist_pois && is_oppose_pois(creature_ptr)) { + si_ptr->info[si_ptr->line++] = _("‚ ‚È‚½‚Í“Å‚Ö‚Ì‹­—͂ȑϐ«‚ðŽ‚Á‚Ä‚¢‚éB", "You resist poison exceptionally well."); + } else if (creature_ptr->resist_pois || is_oppose_pois(creature_ptr)) { + si_ptr->info[si_ptr->line++] = _("‚ ‚È‚½‚͓łւ̑ϐ«‚ðŽ‚Á‚Ä‚¢‚éB", "You are resistant to poison."); + } +} diff --git a/src/player-info/resistance-info.h b/src/player-info/resistance-info.h new file mode 100644 index 000000000..8b6fa74cb --- /dev/null +++ b/src/player-info/resistance-info.h @@ -0,0 +1,6 @@ +#pragma once + +#include "system/angband.h" + +typedef struct self_info_type self_info_type; +void set_element_resistance_info(player_type *creature_ptr, self_info_type *si_ptr); diff --git a/src/player-info/self-info.c b/src/player-info/self-info.c index ae0efc0c4..f2af6b962 100644 --- a/src/player-info/self-info.c +++ b/src/player-info/self-info.c @@ -22,6 +22,7 @@ #include "player-info/class-ability-info.h" #include "player-info/mutation-info.h" #include "player-info/race-ability-info.h" +#include "player-info/resistance-info.h" #include "player-info/self-info-util.h" #include "player/attack-defense-types.h" #include "player/player-class.h" @@ -364,52 +365,7 @@ void self_knowledge(player_type *creature_ptr) set_body_improvement_info_2(creature_ptr, si_ptr); set_esp_info(creature_ptr, si_ptr); set_body_improvement_info_3(creature_ptr, si_ptr); - if (creature_ptr->immune_acid) { - si_ptr->info[si_ptr->line++] = _("あなたは酸に対する完全なる免疫を持っている。", "You are completely immune to acid."); - } else if (creature_ptr->resist_acid && is_oppose_acid(creature_ptr)) { - si_ptr->info[si_ptr->line++] = _("あなたは酸への強力な耐性を持っている。", "You resist acid exceptionally well."); - } else if (creature_ptr->resist_acid || is_oppose_acid(creature_ptr)) { - si_ptr->info[si_ptr->line++] = _("あなたは酸への耐性を持っている。", "You are resistant to acid."); - } - - if (creature_ptr->immune_elec) { - si_ptr->info[si_ptr->line++] = _("あなたは電撃に対する完全なる免疫を持っている。", "You are completely immune to lightning."); - } else if (creature_ptr->resist_elec && is_oppose_elec(creature_ptr)) { - si_ptr->info[si_ptr->line++] = _("あなたは電撃への強力な耐性を持っている。", "You resist lightning exceptionally well."); - } else if (creature_ptr->resist_elec || is_oppose_elec(creature_ptr)) { - si_ptr->info[si_ptr->line++] = _("あなたは電撃への耐性を持っている。", "You are resistant to lightning."); - } - - if (is_specific_player_race(creature_ptr, RACE_ANDROID) && !creature_ptr->immune_elec) { - si_ptr->info[si_ptr->line++] = _("あなたは電撃に弱い。", "You are susceptible to damage from lightning."); - } - - if (creature_ptr->immune_fire) { - si_ptr->info[si_ptr->line++] = _("あなたは火に対する完全なる免疫を持っている。", "You are completely immune to fire."); - } else if (creature_ptr->resist_fire && is_oppose_fire(creature_ptr)) { - si_ptr->info[si_ptr->line++] = _("あなたは火への強力な耐性を持っている。", "You resist fire exceptionally well."); - } else if (creature_ptr->resist_fire || is_oppose_fire(creature_ptr)) { - si_ptr->info[si_ptr->line++] = _("あなたは火への耐性を持っている。", "You are resistant to fire."); - } - - if (is_specific_player_race(creature_ptr, RACE_ENT) && !creature_ptr->immune_fire) { - si_ptr->info[si_ptr->line++] = _("あなたは火に弱い。", "You are susceptible to damage from fire."); - } - - if (creature_ptr->immune_cold) { - si_ptr->info[si_ptr->line++] = _("あなたは冷気に対する完全なる免疫を持っている。", "You are completely immune to cold."); - } else if (creature_ptr->resist_cold && is_oppose_cold(creature_ptr)) { - si_ptr->info[si_ptr->line++] = _("あなたは冷気への強力な耐性を持っている。", "You resist cold exceptionally well."); - } else if (creature_ptr->resist_cold || is_oppose_cold(creature_ptr)) { - si_ptr->info[si_ptr->line++] = _("あなたは冷気への耐性を持っている。", "You are resistant to cold."); - } - - if (creature_ptr->resist_pois && is_oppose_pois(creature_ptr)) { - si_ptr->info[si_ptr->line++] = _("あなたは毒への強力な耐性を持っている。", "You resist poison exceptionally well."); - } else if (creature_ptr->resist_pois || is_oppose_pois(creature_ptr)) { - si_ptr->info[si_ptr->line++] = _("あなたは毒への耐性を持っている。", "You are resistant to poison."); - } - + set_element_resistance_info(creature_ptr, si_ptr); if (creature_ptr->resist_lite) { si_ptr->info[si_ptr->line++] = _("あなたは閃光への耐性を持っている。", "You are resistant to bright light."); } -- 2.11.0