From dc633fa52cbee152299d54867dd2b6c391c96401 Mon Sep 17 00:00:00 2001 From: Hourier <66951241+Hourier@users.noreply.github.com> Date: Tue, 6 Jun 2023 23:40:58 +0900 Subject: [PATCH] =?utf8?q?[Refactor]=20#3358=20=E4=B8=89=E9=A0=85=E6=BC=94?= =?utf8?q?=E7=AE=97=E5=AD=90=E3=81=AE=E5=B1=B1=E3=82=92switch=20=E3=81=AB?= =?utf8?q?=E5=B7=AE=E3=81=97=E6=9B=BF=E3=81=88=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/spell-realm/spells-craft.cpp | 76 +++++++++++++++++++++++++--------------- 1 file changed, 47 insertions(+), 29 deletions(-) diff --git a/src/spell-realm/spells-craft.cpp b/src/spell-realm/spells-craft.cpp index 34e7e9d23..cedfc9a45 100644 --- a/src/spell-realm/spells-craft.cpp +++ b/src/spell-realm/spells-craft.cpp @@ -63,25 +63,30 @@ bool set_ele_attack(PlayerType *player_ptr, uint32_t attack_type, TIME_EFFECT v) if ((v) && (attack_type)) { player_ptr->special_attack |= (attack_type); player_ptr->ele_attack = v; -#ifdef JP - msg_format("%sで攻撃できるようになった!", - ((attack_type == ATTACK_ACID) - ? "酸" - : ((attack_type == ATTACK_ELEC) - ? "電撃" - : ((attack_type == ATTACK_FIRE) ? "火炎" - : ((attack_type == ATTACK_COLD) ? "冷気" : ((attack_type == ATTACK_POIS) ? "毒" : "(なし)")))))); -#else - msg_format("For a while, the blows you deal will %s", - ((attack_type == ATTACK_ACID) - ? "melt with acid!" - : ((attack_type == ATTACK_ELEC) - ? "shock your foes!" - : ((attack_type == ATTACK_FIRE) - ? "burn with fire!" - : ((attack_type == ATTACK_COLD) ? "chill to the bone!" - : ((attack_type == ATTACK_POIS) ? "poison your enemies!" : "do nothing special.")))))); -#endif + std::string element; + switch (attack_type) { + case ATTACK_ACID: + element = _("酸", "melt with acid!"); + break; + case ATTACK_ELEC: + element = _("電撃", "shock your foes!"); + break; + case ATTACK_FIRE: + element = _("火炎", "burn with fire!"); + break; + case ATTACK_COLD: + element = _("冷気", "chill to the bone!"); + break; + case ATTACK_POIS: + element = _("毒", "poison your enemies!"); + break; + default: // @todo 本来はruntime_error を飛ばすべきだが、既存コードと同じように動くことを優先した. + element = _("(なし)", "do nothing special."); + break; + } + + constexpr auto mes = _("%sで攻撃できるようになった!", "For a while, the blows you deal will %s"); + msg_format(mes, element.data()); } if (disturb_state) { @@ -135,16 +140,29 @@ bool set_ele_immune(PlayerType *player_ptr, uint32_t immune_type, TIME_EFFECT v) if ((v) && (immune_type)) { player_ptr->special_defense |= (immune_type); player_ptr->ele_immune = v; - msg_format(_("%sの攻撃を受けつけなくなった!", "For a while, you are immune to %s"), - ((immune_type == DEFENSE_ACID) - ? _("酸", "acid!") - : ((immune_type == DEFENSE_ELEC) - ? _("電撃", "electricity!") - : ((immune_type == DEFENSE_FIRE) - ? _("火炎", "fire!") - : ((immune_type == DEFENSE_COLD) - ? _("冷気", "cold!") - : ((immune_type == DEFENSE_POIS) ? _("毒", "poison!") : _("(なし)", "nothing special."))))))); + std::string element; + switch (immune_type) { + case ATTACK_ACID: + element = _("酸", "acid!"); + break; + case ATTACK_ELEC: + element = _("電撃", "electricity!"); + break; + case ATTACK_FIRE: + element = _("火炎", "fire!"); + break; + case ATTACK_COLD: + element = _("冷気", "cold!"); + break; + case ATTACK_POIS: + element = _("毒", "poison!"); + break; + default: // @todo 本来はruntime_error を飛ばすべきだが、既存コードと同じように動くことを優先した. + element = _("(なし)", "nothing special."); + break; + } + + msg_format(_("%sの攻撃を受けつけなくなった!", "For a while, you are immune to %s"), element.data()); } if (disturb_state) { -- 2.11.0