OSDN Git Service

[Chore] UTF-8エンコーディングのファイルからBOMを削除
[hengbandforosx/hengbandosx.git] / src / market / building-craft-armor.cpp
1 #include "market/building-craft-armor.h"
2 #include "io/input-key-acceptor.h"
3 #include "market/building-util.h"
4 #include "term/screen-processor.h"
5 #include "view/display-util.h"
6
7 /*!
8  * @brief ACから回避率、ダメージ減少率を計算し表示する。 / Evaluate AC
9  * @details
10  * Calculate and display the dodge-rate and the protection-rate
11  * based on AC
12  * @param ac プレイヤーのAC。
13  * @return 常にTRUEを返す。
14  */
15 bool eval_ac(short ac)
16 {
17     constexpr auto memo = _("ダメージ軽減率とは、敵の攻撃が当たった時そのダメージを\n"
18                             "何パーセント軽減するかを示します。\n"
19                             "ダメージ軽減は通常の直接攻撃(種類が「攻撃する」と「粉砕する」の物)\n"
20                             "に対してのみ効果があります。\n \n"
21                             "敵のレベルとは、その敵が通常何階に現れるかを示します。\n \n"
22                             "回避率は敵の直接攻撃を何パーセントの確率で避けるかを示し、\n"
23                             "敵のレベルとあなたのACによって決定されます。\n \n"
24                             "ダメージ期待値とは、敵の100ポイントの通常攻撃に対し、\n"
25                             "回避率とダメージ軽減率を考慮したダメージの期待値を示します。\n",
26         "'Protection Rate' means how much damage is reduced by your armor.\n"
27         "Note that the Protection rate is effective only against normal "
28         "'attack' and 'shatter' type melee attacks, "
29         "and has no effect against any other types such as 'poison'.\n \n"
30         "'Dodge Rate' indicates the success rate on dodging the "
31         "monster's melee attacks.  "
32         "It is depend on the level of the monster and your AC.\n \n"
33         "'Average Damage' indicates the expected amount of damage "
34         "when you are attacked by normal melee attacks with power=100.");
35
36     if (ac < 0) {
37         ac = 0;
38     }
39
40     const auto protection = 100 * std::min<short>(ac, 150) / 250;
41     screen_save();
42     clear_bldg(0, 22);
43
44     auto row = 2;
45     put_str(format(_("あなたの現在のAC: %3d", "Your current AC : %3d"), ac), row++, 0);
46     put_str(format(_("ダメージ軽減率  : %3d%%", "Protection rate : %3d%%"), protection), row++, 0);
47     row++;
48
49     put_str(_("敵のレベル      :", "Level of Monster:"), row + 0, 0);
50     put_str(_("回避率          :", "Dodge Rate      :"), row + 1, 0);
51     put_str(_("ダメージ期待値  :", "Average Damage  :"), row + 2, 0);
52
53     for (auto col = 17 + 1, lvl = 0; lvl <= 100; lvl += 10, col += 5) {
54         auto quality = 60 + lvl * 3; /* attack quality with power 60 */
55         put_str(format("%3d", lvl), row + 0, col);
56
57         /* 回避率を計算 */
58         auto dodge = 5 + (std::min(100, 100 * (ac * 3 / 4) / quality) * 9 + 5) / 10;
59         put_str(format("%3d%%", dodge), row + 1, col);
60
61         /* 100点の攻撃に対してのダメージ期待値を計算 */
62         auto average = (100 - dodge) * (100 - protection) / 100;
63         put_str(format("%3d", average), row + 2, col);
64     }
65
66     display_wrap_around(memo, 70, row + 4, 4);
67
68     prt(_("現在のあなたの装備からすると、あなたの防御力はこれくらいです:", "Defense abilities from your current Armor Class are evaluated below."), 0, 0);
69
70     flush();
71     (void)inkey();
72     screen_load();
73
74     return true;
75 }