The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
combatant Struct Reference

All combat-related info. More...

#include <attack_prediction.hpp>

Classes

struct  combat_slice
 A struct to describe one possible combat scenario. More...
 

Public Member Functions

 combatant (const battle_context_unit_stats &u, const combatant *prev=nullptr)
 Construct a combatant. More...
 
 combatant (const combatant &that, const battle_context_unit_stats &u)
 Copy constructor. More...
 
void fight (combatant &opponent, bool levelup_considered=true)
 Simulate a fight! Can be called multiple times for cumulative calculations. More...
 
double average_hp (unsigned int healing=0) const
 What's the average hp (weighted average of hp_dist). More...
 

Public Attributes

std::vector< double > hp_dist
 Resulting probability distribution (might be not as large as max_hp) More...
 
double untouched
 Resulting chance we were not hit by this opponent (important if it poisons) More...
 
double poisoned
 Resulting chance we are poisoned. More...
 
double slowed
 Resulting chance we are slowed. More...
 

Private Member Functions

 combatant (const combatant &that)
 
combatantoperator= (const combatant &)
 
std::vector< combat_slicesplit_summary () const
 Split the combat by number of attacks per combatant (for swarm). More...
 

Private Attributes

const battle_context_unit_statsu_
 
std::vector< double > summary [2]
 Summary of matrix used to calculate last battle (unslowed & slowed). More...
 

Detailed Description

All combat-related info.

Definition at line 30 of file attack_prediction.hpp.

Constructor & Destructor Documentation

combatant::combatant ( const battle_context_unit_stats u,
const combatant prev = nullptr 
)
combatant::combatant ( const combatant that,
const battle_context_unit_stats u 
)

Copy constructor.

Definition at line 1078 of file attack_prediction.cpp.

References summary.

combatant::combatant ( const combatant that)
private

Member Function Documentation

double combatant::average_hp ( unsigned int  healing = 0) const
void combatant::fight ( combatant opponent,
bool  levelup_considered = true 
)
combatant& combatant::operator= ( const combatant )
private
std::vector< combatant::combat_slice > combatant::split_summary ( ) const
private

Split the combat by number of attacks per combatant (for swarm).

This also clears the current summaries.

Definition at line 1112 of file attack_prediction.cpp.

References battle_context_unit_stats::calc_blows(), debug, battle_context_unit_stats::max_hp, battle_context_unit_stats::num_blows, summary, battle_context_unit_stats::swarm_max, battle_context_unit_stats::swarm_min, and u_.

Referenced by fight().

Member Data Documentation

std::vector<double> combatant::hp_dist

Resulting probability distribution (might be not as large as max_hp)

Definition at line 42 of file attack_prediction.hpp.

Referenced by ai::attack_analysis::analyze(), battle_context::better_combat(), combatant(), fight(), luaW_pushsimdata(), and unit_weapons().

double combatant::poisoned
double combatant::slowed

Resulting chance we are slowed.

Definition at line 51 of file attack_prediction.hpp.

Referenced by combatant(), and luaW_pushsimdata().

std::vector<double> combatant::summary[2]
private

Summary of matrix used to calculate last battle (unslowed & slowed).

Invariant: summary[1].size() == summary[0].size() or summary[1].empty()

Definition at line 74 of file attack_prediction.hpp.

Referenced by combatant(), fight(), and split_summary().

const battle_context_unit_stats& combatant::u_
private

Definition at line 70 of file attack_prediction.hpp.

Referenced by average_hp(), fight(), and split_summary().

double combatant::untouched

Resulting chance we were not hit by this opponent (important if it poisons)

Definition at line 45 of file attack_prediction.hpp.

Referenced by combatant().


The documentation for this struct was generated from the following files: