The Battle for Wesnoth  1.15.12+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 "units/types.hpp"
#include <cmath>
Include dependency graph for statistics.cpp:

Go to the source code of this file.




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


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)


static lg::log_domain log_engine ("engine")

Detailed Description

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

Definition in file statistics.cpp.

Macro Definition Documentation


#define DBG_NG   LOG_STREAM(debug, log_engine)

Definition at line 32 of file statistics.cpp.

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


#define ERR_NG   LOG_STREAM(err, log_engine)

Definition at line 33 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)

◆ merge_battle_result_maps()

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

Definition at line 257 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 

Definition at line 264 of file statistics.cpp.

References i.

Referenced by merge_stats().

◆ merge_stats()

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

◆ merge_str_int_map()

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

Definition at line 250 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)

◆ read_by_cth_map()

static stats::hitrate_map read_by_cth_map ( const config cfg)

Definition at line 241 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 

Definition at line 213 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)

Definition at line 148 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)

Definition at line 164 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 

◆ write_by_cth_map()

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

Definition at line 200 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)

Definition at line 110 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 

Definition at line 125 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")