The Battle for Wesnoth  1.19.5+dev
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
statistics_t Class Reference

#include <statistics.hpp>

Public Types

using stats = statistics_record::stats_t
 
typedef std::vector< std::pair< const std::string *, const stats * > > levels
 Stats (and name) for each scenario. More...
 

Public Member Functions

 statistics_t (statistics_record::campaign_stats_t &record)
 
void recruit_unit (const unit &u)
 
void recall_unit (const unit &u)
 
void un_recall_unit (const unit &u)
 
void un_recruit_unit (const unit &u)
 
void advance_unit (const unit &u)
 
void reset_turn_stats (const std::string &save_id)
 
stats calculate_stats (const std::string &save_id)
 
levels level_stats (const std::string &save_id)
 Returns a list of names and stats for each scenario in the current campaign. More...
 
statsget_stats (const std::string &save_id)
 returns the stats for the given side in the current scenario. More...
 

Static Public Member Functions

static int sum_str_int_map (const std::map< std::string, int > &m)
 
static int sum_cost_str_int_map (const std::map< std::string, int > &m)
 

Private Member Functions

auto & master_stats ()
 

Private Attributes

statistics_record::campaign_stats_trecord_
 

Detailed Description

Definition at line 25 of file statistics.hpp.

Member Typedef Documentation

◆ levels

typedef std::vector< std::pair<const std::string *, const stats *> > statistics_t::levels

Stats (and name) for each scenario.

The pointers are never nullptr.

Definition at line 42 of file statistics.hpp.

◆ stats

Definition at line 28 of file statistics.hpp.

Constructor & Destructor Documentation

◆ statistics_t()

statistics_t::statistics_t ( statistics_record::campaign_stats_t record)

Definition at line 46 of file statistics.cpp.

Member Function Documentation

◆ advance_unit()

void statistics_t::advance_unit ( const unit u)

Definition at line 201 of file statistics.cpp.

References get_stats(), s, and unit::type_id().

Referenced by advance_unit().

◆ calculate_stats()

statistics_t::stats statistics_t::calculate_stats ( const std::string &  save_id)

Definition at line 219 of file statistics.cpp.

References DBG_NG, i, master_stats(), and statistics_record::stats_t::merge_with().

◆ get_stats()

statistics_t::stats & statistics_t::get_stats ( const std::string &  save_id)

returns the stats for the given side in the current scenario.

Definition at line 271 of file statistics.cpp.

References master_stats().

Referenced by advance_unit(), statistics_attack_context::attacker_stats(), statistics_attack_context::defender_stats(), recall_unit(), recruit_unit(), reset_turn_stats(), un_recall_unit(), and un_recruit_unit().

◆ level_stats()

statistics_t::levels statistics_t::level_stats ( const std::string &  save_id)

Returns a list of names and stats for each scenario in the current campaign.

The front of the list is the oldest scenario; the back of the list is the (most) current scenario. Only scenarios with stats for the given side_id are included, but if no scenarios are applicable, then a vector containing a single dummy entry will be returned. (I.e., this never returns an empty vector.) This list is intended for the statistics dialog and may become invalid if new stats are recorded.

Definition at line 246 of file statistics.cpp.

References game_config::images::level, and master_stats().

◆ master_stats()

auto& statistics_t::master_stats ( )
inlineprivate

◆ recall_unit()

void statistics_t::recall_unit ( const unit u)

Definition at line 180 of file statistics.cpp.

References unit::cost(), get_stats(), s, and unit::type_id().

Referenced by actions::recall_unit().

◆ recruit_unit()

void statistics_t::recruit_unit ( const unit u)

Definition at line 173 of file statistics.cpp.

References unit::cost(), get_stats(), unit_type::parent_id(), s, and unit::type().

Referenced by actions::recruit_unit().

◆ reset_turn_stats()

void statistics_t::reset_turn_stats ( const std::string &  save_id)

Definition at line 207 of file statistics.cpp.

References get_stats(), and s.

Referenced by play_controller::do_init_side().

◆ sum_cost_str_int_map()

int statistics_t::sum_cost_str_int_map ( const std::map< std::string, int > &  m)
static

Definition at line 290 of file statistics.cpp.

References ERR_NG, unit_type_data::find(), t, and unit_types.

Referenced by gui2::dialogs::statistics_dialog::add_stat_row().

◆ sum_str_int_map()

int statistics_t::sum_str_int_map ( const std::map< std::string, int > &  m)
static

Definition at line 280 of file statistics.cpp.

Referenced by gui2::dialogs::statistics_dialog::add_stat_row().

◆ un_recall_unit()

void statistics_t::un_recall_unit ( const unit u)

Definition at line 187 of file statistics.cpp.

References unit::cost(), get_stats(), s, and unit::type_id().

Referenced by actions::undo::recall_action::undo().

◆ un_recruit_unit()

void statistics_t::un_recruit_unit ( const unit u)

Member Data Documentation

◆ record_

statistics_record::campaign_stats_t& statistics_t::record_
private

Definition at line 51 of file statistics.hpp.

Referenced by master_stats().


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