statistics_dialog: Change the hits table format to "1703.2 + 42 | 93.6"
This is "Option B" from https://forums.wesnoth.org/viewtopic.php?f=12&t=49785&p=643513#p643495
This commit is contained in:
parent
1c19e8ce29
commit
7b78a8c019
2 changed files with 15 additions and 4 deletions
|
@ -547,7 +547,8 @@
|
|||
|
||||
{_GUI_DAMAGE_STATS_LIST
|
||||
(_ "Damage") damage_this_turn_header stats_list_damage damage_type damage_overall damage_this_turn
|
||||
(_"stats dialog^Amount of hitpoints (actual / expected)")
|
||||
(_"stats dialog^The first number is the expected number of hitpoints.
|
||||
The sum (or difference) of the two numbers is the actual number of hitpoints.")
|
||||
(_"stats dialog^Ratio of actual to expected")}
|
||||
[/column]
|
||||
|
||||
|
@ -564,7 +565,8 @@
|
|||
|
||||
{_GUI_DAMAGE_STATS_LIST
|
||||
(_ "Hits") hits_this_turn_header stats_list_hits hits_type hits_overall hits_this_turn
|
||||
(_"stats dialog^Number of hits (actual / expected)")
|
||||
(_"stats dialog^The first number is the expected number of hits.
|
||||
The sum (or difference) of the two numbers is the actual number of hits.")
|
||||
(_"stats dialog^Estimate of how much randomness of battles favored or disfavored this side.
|
||||
Values between 0 and 50 suggest the number of hits was less than expected.
|
||||
Values between 50 and 100 suggest the number of hits was more than expected.")}
|
||||
|
|
|
@ -129,6 +129,15 @@ void statistics_dialog::add_stat_row(window& window, const std::string& type, co
|
|||
main_stat_table_.push_back(&value);
|
||||
}
|
||||
|
||||
// Generate the string for the "A + B" column of the damage and hits tables.
|
||||
static std::ostream& write_actual_and_expected(std::ostream& str, const long long actual, const double expected)
|
||||
{
|
||||
// This is displayed as a sum or difference, not as "actual/expected", to prevent the string in the next column, str2.str(), from being mistaken for the result of the division.
|
||||
str << expected << (actual >= expected ? " + " : " − ")
|
||||
<< static_cast<unsigned int>(std::round(std::abs(expected - actual)));
|
||||
return str;
|
||||
}
|
||||
|
||||
void statistics_dialog::add_damage_row(
|
||||
window& window,
|
||||
const std::string& type,
|
||||
|
@ -154,7 +163,7 @@ void statistics_dialog::add_damage_row(
|
|||
const auto damage_str = [shift](long long damage, long long expected) {
|
||||
const long long shifted = ((expected * 20) + shift) / (2 * shift);
|
||||
std::ostringstream str;
|
||||
str << damage << " / " << static_cast<double>(shifted) * 0.1;
|
||||
write_actual_and_expected(str, damage, static_cast<double>(shifted) * 0.1);
|
||||
return str.str();
|
||||
};
|
||||
item["label"] = damage_str(damage, expected);
|
||||
|
@ -211,7 +220,7 @@ static hitrate_table_element tally(const statistics::stats::hitrate_map& by_cth,
|
|||
}
|
||||
|
||||
std::ostringstream str, str2;
|
||||
str << overall_hits << " / " << expected_hits;
|
||||
write_actual_and_expected(str, overall_hits, expected_hits);
|
||||
|
||||
// Compute the a priori probability of this actual result, by simulating many attacks against a single defender.
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue