summaryrefslogtreecommitdiff
path: root/src/game/unit_scientist.cpp
diff options
context:
space:
mode:
authorPaweł Redman <pawel.redman@gmail.com>2018-04-26 17:26:18 +0200
committerPaweł Redman <pawel.redman@gmail.com>2018-04-26 17:26:18 +0200
commitbcfefeaf919281911a53c94b91bc7ec016bd6775 (patch)
treef7421a336011c89f1123fffbce0a6a70ed3076ba /src/game/unit_scientist.cpp
parentfe96448665543ba762f237328570ff55cd89a24f (diff)
Improve says a bit.
Diffstat (limited to 'src/game/unit_scientist.cpp')
-rw-r--r--src/game/unit_scientist.cpp24
1 files changed, 20 insertions, 4 deletions
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);