The Battle for Wesnoth  1.15.1+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/map.hpp"
20 
21 class battle_context;
22 
24 struct combatant;
25 
26 namespace gui2
27 {
28 class drawing;
29 
30 namespace dialogs
31 {
32 
33 using hp_probability_t = std::pair<int, double>;
34 using hp_probability_vector = std::vector<hp_probability_t>;
35 
37 {
38 public:
39  attack_predictions(battle_context& bc, const unit& attacker, const unit& defender);
40 
42 
43 private:
44  /** Inherited from modal_dialog, implemented by REGISTER_DIALOG. */
45  virtual const std::string& window_id() const override;
46 
47  /** Inherited from modal_dialog. */
48  virtual void pre_show(window& window) override;
49 
51  {
53  : stats_(stats)
54  , combatant_(combatant)
55  , unit_(unit)
56  {}
57 
60  const unit& unit_;
61  };
62 
63  void set_data(window& window, const combatant_data& attacker, const combatant_data& defender);
64 
65  hp_probability_vector get_hitpoint_probabilities(const std::vector<double>& hp_dist);
66 
67  static const unsigned int graph_width;
68  static const unsigned int graph_height;
69  static const unsigned int graph_max_rows;
70 
71  void draw_hp_graph(drawing& hp_graph, const combatant_data& attacker, const combatant_data& defender);
72 
75 };
76 
77 } // namespace dialogs
78 } // namespace gui2
std::vector< hp_probability_t > hp_probability_vector
This class represents a single unit of a specific type.
Definition: unit.hpp:99
Various functions that implement attacks and attack calculations.
A widget to draw upon.
Definition: drawing.hpp:38
static const unsigned int graph_max_rows
Generic file dialog.
Definition: field-fwd.hpp:22
std::pair< int, double > hp_probability_t
void set_data(window &window, const combatant_data &attacker, const combatant_data &defender)
Computes the statistics of a battle between an attacker and a defender unit.
Definition: attack.hpp:171
Structure describing the statistics of a unit involved in the battle.
Definition: attack.hpp:48
Various uncategorised dialogs.
virtual void pre_show(window &window) override
Inherited from modal_dialog.
All combat-related info.
void draw_hp_graph(drawing &hp_graph, const combatant_data &attacker, const combatant_data &defender)
combatant_data(const unit &unit, const combatant &combatant, const battle_context_unit_stats &stats)
Abstract base class for all modal dialogs.
static const unsigned int graph_width
hp_probability_vector get_hitpoint_probabilities(const std::vector< double > &hp_dist)
static const unsigned int graph_height
attack_predictions(battle_context &bc, const unit &attacker, const unit &defender)
base class of top level items, the only item which needs to store the final canvases to draw on ...
Definition: window.hpp:63
virtual const std::string & window_id() const override
Inherited from modal_dialog, implemented by REGISTER_DIALOG.