From bcfefeaf919281911a53c94b91bc7ec016bd6775 Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Thu, 26 Apr 2018 17:26:18 +0200 Subject: Improve says a bit. --- src/game/unit_scientist.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'src/game/unit_scientist.cpp') diff --git a/src/game/unit_scientist.cpp b/src/game/unit_scientist.cpp index 8319aaa..537539e 100644 --- a/src/game/unit_scientist.cpp +++ b/src/game/unit_scientist.cpp @@ -27,7 +27,7 @@ static std::string scientist_name(procgen::prng_t *prng) "Дмитрий", "Иосиф", "Иван", "Пётр", "Юрий" }; - ss << "проф. "; + ss << "Проф. "; ss << names[prng->next() % (sizeof(names) / sizeof(names[0]))]; return ss.str(); @@ -51,6 +51,23 @@ unit_scientist_t::unit_scientist_t(game::state_t *game) : unit_t(game, UNIT_SCIE health = max_health = 15; } +static std::string russian_plural(size_t count, const char *nom_sg, const char *gen_sg, + const char *gen_pl) +{ + const char *word; + + if (count >= 10 && count < 20) + word = gen_sg; + else if (count % 10 == 1) + word = nom_sg; + else if (count % 10 >= 2 && count % 10 < 5) + word = gen_sg; + else + word = gen_pl; + + return std::to_string(count) + " " + word; +} + void unit_scientist_t::gather_crystals(void) { rectf_t rect; @@ -77,10 +94,9 @@ void unit_scientist_t::gather_crystals(void) goto out; } - crystals = 75; + crystals = game->prng.next() % 60 + 25; game->crystals += crystals; - game->interface.print(name + " collected " + std::to_string(crystals) + " " + - (crystals == 1 ? "crystal" : "crystals")); + say("Я собрал " + russian_plural(crystals, "кристалл", "кристалла", "кристаллов") + "."); deco->type = DECO_CRYSTAL_BROKEN; assets::scientist.gather.play_3d(x); -- cgit