OSDN Git Service

[Refactor] RIDING を新定義に合わせた
[hengbandforosx/hengbandosx.git] / src / monster-floor / monster-death-util.cpp
1 #include "monster-floor/monster-death-util.h"
2 #include "monster-race/monster-race.h"
3 #include "monster-race/race-flags1.h"
4 #include "monster-race/race-indice-types.h"
5 #include "monster/monster-info.h"
6 #include "monster/smart-learn-types.h"
7 #include "system/angband-system.h"
8 #include "system/floor-type-definition.h"
9 #include "system/monster-entity.h"
10 #include "system/monster-race-info.h"
11 #include "system/player-type-definition.h"
12 #include "util/bit-flags-calculator.h"
13
14 /*!
15  * @brief モンスターを倒した際の財宝svalを返す
16  * @param r_idx 倒したモンスターの種族ID
17  * @return 財宝のsval
18  * @details
19  * Hack -- Return the "automatic coin type" of a monster race
20  * Used to allocate proper treasure when "Creeping coins" die
21  * Note the use of actual "monster names"
22  */
23 static int get_coin_type(MonsterRaceId r_idx)
24 {
25     switch (r_idx) {
26     case MonsterRaceId::COPPER_COINS:
27         return 2;
28     case MonsterRaceId::SILVER_COINS:
29         return 5;
30     case MonsterRaceId::GOLD_COINS:
31         return 10;
32     case MonsterRaceId::MITHRIL_COINS:
33     case MonsterRaceId::MITHRIL_GOLEM:
34         return 16;
35     case MonsterRaceId::ADAMANT_COINS:
36         return 17;
37     default:
38         return 0;
39     }
40 }
41
42 MonsterDeath::MonsterDeath(FloorType &floor, MONSTER_IDX m_idx, bool drop_item)
43     : m_idx(m_idx)
44     , m_ptr(&floor.m_list[m_idx])
45 {
46     this->r_ptr = &this->m_ptr->get_monrace();
47     this->do_gold = this->r_ptr->drop_flags.has_none_of({
48         MonsterDropType::ONLY_ITEM,
49         MonsterDropType::DROP_GOOD,
50         MonsterDropType::DROP_GREAT,
51     });
52     this->do_item = this->r_ptr->drop_flags.has_not(MonsterDropType::ONLY_GOLD);
53     this->do_item |= this->r_ptr->drop_flags.has_any_of({ MonsterDropType::DROP_GOOD, MonsterDropType::DROP_GREAT });
54     this->cloned = this->m_ptr->mflag2.has(MonsterConstantFlagType::CLONED);
55     this->force_coin = get_coin_type(this->m_ptr->r_idx);
56     this->drop_chosen_item = drop_item && !this->cloned && !floor.inside_arena && !AngbandSystem::get_instance().is_phase_out() && !this->m_ptr->is_pet();
57 }