Hit stats: Introduce a hitrate_map typedef.
This commit is contained in:
parent
24b59cb2bf
commit
5f34300bf9
4 changed files with 15 additions and 14 deletions
|
@ -184,7 +184,7 @@ void statistics_dialog::add_damage_row(
|
|||
}
|
||||
|
||||
// Return the strings to use in the "Hits" table, showing actual and expected number of hits.
|
||||
static std::pair<std::string, std::string> tally(const std::map<int, struct statistics::stats::by_cth_t>& by_cth)
|
||||
static std::pair<std::string, std::string> tally(const statistics::stats::hitrate_map& by_cth)
|
||||
{
|
||||
unsigned int overall_hits = 0;
|
||||
double expected_hits = 0;
|
||||
|
@ -268,8 +268,8 @@ static std::pair<std::string, std::string> tally(const std::map<int, struct stat
|
|||
void statistics_dialog::add_hits_row(
|
||||
window& window,
|
||||
const std::string& type,
|
||||
const std::map<int, struct statistics::stats::by_cth_t>& by_cth,
|
||||
const std::map<int, struct statistics::stats::by_cth_t>& turn_by_cth,
|
||||
const statistics::stats::hitrate_map& by_cth,
|
||||
const statistics::stats::hitrate_map& turn_by_cth,
|
||||
const bool show_this_turn)
|
||||
{
|
||||
listbox& hits_list = find_widget<listbox>(&window, "stats_list_hits", false);
|
||||
|
|
|
@ -59,8 +59,8 @@ private:
|
|||
void add_hits_row(
|
||||
window& window,
|
||||
const std::string& type,
|
||||
const std::map<int, struct statistics::stats::by_cth_t>& by_cth,
|
||||
const std::map<int, struct statistics::stats::by_cth_t>& turn_by_cth,
|
||||
const statistics::stats::hitrate_map& by_cth,
|
||||
const statistics::stats::hitrate_map& turn_by_cth,
|
||||
const bool show_this_turn);
|
||||
|
||||
void update_lists(window& window);
|
||||
|
|
|
@ -194,7 +194,7 @@ static stats::battle_result_map read_battle_result_map(const config& cfg)
|
|||
return m;
|
||||
}
|
||||
|
||||
static config write_by_cth_map(const std::map<int, struct statistics::stats::by_cth_t>& m)
|
||||
static config write_by_cth_map(const stats::hitrate_map& m)
|
||||
{
|
||||
config res;
|
||||
for(const auto& i : m) {
|
||||
|
@ -208,9 +208,9 @@ static config write_by_cth_map(const std::map<int, struct statistics::stats::by_
|
|||
}
|
||||
|
||||
static void merge_battle_result_maps(stats::battle_result_map& a, const stats::battle_result_map& b);
|
||||
static std::map<int, struct statistics::stats::by_cth_t> 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_from_battle_result_maps(const statistics::stats::battle_result_map& attacks, const statistics::stats::battle_result_map& defends)
|
||||
{
|
||||
std::map<int, struct statistics::stats::by_cth_t> m;
|
||||
stats::hitrate_map m;
|
||||
|
||||
statistics::stats::battle_result_map merged = attacks;
|
||||
merge_battle_result_maps(merged, defends);
|
||||
|
@ -235,9 +235,9 @@ static std::map<int, struct statistics::stats::by_cth_t> read_by_cth_map_from_ba
|
|||
return m;
|
||||
}
|
||||
|
||||
static std::map<int, struct statistics::stats::by_cth_t> read_by_cth_map(const config& cfg)
|
||||
static stats::hitrate_map read_by_cth_map(const config& cfg)
|
||||
{
|
||||
std::map<int, struct statistics::stats::by_cth_t> m;
|
||||
stats::hitrate_map m;
|
||||
for(const config &i : cfg.child_range("keyvalue")) {
|
||||
m.emplace(i["key"], statistics::stats::by_cth_t(i.child("value")));
|
||||
}
|
||||
|
@ -258,7 +258,7 @@ static void merge_battle_result_maps(stats::battle_result_map& a, const stats::b
|
|||
}
|
||||
}
|
||||
|
||||
static void merge_cth_map(std::map<int, struct statistics::stats::by_cth_t>& a, const std::map<int, struct statistics::stats::by_cth_t>& b)
|
||||
static void merge_cth_map(stats::hitrate_map& a, const stats::hitrate_map& b)
|
||||
{
|
||||
for(const auto& i : b) {
|
||||
a[i.first].hits += i.second.hits;
|
||||
|
|
|
@ -67,9 +67,10 @@ namespace statistics
|
|||
config write() const;
|
||||
friend std::ostream& operator<<(std::ostream& outstream, const struct by_cth_t& by_cth);
|
||||
};
|
||||
/// Maps of chance-to-hit percentage to a 'struct by_cth_t'.
|
||||
std::map<int, struct by_cth_t> by_cth_inflicted, by_cth_taken;
|
||||
std::map<int, struct by_cth_t> turn_by_cth_inflicted, turn_by_cth_taken;
|
||||
/// A type that maps chance-to-hit percentage to number of hits and strikes at that CTH.
|
||||
typedef std::map<int, struct by_cth_t> hitrate_map;
|
||||
hitrate_map by_cth_inflicted, by_cth_taken;
|
||||
hitrate_map turn_by_cth_inflicted, turn_by_cth_taken;
|
||||
|
||||
static const int decimal_shift = 1000;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue