The Battle for Wesnoth 1.21.0-dev
 
Loading...
Searching...
No Matches
statistics.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2003 - 2025
3 by David White <dave@whitevine.net>
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 "statistics_record.hpp"
19
20class unit;
21#include <string>
22#include <map>
23#include <vector>
24
26{
27public:
29
31
32 void recruit_unit(const unit& u);
33 void recall_unit(const unit& u);
34 void un_recall_unit(const unit& u);
35 void un_recruit_unit(const unit& u);
36
37 void advance_unit(const unit& u);
38
39 void reset_turn_stats(const std::string & save_id);
40 stats calculate_stats(const std::string & save_id);
41 /** Stats (and name) for each scenario. The pointers are never nullptr. */
42 typedef std::vector< std::pair<const std::string *, const stats *>> levels;
43 /** Returns a list of names and stats for each scenario in the current campaign. */
44 levels level_stats(const std::string & save_id);
45 /// returns the stats for the given side in the current scenario.
46 stats& get_stats(const std::string &save_id);
47
48 static int sum_str_int_map(const std::map<std::string,int>& m);
49 static int sum_cost_str_int_map(const std::map<std::string,int>& m);
50private:
52
53 auto& master_stats() {
55 }
56};
57
59{
61
62 statistics_attack_context(statistics_t& stats, const unit& a, const unit& d, int a_cth, int d_cth);
65
66 void attack_expected_damage(double attacker_inflict, double defender_inflict);
67 void attack_result(hit_result res, int cth, int damage, int drain);
68 void defend_result(hit_result res, int cth, int damage, int drain);
69private:
70
71 /// never nullptr
73
78
81};
levels level_stats(const std::string &save_id)
Returns a list of names and stats for each scenario in the current campaign.
void recall_unit(const unit &u)
std::vector< std::pair< const std::string *, const stats * > > levels
Stats (and name) for each scenario.
stats & get_stats(const std::string &save_id)
returns the stats for the given side in the current scenario.
auto & master_stats()
void advance_unit(const unit &u)
static int sum_cost_str_int_map(const std::map< std::string, int > &m)
static int sum_str_int_map(const std::map< std::string, int > &m)
void un_recall_unit(const unit &u)
statistics_record::campaign_stats_t & record_
void reset_turn_stats(const std::string &save_id)
stats calculate_stats(const std::string &save_id)
statistics_record::stats_t stats
void un_recruit_unit(const unit &u)
void recruit_unit(const unit &u)
This class represents a single unit of a specific type.
Definition unit.hpp:39
void attack_result(hit_result res, int cth, int damage, int drain)
statistics_t * stats_
never nullptr
void attack_expected_damage(double attacker_inflict, double defender_inflict)
void defend_result(hit_result res, int cth, int damage, int drain)
std::vector< scenario_stats_t > master_record
#define d