The Battle for Wesnoth  1.15.2+dev
Namespaces | Macros | Functions | Variables
statistics.cpp File Reference

Manage statistics: recruitments, recalls, kills, losses, etc. More...

#include "game_board.hpp"
#include "statistics.hpp"
#include "log.hpp"
#include "resources.hpp"
#include "serialization/binary_or_text.hpp"
#include "team.hpp"
#include "units/unit.hpp"
Include dependency graph for statistics.cpp:

Go to the source code of this file.

Namespaces

 statistics
 

Macros

#define DBG_NG   LOG_STREAM(debug, log_engine)
 
#define ERR_NG   LOG_STREAM(err, log_engine)
 

Functions

static stats & get_stats (const std::string &save_id)
 
static config write_str_int_map (const stats::str_int_map &m)
 
static void write_str_int_map (config_writer &out, const stats::str_int_map &m)
 
static stats::str_int_map read_str_int_map (const config &cfg)
 
static config write_battle_result_map (const stats::battle_result_map &m)
 
static void write_battle_result_map (config_writer &out, const stats::battle_result_map &m)
 
static stats::battle_result_map read_battle_result_map (const config &cfg)
 
static config write_by_cth_map (const stats::hitrate_map &m)
 
static void merge_battle_result_maps (stats::battle_result_map &a, const stats::battle_result_map &b)
 
static stats::hitrate_map read_by_cth_map_from_battle_result_maps (const statistics::stats::battle_result_map &attacks, const statistics::stats::battle_result_map &defends)
 
static stats::hitrate_map read_by_cth_map (const config &cfg)
 
static void merge_str_int_map (stats::str_int_map &a, const stats::str_int_map &b)
 
static void merge_cth_map (stats::hitrate_map &a, const stats::hitrate_map &b)
 
static void merge_stats (stats &a, const stats &b)
 
void statistics::recruit_unit (const unit &u)
 
void statistics::recall_unit (const unit &u)
 
void statistics::un_recall_unit (const unit &u)
 
void statistics::un_recruit_unit (const unit &u)
 
int statistics::un_recall_unit_cost (const unit &u)
 
void statistics::advance_unit (const unit &u)
 
void statistics::reset_turn_stats (const std::string &save_id)
 
stats statistics::calculate_stats (const std::string &save_id)
 
levels statistics::level_stats (const std::string &save_id)
 Returns a list of names and stats for each scenario in the current campaign. More...
 
config statistics::write_stats ()
 
void statistics::write_stats (config_writer &out)
 
void statistics::read_stats (const config &cfg)
 
void statistics::fresh_stats ()
 
void statistics::clear_current_scenario ()
 Delete the current scenario from the stats. More...
 
void statistics::reset_current_scenario ()
 Reset the stats of the current scenario to the beginning. More...
 
int statistics::sum_str_int_map (const stats::str_int_map &m)
 
int statistics::sum_cost_str_int_map (const stats::str_int_map &m)
 
std::ostream & operator<< (std::ostream &outstream, const statistics::stats::hitrate_t &by_cth)
 

Variables

static lg::log_domain log_engine ("engine")
 

Detailed Description

Manage statistics: recruitments, recalls, kills, losses, etc.

Definition in file statistics.cpp.

Macro Definition Documentation

◆ DBG_NG

#define DBG_NG   LOG_STREAM(debug, log_engine)

Definition at line 29 of file statistics.cpp.

Referenced by statistics::calculate_stats(), and merge_stats().

◆ ERR_NG

#define ERR_NG   LOG_STREAM(err, log_engine)

Definition at line 30 of file statistics.cpp.

Referenced by read_str_int_map(), and statistics::sum_cost_str_int_map().

Function Documentation

◆ get_stats()

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

◆ merge_battle_result_maps()

static void merge_battle_result_maps ( stats::battle_result_map &  a,
const stats::battle_result_map &  b 
)
static

Definition at line 254 of file statistics.cpp.

References i, and merge_str_int_map().

Referenced by merge_stats(), read_by_cth_map_from_battle_result_maps(), and write_by_cth_map().

◆ merge_cth_map()

static void merge_cth_map ( stats::hitrate_map &  a,
const stats::hitrate_map &  b 
)
static

Definition at line 261 of file statistics.cpp.

References i.

Referenced by merge_stats().

◆ merge_stats()

static void merge_stats ( stats &  a,
const stats &  b 
)
static

◆ merge_str_int_map()

static void merge_str_int_map ( stats::str_int_map &  a,
const stats::str_int_map &  b 
)
static

Definition at line 247 of file statistics.cpp.

References i.

Referenced by merge_battle_result_maps(), and merge_stats().

◆ operator<<()

std::ostream& operator<< ( std::ostream &  outstream,
const statistics::stats::hitrate_t by_cth 
)

◆ read_battle_result_map()

static stats::battle_result_map read_battle_result_map ( const config cfg)
static

◆ read_by_cth_map()

static stats::hitrate_map read_by_cth_map ( const config cfg)
static

Definition at line 238 of file statistics.cpp.

References config::child_range(), and i.

Referenced by statistics::stats::read().

◆ read_by_cth_map_from_battle_result_maps()

static stats::hitrate_map read_by_cth_map_from_battle_result_maps ( const statistics::stats::battle_result_map attacks,
const statistics::stats::battle_result_map defends 
)
static

Definition at line 210 of file statistics.cpp.

References i, and merge_battle_result_maps().

Referenced by statistics::stats::read().

◆ read_str_int_map()

static stats::str_int_map read_str_int_map ( const config cfg)
static

Definition at line 145 of file statistics.cpp.

References config::attribute_range(), ERR_NG, i, and utils::split().

Referenced by statistics::stats::read(), and read_battle_result_map().

◆ write_battle_result_map() [1/2]

static config write_battle_result_map ( const stats::battle_result_map &  m)
static

Definition at line 161 of file statistics.cpp.

References config::add_child(), i, and write_str_int_map().

Referenced by statistics::stats::write().

◆ write_battle_result_map() [2/2]

static void write_battle_result_map ( config_writer out,
const stats::battle_result_map &  m 
)
static

◆ write_by_cth_map()

static config write_by_cth_map ( const stats::hitrate_map &  m)
static

Definition at line 197 of file statistics.cpp.

References a, config::add_child(), b, i, and merge_battle_result_maps().

Referenced by statistics::stats::write().

◆ write_str_int_map() [1/2]

static config write_str_int_map ( const stats::str_int_map &  m)
static

Definition at line 107 of file statistics.cpp.

References config::has_attribute(), i, and n.

Referenced by statistics::stats::write(), and write_battle_result_map().

◆ write_str_int_map() [2/2]

static void write_str_int_map ( config_writer out,
const stats::str_int_map &  m 
)
static

Definition at line 122 of file statistics.cpp.

References i, utils::join(), p, and config_writer::write_key_val().

Variable Documentation

◆ log_engine

lg::log_domain log_engine("engine")
static