1 #include "mspell/mspell-attack/abstract-mspell.h"
2 #include "monster/monster-update.h"
3 #include "mspell/mspell-damage-calculator.h"
4 #include "mspell/mspell-util.h"
5 #include "system/player-type-definition.h"
7 AbstractMSpellAttack::AbstractMSpellAttack(PlayerType *player_ptr, MONSTER_IDX m_idx, MonsterAbilityType ability, MSpellData data, int target_type, std::function<ProjectResult(POSITION, POSITION, int, AttributeType)> fire)
8 : player_ptr(player_ptr)
12 , data(std::move(data))
13 , target_type(target_type)
14 , fire(std::move(fire))
18 AbstractMSpellAttack::AbstractMSpellAttack(PlayerType *player_ptr, MONSTER_IDX m_idx, MONSTER_IDX t_idx, MonsterAbilityType ability, MSpellData data, int target_type, std::function<ProjectResult(POSITION, POSITION, int, AttributeType)> fire)
19 : player_ptr(player_ptr)
23 , data(std::move(data))
24 , target_type(target_type)
25 , fire(std::move(fire))
29 MonsterSpellResult AbstractMSpellAttack::shoot(POSITION y, POSITION x)
31 if (!this->data.contain) {
32 return MonsterSpellResult::make_invalid();
35 this->data.msg.output(this->player_ptr, this->m_idx, this->t_idx, this->target_type);
37 const auto dam = monspell_damage(this->player_ptr, this->ability, this->m_idx, DAM_ROLL);
38 const auto proj_res = fire(y, x, dam, data.type);
39 if (this->target_type == MONSTER_TO_PLAYER) {
40 this->data.drs.execute(this->player_ptr, this->m_idx);
43 auto res = MonsterSpellResult::make_valid(dam);
44 res.learnable = proj_res.affected_player;