Project

Profile

Help

HostedRedmine.com has moved to the Planio platform. All logins and passwords remained the same. All users will be able to login and use Redmine just as before. Read more...

Feature #874620 ยป 0011-factor-out-action_prob_to_text.patch

Sveinung Kvilhaugsvik, 2020-05-22 07:28 AM

View differences:

common/actions.c
return action_prepare_ui_name(act_id, mnemonic, ACTPROB_NA, NULL);
}
/**********************************************************************//**
Returns a text representation of the action probability prob unless it
is a signal. Returns NULL if prob is a signal.
**************************************************************************/
static const char *action_prob_to_text(const struct act_prob prob)
{
static struct astring chance = ASTRING_INIT;
/* How to interpret action probabilities like prob is documented in
* fc_types.h */
if (action_prob_is_signal(prob)) {
fc_assert(action_prob_not_impl(prob)
|| action_prob_not_relevant(prob));
/* Unknown because of missing server support or should not exits. */
return NULL;
}
if (prob.min == prob.max) {
/* Only one probability in range. */
/* TRANS: the probability that an action will succeed. Given in
* percentage. Resolution is 0.5%. */
astr_set(&chance, _("%.1f%%"), (double)prob.max / ACTPROB_VAL_1_PCT);
} else {
/* TRANS: the interval (end points included) where the probability of
* the action's success is. Given in percentage. Resolution is 0.5%. */
astr_set(&chance, _("[%.1f%%, %.1f%%]"),
(double)prob.min / ACTPROB_VAL_1_PCT,
(double)prob.max / ACTPROB_VAL_1_PCT);
}
return astr_str(&chance);
}
/**********************************************************************//**
Get the UI name ready to show the action in the UI. It is possible to
add a client specific mnemonic; it is assumed that if the mnemonic
......
return astr_str(&str);
}
/* How to interpret action probabilities like prob is documented in
* fc_types.h */
if (action_prob_is_signal(prob)) {
fc_assert(action_prob_not_impl(prob)
|| action_prob_not_relevant(prob));
/* Unknown because of missing server support or should not exits. */
probtxt = NULL;
} else {
if (prob.min == prob.max) {
/* Only one probability in range. */
/* TRANS: the probability that an action will succeed. Given in
* percentage. Resolution is 0.5%. */
astr_set(&chance, _("%.1f%%"), (double)prob.max / ACTPROB_VAL_1_PCT);
} else {
/* TRANS: the interval (end points included) where the probability of
* the action's success is. Given in percentage. Resolution is 0.5%. */
astr_set(&chance, _("[%.1f%%, %.1f%%]"),
(double)prob.min / ACTPROB_VAL_1_PCT,
(double)prob.max / ACTPROB_VAL_1_PCT);
}
probtxt = astr_str(&chance);
}
probtxt = action_prob_to_text(prob);
/* Format the info part of the action's UI name. */
if (probtxt != NULL && custom != NULL) {
    (1-1/1)