The Battle for Wesnoth  1.19.0-dev
attack_predictions.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/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)
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
Various functions that implement attacks and attack calculations.
Computes the statistics of a battle between an attacker and a defender unit.
Definition: attack.hpp:167
void draw_hp_graph(drawing &hp_graph, const combatant_data &attacker, const combatant_data &defender) const
static const unsigned int graph_width
attack_predictions(battle_context &bc, unit_const_ptr attacker, unit_const_ptr defender)
void set_data(window &window, const combatant_data &attacker, const combatant_data &defender) const
static const unsigned int graph_height
virtual void pre_show(window &window) override
Actions to be taken before showing the window.
static const unsigned int graph_max_rows
virtual const std::string & window_id() const override
The ID of the window to build.
hp_probability_vector get_hitpoint_probabilities(const std::vector< double > &hp_dist) const
Abstract base class for all modal dialogs.
A drawing is widget with a fixed size and gives access to the canvas of the widget in the window inst...
Definition: drawing.hpp:49
base class of top level items, the only item which needs to store the final canvases to draw on.
Definition: window.hpp:63
This class represents a single unit of a specific type.
Definition: unit.hpp:133
#define DEFINE_SIMPLE_DISPLAY_WRAPPER(dialog)
Adds a bare-bones static display function to a dialog class that immediately invokes the dialogs's mo...
Various uncategorised dialogs.
std::vector< std::pair< int, double > > hp_probability_vector
Generic file dialog.
std::shared_ptr< const unit > unit_const_ptr
Definition: ptr.hpp:27
Structure describing the statistics of a unit involved in the battle.
Definition: attack.hpp:51
All combat-related info.
combatant_data(unit_const_ptr unit, const combatant &combatant, const battle_context_unit_stats &stats)