The Battle for Wesnoth  1.17.0-dev
attack_predictions.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010 - 2021
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/ptr.hpp"
21 
22 class battle_context;
23 
25 struct combatant;
26 
27 namespace gui2
28 {
29 class drawing;
30 
31 namespace dialogs
32 {
33 using hp_probability_vector = std::vector<std::pair<int, double>>;
34 
36 {
37 public:
39 
41 
42 private:
43  virtual const std::string& window_id() const override;
44 
45  virtual void pre_show(window& window) override;
46 
48  {
50  : stats_(stats)
51  , combatant_(combatant)
52  , unit_(unit)
53  {}
54 
57  /** never null */
59  };
60 
61  void set_data(window& window, const combatant_data& attacker, const combatant_data& defender) const;
62 
63  hp_probability_vector get_hitpoint_probabilities(const std::vector<double>& hp_dist) const;
64 
65  static const unsigned int graph_width;
66  static const unsigned int graph_height;
67  static const unsigned int graph_max_rows;
68 
69  void draw_hp_graph(drawing& hp_graph, const combatant_data& attacker, const combatant_data& defender) const;
70 
73 };
74 
75 } // namespace dialogs
76 } // namespace gui2
hp_probability_vector get_hitpoint_probabilities(const std::vector< double > &hp_dist) const
This class represents a single unit of a specific type.
Definition: unit.hpp:121
std::vector< std::pair< int, double > > hp_probability_vector
Various functions that implement attacks and attack calculations.
A drawing is widget with a fixed size and gives access to the canvas of the widget in the window inst...
Definition: drawing.hpp:52
void set_data(window &window, const combatant_data &attacker, const combatant_data &defender) const
static const unsigned int graph_max_rows
void draw_hp_graph(drawing &hp_graph, const combatant_data &attacker, const combatant_data &defender) const
Generic file dialog.
Definition: field-fwd.hpp:23
std::shared_ptr< const unit > unit_const_ptr
Definition: ptr.hpp:27
Computes the statistics of a battle between an attacker and a defender unit.
Definition: attack.hpp:173
Structure describing the statistics of a unit involved in the battle.
Definition: attack.hpp:51
Various uncategorised dialogs.
virtual void pre_show(window &window) override
Actions to be taken before showing the window.
All combat-related info.
attack_predictions(battle_context &bc, unit_const_ptr attacker, unit_const_ptr defender)
Abstract base class for all modal dialogs.
combatant_data(unit_const_ptr unit, const combatant &combatant, const battle_context_unit_stats &stats)
static const unsigned int graph_width
static const unsigned int graph_height
base class of top level items, the only item which needs to store the final canvases to draw on...
Definition: window.hpp:65
virtual const std::string & window_id() const override
The id of the window to build.