Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef STATISTICS_HPP_INCLUDED
00019 #define STATISTICS_HPP_INCLUDED
00020
00021 class config;
00022 class config_writer;
00023 class unit;
00024
00025 #include <string>
00026 #include <map>
00027 #include <vector>
00028
00029 namespace statistics
00030 {
00031 struct stats
00032 {
00033 stats();
00034 explicit stats(const config& cfg);
00035
00036 config write() const;
00037 void write(config_writer &out) const;
00038 void read(const config& cfg);
00039
00040 typedef std::map<std::string,int> str_int_map;
00041 str_int_map recruits, recalls, advanced_to, deaths, killed;
00042 int recruit_cost, recall_cost;
00043
00044
00045
00046
00047
00048 typedef str_int_map battle_sequence_frequency_map;
00049
00050
00051 typedef std::map<int,battle_sequence_frequency_map> battle_result_map;
00052
00053 battle_result_map attacks, defends;
00054
00055 long long damage_inflicted, damage_taken;
00056 long long turn_damage_inflicted, turn_damage_taken;
00057
00058 static const int decimal_shift = 1000;
00059
00060
00061
00062
00063
00064 long long expected_damage_inflicted, expected_damage_taken;
00065 long long turn_expected_damage_inflicted, turn_expected_damage_taken;
00066 std::string save_id;
00067 };
00068
00069 int sum_str_int_map(const stats::str_int_map& m);
00070 int sum_cost_str_int_map(const stats::str_int_map &m);
00071
00072 struct scenario_context
00073 {
00074 scenario_context(const std::string& name);
00075 ~scenario_context();
00076 };
00077
00078 struct attack_context
00079 {
00080 attack_context(const unit& a, const unit& d, int a_cth, int d_cth);
00081 ~attack_context();
00082
00083 enum hit_result { MISSES, HITS, KILLS };
00084
00085 void attack_expected_damage(double attacker_inflict, double defender_inflict);
00086 void attack_result(hit_result res, int damage, int drain);
00087 void defend_result(hit_result res, int damage, int drain);
00088
00089 private:
00090
00091 std::string attacker_type, defender_type;
00092 std::string attacker_side, defender_side;
00093 int chance_to_hit_defender, chance_to_hit_attacker;
00094 std::string attacker_res, defender_res;
00095
00096 stats& attacker_stats();
00097 stats& defender_stats();
00098 };
00099
00100 void recruit_unit(const unit& u);
00101 void recall_unit(const unit& u);
00102 void un_recall_unit(const unit& u);
00103 void un_recruit_unit(const unit& u);
00104
00105 void advance_unit(const unit& u);
00106
00107 config write_stats();
00108 void write_stats(config_writer &out);
00109 void read_stats(const config& cfg);
00110 void fresh_stats();
00111 void clear_current_scenario();
00112
00113 void reset_turn_stats(std::string save_id);
00114 stats calculate_stats(int category, std::string save_id);
00115 }
00116
00117 #endif