The Battle for Wesnoth
1.19.7+dev
gui
dialogs
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
"
19
#include "
gui/dialogs/modal_dialog.hpp
"
20
#include "
units/ptr.hpp
"
21
22
class
battle_context
;
23
24
struct
battle_context_unit_stats
;
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
35
class
attack_predictions
:
public
modal_dialog
36
{
37
public
:
38
attack_predictions
(
battle_context
& bc,
unit_const_ptr
attacker,
unit_const_ptr
defender);
39
40
DEFINE_SIMPLE_DISPLAY_WRAPPER
(
attack_predictions
)
41
42
private
:
43
virtual
const
std::string&
window_id
()
const override
;
44
45
virtual
void
pre_show
()
override
;
46
47
struct
combatant_data
48
{
49
combatant_data
(
unit_const_ptr
unit
,
const
combatant
&
combatant
,
const
battle_context_unit_stats
& stats)
50
:
stats_
(stats)
51
,
combatant_
(
combatant
)
52
,
unit_
(
unit
)
53
{}
54
55
const
battle_context_unit_stats
&
stats_
;
56
const
combatant
&
combatant_
;
57
/** never null */
58
unit_const_ptr
unit_
;
59
};
60
61
void
set_data
(
const
combatant_data
& attacker,
const
combatant_data
& defender);
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);
70
71
combatant_data
attacker_data_
;
72
combatant_data
defender_data_
;
73
};
74
75
}
// namespace dialogs
76
}
// 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:167
gui2::dialogs::attack_predictions
Definition:
attack_predictions.hpp:36
gui2::dialogs::attack_predictions::graph_width
static const unsigned int graph_width
Definition:
attack_predictions.hpp:65
gui2::dialogs::attack_predictions::attack_predictions
attack_predictions(battle_context &bc, unit_const_ptr attacker, unit_const_ptr defender)
Definition:
attack_predictions.cpp:48
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:281
gui2::dialogs::attack_predictions::graph_height
static const unsigned int graph_height
Definition:
attack_predictions.hpp:66
gui2::dialogs::attack_predictions::set_data
void set_data(const combatant_data &attacker, const combatant_data &defender)
Definition:
attack_predictions.cpp:74
gui2::dialogs::attack_predictions::graph_max_rows
static const unsigned int graph_max_rows
Definition:
attack_predictions.hpp:67
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::pre_show
virtual void pre_show() override
Actions to be taken before showing the window.
Definition:
attack_predictions.cpp:55
gui2::dialogs::attack_predictions::attacker_data_
combatant_data attacker_data_
Definition:
attack_predictions.hpp:71
gui2::dialogs::attack_predictions::get_hitpoint_probabilities
hp_probability_vector get_hitpoint_probabilities(const std::vector< double > &hp_dist) const
Definition:
attack_predictions.cpp:381
gui2::dialogs::attack_predictions::defender_data_
combatant_data defender_data_
Definition:
attack_predictions.hpp:72
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:133
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:33
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:51
combatant
All combat-related info.
Definition:
attack_prediction.hpp:26
gui2::dialogs::attack_predictions::combatant_data
Definition:
attack_predictions.hpp:48
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:49
gui2::dialogs::attack_predictions::combatant_data::stats_
const battle_context_unit_stats & stats_
Definition:
attack_predictions.hpp:55
gui2::dialogs::attack_predictions::combatant_data::unit_
unit_const_ptr unit_
never null
Definition:
attack_predictions.hpp:58
gui2::dialogs::attack_predictions::combatant_data::combatant_
const combatant & combatant_
Definition:
attack_predictions.hpp:56
Generated by
1.9.1