The Battle for Wesnoth  1.19.5+dev
unit_attack.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010 - 2024
3  by Mark de Wever <koraq@xs4all.nl>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 #pragma once
17 
18 #include "actions/attack.hpp"
20 #include "units/map.hpp"
21 
22 namespace gui2::dialogs
23 {
24 
25 class unit_attack : public modal_dialog
26 {
27 public:
28  unit_attack(const unit_map::iterator& attacker_itor,
29  const unit_map::iterator& defender_itor,
30  std::vector<battle_context>&& weapons,
31  const int best_weapon);
32 
33  /***** ***** ***** setters / getters for members ***** ****** *****/
34 
35  int get_selected_weapon() const
36  {
37  return selected_weapon_;
38  }
39 
40 private:
41  virtual const std::string& window_id() const override;
42 
43  virtual void pre_show() override;
44 
45  virtual void post_show() override;
46 
47  void damage_calc_callback();
48 
49  /** The index of the selected weapon. */
51 
52  /** Iterator pointing to the attacker. */
54 
55  /** Iterator pointing to the defender. */
57 
58  /** List of all battle contexts used for getting the weapons. */
59  std::vector<battle_context> weapons_;
60 
61  /** The best weapon, aka the one high-lighted. */
63 };
64 
65 } // namespace dialogs
Various functions that implement attacks and attack calculations.
Abstract base class for all modal dialogs.
virtual void post_show() override
Actions to be taken after the window has been shown.
int selected_weapon_
The index of the selected weapon.
Definition: unit_attack.hpp:50
unit_map::iterator defender_itor_
Iterator pointing to the defender.
Definition: unit_attack.hpp:56
virtual const std::string & window_id() const override
The ID of the window to build.
int best_weapon_
The best weapon, aka the one high-lighted.
Definition: unit_attack.hpp:62
virtual void pre_show() override
Actions to be taken before showing the window.
Definition: unit_attack.cpp:57
unit_map::iterator attacker_itor_
Iterator pointing to the attacker.
Definition: unit_attack.hpp:53
unit_attack(const unit_map::iterator &attacker_itor, const unit_map::iterator &defender_itor, std::vector< battle_context > &&weapons, const int best_weapon)
Definition: unit_attack.cpp:38
std::vector< battle_context > weapons_
List of all battle contexts used for getting the weapons.
Definition: unit_attack.hpp:59