The Battle for Wesnoth
1.21.0-dev
Loading...
Searching...
No Matches
gui
dialogs
attack_predictions.hpp
Go to the documentation of this file.
1
/*
2
Copyright (C) 2010 - 2025
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
"
19
#include "
gui/dialogs/modal_dialog.hpp
"
20
#include "
units/ptr.hpp
"
21
22
#include <string>
23
24
class
battle_context
;
25
26
struct
battle_context_unit_stats
;
27
struct
combatant
;
28
29
namespace
gui2
30
{
31
class
drawing;
32
33
namespace
dialogs
34
{
35
using
hp_probability_vector
= std::vector<std::pair<int, double>>;
36
37
class
attack_predictions
:
public
modal_dialog
38
{
39
public
:
40
attack_predictions
(
battle_context
& bc,
unit_const_ptr
attacker,
unit_const_ptr
defender);
41
42
DEFINE_SIMPLE_DISPLAY_WRAPPER
(
attack_predictions
)
43
44
static
std::string
rng_mode_name
();
45
46
static
std::string
rng_mode_tooltip
();
47
48
private
:
49
virtual
const
std::string&
window_id
()
const override
;
50
51
virtual
void
pre_show
()
override
;
52
53
struct
combatant_data
54
{
55
combatant_data
(
unit_const_ptr
unit
,
const
combatant
&
combatant
,
const
battle_context_unit_stats
& stats)
56
:
stats_
(stats)
57
,
combatant_
(
combatant
)
58
,
unit_
(
unit
)
59
{}
60
61
const
battle_context_unit_stats
&
stats_
;
62
const
combatant
&
combatant_
;
63
/** never null */
64
unit_const_ptr
unit_
;
65
};
66
67
void
set_data
(
const
combatant_data
& attacker,
const
combatant_data
& defender);
68
69
hp_probability_vector
get_hitpoint_probabilities
(
const
std::vector<double>& hp_dist)
const
;
70
71
static
const
unsigned
int
graph_width
;
72
static
const
unsigned
int
graph_height
;
73
static
const
unsigned
int
graph_max_rows
;
74
75
void
draw_hp_graph
(
drawing
& hp_graph,
const
combatant_data
& attacker,
const
combatant_data
& defender);
76
77
combatant_data
attacker_data_
;
78
combatant_data
defender_data_
;
79
};
80
81
}
// namespace dialogs
82
}
// namespace gui2
attack.hpp
Various functions that implement attacks and attack calculations.
battle_context
Computes the statistics of a battle between an attacker and a defender unit.
Definition
attack.hpp:183
gui2::dialogs::attack_predictions
Definition
attack_predictions.hpp:38
gui2::dialogs::attack_predictions::graph_width
static const unsigned int graph_width
Definition
attack_predictions.hpp:71
gui2::dialogs::attack_predictions::rng_mode_name
static std::string rng_mode_name()
Definition
attack_predictions.cpp:67
gui2::dialogs::attack_predictions::draw_hp_graph
void draw_hp_graph(drawing &hp_graph, const combatant_data &attacker, const combatant_data &defender)
Definition
attack_predictions.cpp:309
gui2::dialogs::attack_predictions::rng_mode_tooltip
static std::string rng_mode_tooltip()
Definition
attack_predictions.cpp:82
gui2::dialogs::attack_predictions::graph_height
static const unsigned int graph_height
Definition
attack_predictions.hpp:72
gui2::dialogs::attack_predictions::set_data
void set_data(const combatant_data &attacker, const combatant_data &defender)
Definition
attack_predictions.cpp:112
gui2::dialogs::attack_predictions::window_id
virtual const std::string & window_id() const override
The ID of the window to build.
gui2::dialogs::attack_predictions::graph_max_rows
static const unsigned int graph_max_rows
Definition
attack_predictions.hpp:73
gui2::dialogs::attack_predictions::pre_show
virtual void pre_show() override
Actions to be taken before showing the window.
Definition
attack_predictions.cpp:57
gui2::dialogs::attack_predictions::attacker_data_
combatant_data attacker_data_
Definition
attack_predictions.hpp:77
gui2::dialogs::attack_predictions::get_hitpoint_probabilities
hp_probability_vector get_hitpoint_probabilities(const std::vector< double > &hp_dist) const
Definition
attack_predictions.cpp:409
gui2::dialogs::attack_predictions::defender_data_
combatant_data defender_data_
Definition
attack_predictions.hpp:78
gui2::dialogs::modal_dialog
Abstract base class for all modal dialogs.
Definition
modal_dialog.hpp:146
gui2::drawing
Definition
drawing.hpp:30
unit
This class represents a single unit of a specific type.
Definition
unit.hpp:39
modal_dialog.hpp
DEFINE_SIMPLE_DISPLAY_WRAPPER
#define DEFINE_SIMPLE_DISPLAY_WRAPPER(dialog)
Adds a bare-bones static display function to a dialog class that immediately invokes the dialogs's mo...
Definition
modal_dialog.hpp:98
dialogs
Various uncategorised dialogs.
gui2::dialogs::hp_probability_vector
std::vector< std::pair< int, double > > hp_probability_vector
Definition
attack_predictions.hpp:35
gui2
Generic file dialog.
Definition
draw_manager.hpp:21
ptr.hpp
unit_const_ptr
std::shared_ptr< const unit > unit_const_ptr
Definition
ptr.hpp:27
battle_context_unit_stats
Structure describing the statistics of a unit involved in the battle.
Definition
attack.hpp:72
combatant
All combat-related info.
Definition
attack_prediction.hpp:26
gui2::dialogs::attack_predictions::combatant_data
Definition
attack_predictions.hpp:54
gui2::dialogs::attack_predictions::combatant_data::combatant_data
combatant_data(unit_const_ptr unit, const combatant &combatant, const battle_context_unit_stats &stats)
Definition
attack_predictions.hpp:55
gui2::dialogs::attack_predictions::combatant_data::stats_
const battle_context_unit_stats & stats_
Definition
attack_predictions.hpp:61
gui2::dialogs::attack_predictions::combatant_data::unit_
unit_const_ptr unit_
never null
Definition
attack_predictions.hpp:64
gui2::dialogs::attack_predictions::combatant_data::combatant_
const combatant & combatant_
Definition
attack_predictions.hpp:62
Generated by
1.9.8