Hit stats: Track both inflicted and taken hits.
This commit is contained in:
parent
ed22925dd1
commit
7eb75539a6
3 changed files with 20 additions and 11 deletions
|
@ -247,7 +247,7 @@ void statistics_dialog::update_lists(window& window)
|
|||
show_this_turn
|
||||
);
|
||||
add_hits_row(window, _("Inflicted"),
|
||||
stats.by_cth,
|
||||
stats.by_cth_inflicted,
|
||||
show_this_turn
|
||||
);
|
||||
|
||||
|
@ -258,7 +258,10 @@ void statistics_dialog::update_lists(window& window)
|
|||
stats.turn_expected_damage_taken,
|
||||
show_this_turn
|
||||
);
|
||||
// TODO add by_cth_taken/by_cth_inflicted
|
||||
add_hits_row(window, _("Taken"),
|
||||
stats.by_cth_taken,
|
||||
show_this_turn
|
||||
);
|
||||
}
|
||||
|
||||
void statistics_dialog::on_scenario_select(window& window)
|
||||
|
|
|
@ -300,7 +300,7 @@ config stats::write() const
|
|||
res["expected_damage_inflicted"] = expected_damage_inflicted;
|
||||
res["expected_damage_taken"] = expected_damage_taken;
|
||||
|
||||
// TODO add by_cth here and throughout this file
|
||||
// TODO add by_cth_inflicted/by_cth_taken here and throughout this file
|
||||
res["turn_damage_inflicted"] = turn_damage_inflicted;
|
||||
res["turn_damage_taken"] = turn_damage_taken;
|
||||
res["turn_expected_damage_inflicted"] = turn_expected_damage_inflicted;
|
||||
|
@ -461,9 +461,12 @@ void attack_context::attack_result(hit_result res, int cth, int damage, int drai
|
|||
attacker_res.push_back(res == MISSES ? '0' : '1');
|
||||
stats &att_stats = attacker_stats(), &def_stats = defender_stats();
|
||||
|
||||
if(res != MISSES)
|
||||
++att_stats.by_cth[cth].hits;
|
||||
++att_stats.by_cth[cth].strikes;
|
||||
if(res != MISSES) {
|
||||
++att_stats.by_cth_inflicted[cth].hits;
|
||||
++def_stats.by_cth_taken[cth].hits;
|
||||
}
|
||||
++att_stats.by_cth_inflicted[cth].strikes;
|
||||
++def_stats.by_cth_taken[cth].strikes;
|
||||
|
||||
if(res != MISSES) {
|
||||
// handle drain
|
||||
|
@ -489,9 +492,12 @@ void attack_context::defend_result(hit_result res, int cth, int damage, int drai
|
|||
defender_res.push_back(res == MISSES ? '0' : '1');
|
||||
stats &att_stats = attacker_stats(), &def_stats = defender_stats();
|
||||
|
||||
if(res != MISSES)
|
||||
++def_stats.by_cth[cth].hits;
|
||||
++def_stats.by_cth[cth].strikes;
|
||||
if(res != MISSES) {
|
||||
++def_stats.by_cth_inflicted[cth].hits;
|
||||
++att_stats.by_cth_taken[cth].hits;
|
||||
}
|
||||
++def_stats.by_cth_inflicted[cth].strikes;
|
||||
++att_stats.by_cth_taken[cth].strikes;
|
||||
|
||||
if(res != MISSES) {
|
||||
//handle drain
|
||||
|
|
|
@ -57,8 +57,8 @@ namespace statistics
|
|||
int hits; //< Number of strikes that hit at the given CTH
|
||||
friend std::ostream& operator<<(std::ostream& outstream, const struct by_cth_t& by_cth);
|
||||
};
|
||||
/// A map of chance-to-hit percentage to a 'struct by_cth_t'.
|
||||
std::map<int, 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;
|
||||
|
||||
static const int decimal_shift = 1000;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue