OSDN Git Service

[Refactor] #40414 Separated decide_breath_kind() from draconian_breath()
authorHourier <hourier@users.sourceforge.jp>
Thu, 4 Jun 2020 12:39:48 +0000 (21:39 +0900)
committerHourier <hourier@users.sourceforge.jp>
Thu, 4 Jun 2020 12:39:48 +0000 (21:39 +0900)
src/mind/racial-draconian.c

index 0c6ecba..7eb133e 100644 (file)
 #include "spell/spells-launcher.h"
 #include "spell/spells-type.h"
 
-bool draconian_breath(player_type *creature_ptr)
+static void decide_breath_kind(player_type *creature_ptr, int *breath_type, concptr *breath_type_description)
 {
-    int Type = (one_in_(3) ? GF_COLD : GF_FIRE);
-    concptr Type_desc = ((Type == GF_COLD) ? _("冷気", "cold") : _("炎", "fire"));
-    DIRECTION dir;
-    if (!get_aim_dir(creature_ptr, &dir))
-        return FALSE;
-
-    if (randint1(100) < creature_ptr->lev) {
-        switch (creature_ptr->pclass) {
-        case CLASS_WARRIOR:
-        case CLASS_BERSERKER:
-        case CLASS_RANGER:
-        case CLASS_TOURIST:
-        case CLASS_IMITATOR:
-        case CLASS_ARCHER:
-        case CLASS_SMITH:
-            if (one_in_(3)) {
-                Type = GF_MISSILE;
-                Type_desc = _("エレメント", "the elements");
-            } else {
-                Type = GF_SHARDS;
-                Type_desc = _("破片", "shards");
-            }
+    if (randint1(100) >= creature_ptr->lev)
+        return;
 
-            break;
-        case CLASS_MAGE:
-        case CLASS_WARRIOR_MAGE:
-        case CLASS_HIGH_MAGE:
-        case CLASS_SORCERER:
-        case CLASS_MAGIC_EATER:
-        case CLASS_RED_MAGE:
-        case CLASS_BLUE_MAGE:
-        case CLASS_MIRROR_MASTER:
-            if (one_in_(3)) {
-                Type = GF_MANA;
-                Type_desc = _("魔力", "mana");
-            } else {
-                Type = GF_DISENCHANT;
-                Type_desc = _("劣化", "disenchantment");
-            }
+    switch (creature_ptr->pclass) {
+    case CLASS_WARRIOR:
+    case CLASS_BERSERKER:
+    case CLASS_RANGER:
+    case CLASS_TOURIST:
+    case CLASS_IMITATOR:
+    case CLASS_ARCHER:
+    case CLASS_SMITH:
+        if (one_in_(3)) {
+            *breath_type = GF_MISSILE;
+            *breath_type_description = _("エレメント", "the elements");
+        } else {
+            *breath_type = GF_SHARDS;
+            *breath_type_description = _("破片", "shards");
+        }
 
-            break;
-        case CLASS_CHAOS_WARRIOR:
-            if (!one_in_(3)) {
-                Type = GF_CONFUSION;
-                Type_desc = _("混乱", "confusion");
-            } else {
-                Type = GF_CHAOS;
-                Type_desc = _("カオス", "chaos");
-            }
+        break;
+    case CLASS_MAGE:
+    case CLASS_WARRIOR_MAGE:
+    case CLASS_HIGH_MAGE:
+    case CLASS_SORCERER:
+    case CLASS_MAGIC_EATER:
+    case CLASS_RED_MAGE:
+    case CLASS_BLUE_MAGE:
+    case CLASS_MIRROR_MASTER:
+        if (one_in_(3)) {
+            *breath_type = GF_MANA;
+            *breath_type_description = _("魔力", "mana");
+        } else {
+            *breath_type = GF_DISENCHANT;
+            *breath_type_description = _("劣化", "disenchantment");
+        }
 
-            break;
-        case CLASS_MONK:
-        case CLASS_SAMURAI:
-        case CLASS_FORCETRAINER:
-            if (!one_in_(3)) {
-                Type = GF_CONFUSION;
-                Type_desc = _("混乱", "confusion");
-            } else {
-                Type = GF_SOUND;
-                Type_desc = _("轟音", "sound");
-            }
+        break;
+    case CLASS_CHAOS_WARRIOR:
+        if (!one_in_(3)) {
+            *breath_type = GF_CONFUSION;
+            *breath_type_description = _("混乱", "confusion");
+        } else {
+            *breath_type = GF_CHAOS;
+            *breath_type_description = _("カオス", "chaos");
+        }
 
-            break;
-        case CLASS_MINDCRAFTER:
-            if (!one_in_(3)) {
-                Type = GF_CONFUSION;
-                Type_desc = _("混乱", "confusion");
-            } else {
-                Type = GF_PSI;
-                Type_desc = _("精神エネルギー", "mental energy");
-            }
+        break;
+    case CLASS_MONK:
+    case CLASS_SAMURAI:
+    case CLASS_FORCETRAINER:
+        if (!one_in_(3)) {
+            *breath_type = GF_CONFUSION;
+            *breath_type_description = _("混乱", "confusion");
+        } else {
+            *breath_type = GF_SOUND;
+            *breath_type_description = _("轟音", "sound");
+        }
 
-            break;
-        case CLASS_PRIEST:
-        case CLASS_PALADIN:
-            if (one_in_(3)) {
-                Type = GF_HELL_FIRE;
-                Type_desc = _("地獄の劫火", "hellfire");
-            } else {
-                Type = GF_HOLY_FIRE;
-                Type_desc = _("聖なる炎", "holy fire");
-            }
+        break;
+    case CLASS_MINDCRAFTER:
+        if (!one_in_(3)) {
+            *breath_type = GF_CONFUSION;
+            *breath_type_description = _("混乱", "confusion");
+        } else {
+            *breath_type = GF_PSI;
+            *breath_type_description = _("精神エネルギー", "mental energy");
+        }
 
-            break;
-        case CLASS_ROGUE:
-        case CLASS_NINJA:
-            if (one_in_(3)) {
-                Type = GF_DARK;
-                Type_desc = _("暗黒", "darkness");
-            } else {
-                Type = GF_POIS;
-                Type_desc = _("毒", "poison");
-            }
+        break;
+    case CLASS_PRIEST:
+    case CLASS_PALADIN:
+        if (one_in_(3)) {
+            *breath_type = GF_HELL_FIRE;
+            *breath_type_description = _("地獄の劫火", "hellfire");
+        } else {
+            *breath_type = GF_HOLY_FIRE;
+            *breath_type_description = _("聖なる炎", "holy fire");
+        }
 
-            break;
-        case CLASS_BARD:
-            if (!one_in_(3)) {
-                Type = GF_SOUND;
-                Type_desc = _("轟音", "sound");
-            } else {
-                Type = GF_CONFUSION;
-                Type_desc = _("混乱", "confusion");
-            }
+        break;
+    case CLASS_ROGUE:
+    case CLASS_NINJA:
+        if (one_in_(3)) {
+            *breath_type = GF_DARK;
+            *breath_type_description = _("暗黒", "darkness");
+        } else {
+            *breath_type = GF_POIS;
+            *breath_type_description = _("毒", "poison");
+        }
 
-            break;
+        break;
+    case CLASS_BARD:
+        if (!one_in_(3)) {
+            *breath_type = GF_SOUND;
+            *breath_type_description = _("轟音", "sound");
+        } else {
+            *breath_type = GF_CONFUSION;
+            *breath_type_description = _("混乱", "confusion");
         }
+
+        break;
     }
+}
+
+bool draconian_breath(player_type *creature_ptr)
+{
+    int breath_type = (one_in_(3) ? GF_COLD : GF_FIRE);
+    concptr breath_type_description = ((breath_type == GF_COLD) ? _("冷気", "cold") : _("炎", "fire"));
+    DIRECTION dir;
+    if (!get_aim_dir(creature_ptr, &dir))
+        return FALSE;
 
+    decide_breath_kind(creature_ptr, &breath_type, &breath_type_description);
     stop_mouth(creature_ptr);
-    msg_format(_("あなたは%sのブレスを吐いた。", "You breathe %s."), Type_desc);
+    msg_format(_("あなたは%sのブレスを吐いた。", "You breathe %s."), breath_type_description);
 
-    fire_breath(creature_ptr, Type, dir, creature_ptr->lev * 2, (creature_ptr->lev / 15) + 1);
+    fire_breath(creature_ptr, breath_type, dir, creature_ptr->lev * 2, (creature_ptr->lev / 15) + 1);
     return TRUE;
 }