OSDN Git Service

[Refactor] 敵魔法から属性を取得するための基底クラスを追加
[hengbandforosx/hengbandosx.git] / src / mspell / mspell-data.cpp
1 #include "mspell/mspell-data.h"
2 #include "effect/attribute-types.h"
3 #include "monster/monster-update.h"
4 #include "mspell/mspell-util.h"
5 #include "system/player-type-definition.h"
6
7 MSpellData::MSpellData()
8     : msg()
9     , type()
10     , drs()
11     , contain(false)
12 {
13 }
14
15 MSpellData::MSpellData(const MSpellMessageData &msg)
16     : msg(msg)
17     , type()
18     , drs()
19     , contain(true)
20 {
21 }
22
23 MSpellData::MSpellData(const MSpellMessageData &msg, const AttributeType &type)
24     : msg(msg)
25     , type(type)
26     , drs()
27     , contain(true)
28 {
29 }
30
31 MSpellData::MSpellData(const MSpellMessageData &msg, const AttributeType &type, const MSpellDrsData &drs)
32     : msg(msg)
33     , type(type)
34     , drs(drs)
35     , contain(true)
36 {
37 }
38
39 MSpellMessageData::MSpellMessageData()
40     : output([](PlayerType *, MONSTER_IDX, MONSTER_IDX, int) { return false; })
41 {
42 }
43
44 MSpellMessageData::MSpellMessageData(const mspell_cast_msg_blind &msg_string)
45     : output([msg_string](auto player_ptr, auto m_idx, auto t_idx, int target_type) {
46         return monspell_message(player_ptr, m_idx, t_idx, msg_string, target_type);
47     })
48 {
49 }
50
51 MSpellMessageData::MSpellMessageData(const std::string_view &blind, const std::string_view &to_player, const std::string_view &to_monster)
52     : output([blind, to_player, to_monster](auto player_ptr, auto m_idx, auto t_idx, int target_type) {
53         return monspell_message(player_ptr, m_idx, t_idx, { blind.data(), to_player.data(), to_monster.data() }, target_type);
54     })
55 {
56 }
57
58 MSpellDrsData::MSpellDrsData()
59     : execute([](PlayerType *, MONSTER_IDX) {})
60 {
61 }
62
63 MSpellDrsData::MSpellDrsData(std::initializer_list<drs_type> drs)
64     : execute([drs](auto player_ptr, auto m_idx) {
65         for (auto &d : drs) {
66             update_smart_learn(player_ptr, m_idx, d);
67         }
68     })
69 {
70 }
71
72 MSpellDrsData::MSpellDrsData(const drs_type &drs)
73     : execute([drs](auto player_ptr, auto m_idx) { update_smart_learn(player_ptr, m_idx, drs); })
74 {
75 }