The Battle for Wesnoth  1.15.13+dev
attack_predictions.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010 - 2018 by Mark de Wever <koraq@xs4all.nl>
3  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #pragma once
16 
17 #include "actions/attack.hpp"
19 #include "units/ptr.hpp"
20 
21 class battle_context;
22 
24 struct combatant;
25 
26 namespace gui2
27 {
28 class drawing;
29 
30 namespace dialogs
31 {
32 using hp_probability_vector = std::vector<std::pair<int, double>>;
33 
35 {
36 public:
38 
40 
41 private:
42  virtual const std::string& window_id() const override;
43 
44  virtual void pre_show(window& window) override;
45 
47  {
49  : stats_(stats)
50  , combatant_(combatant)
51  , unit_(unit)
52  {}
53 
56  /** never null */
58  };
59 
60  void set_data(window& window, const combatant_data& attacker, const combatant_data& defender) const;
61 
62  hp_probability_vector get_hitpoint_probabilities(const std::vector<double>& hp_dist) const;
63 
64  static const unsigned int graph_width;
65  static const unsigned int graph_height;
66  static const unsigned int graph_max_rows;
67 
68  void draw_hp_graph(drawing& hp_graph, const combatant_data& attacker, const combatant_data& defender) const;
69 
72 };
73 
74 } // namespace dialogs
75 } // 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:120
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:51
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:22
std::shared_ptr< const unit > unit_const_ptr
Definition: ptr.hpp:26
Computes the statistics of a battle between an attacker and a defender unit.
Definition: attack.hpp:172
Structure describing the statistics of a unit involved in the battle.
Definition: attack.hpp:50
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:64
virtual const std::string & window_id() const override
The id of the window to build.