forked from townforge/townforge
game: leaderboards improvements
more user friendly richest leaderboard scores do not show autonomous accounts in leaderboards
This commit is contained in:
parent
ad76e71cbd
commit
49f8d8f99c
@ -28,6 +28,27 @@
|
||||
|
||||
using namespace Urho3D;
|
||||
|
||||
static std::string print_succint_money(uint64_t money)
|
||||
{
|
||||
if (money < 1000000)
|
||||
return game_util::print_money(money);
|
||||
|
||||
char buf[80];
|
||||
if (money < 10 * COIN)
|
||||
snprintf(buf, sizeof(buf), "%.4f", money / (float)COIN);
|
||||
else if (money < 100 * COIN)
|
||||
snprintf(buf, sizeof(buf), "%.3f", money / (float)COIN);
|
||||
else if (money < 1000 * COIN)
|
||||
snprintf(buf, sizeof(buf), "%.2f", money / (float)COIN);
|
||||
else if (money < 10000 * COIN)
|
||||
snprintf(buf, sizeof(buf), "%.4fk", money / (float)(COIN * 1000));
|
||||
else if (money < 100000 * COIN)
|
||||
snprintf(buf, sizeof(buf), "%.3fk", money / (float)(COIN * 1000));
|
||||
else
|
||||
snprintf(buf, sizeof(buf), "%.2fk", money / (float)(COIN * 1000));
|
||||
return buf;
|
||||
}
|
||||
|
||||
CityState::CityState(uint32_t id):
|
||||
id(id),
|
||||
ox(0),
|
||||
@ -1872,6 +1893,8 @@ bool GameState::reset(const cryptonote::cc_snapshot *snapshot)
|
||||
for (const auto &e: snapshot->player_data)
|
||||
{
|
||||
set_player_name(e.id, e.name, e.ignore, e.autonomous);
|
||||
if (e.autonomous)
|
||||
continue;
|
||||
const auto score_level = cc::get_badge_score(e.badges);
|
||||
if (score_level.first > 0)
|
||||
badge_leaderboard.set_score(e.id, score_level.first, std::to_string(score_level.second));
|
||||
@ -1880,7 +1903,7 @@ bool GameState::reset(const cryptonote::cc_snapshot *snapshot)
|
||||
if (e.prestige > 0)
|
||||
prestige_leaderboard.set_score(e.id, e.prestige);
|
||||
if (e.balance > 0)
|
||||
richest_leaderboard.set_score(e.id, e.balance);
|
||||
richest_leaderboard.set_score(e.id, e.balance, print_succint_money(e.balance));
|
||||
}
|
||||
|
||||
for (const auto &s: snapshot->shares)
|
||||
|
Loading…
Reference in New Issue
Block a user