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 typedef str_int_map battle_sequence_frequency_map;
00047
00048
00049 typedef std::map<int,battle_sequence_frequency_map> battle_result_map;
00050
00051 battle_result_map attacks, defends;
00052
00053 long long damage_inflicted, damage_taken;
00054 long long turn_damage_inflicted, turn_damage_taken;
00055
00056 static const long long desimal_shift = 1000;
00057
00058
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 long long new_expected_damage_inflicted, new_expected_damage_taken;
00067 long long new_turn_expected_damage_inflicted, new_turn_expected_damage_taken;
00068 };
00069
00070 int sum_str_int_map(const stats::str_int_map& m);
00071
00072 struct disabler
00073 {
00074 disabler();
00075 ~disabler();
00076 };
00077
00078
00079 struct scenario_context
00080 {
00081 scenario_context(const std::string& name);
00082 ~scenario_context();
00083 };
00084
00085 struct attack_context
00086 {
00087 attack_context(const unit& a, const unit& d, int a_cth, int d_cth);
00088 ~attack_context();
00089
00090 enum ATTACK_RESULT { MISSES, HITS, KILLS };
00091
00092 void attack_excepted_damage(double attacker_inflict, double defender_inflict);
00093 void attack_result(ATTACK_RESULT res, long long damage, long long drain);
00094 void defend_result(ATTACK_RESULT res, long long damage, long long drain);
00095
00096 private:
00097
00098 std::string attacker_type, defender_type;
00099 int attacker_side, defender_side;
00100 int chance_to_hit_defender, chance_to_hit_attacker;
00101 std::string attacker_res, defender_res;
00102
00103 stats& attacker_stats();
00104 stats& defender_stats();
00105 };
00106
00107 void recruit_unit(const unit& u);
00108 void recall_unit(const unit& u);
00109 void un_recall_unit(const unit& u);
00110 void un_recruit_unit(const unit& u);
00111
00112 void advance_unit(const unit& u);
00113
00114 config write_stats();
00115 void write_stats(config_writer &out);
00116 void read_stats(const config& cfg);
00117 void fresh_stats();
00118 void clear_current_scenario();
00119
00120 void reset_turn_stats(int side);
00121 stats calculate_stats(int category, int side);
00122 }
00123
00124 #endif