summaryrefslogtreecommitdiff
path: root/src/game/unit_repl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/unit_repl.cpp')
-rw-r--r--src/game/unit_repl.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/game/unit_repl.cpp b/src/game/unit_repl.cpp
index 6dfa005..ddea8b0 100644
--- a/src/game/unit_repl.cpp
+++ b/src/game/unit_repl.cpp
@@ -54,10 +54,26 @@ void unit_repl_t::render_to(render::state_t *render)
void unit_repl_t::activate(unit_t::type_t type)
{
+ size_t price;
world::cmodel_t cmodel;
unit_t *unit;
switch (type) {
+ case UNIT_SOLDIER: price = 40; break;
+ case UNIT_SCIENTIST: price = 95; break;
+ case UNIT_BUILDER: price = 70; break;
+ default:
+ abort();
+ }
+
+ if (game->crystals < price) {
+ game->interface.print("Insufficient crystals; " + std::to_string(price - game->crystals) + " more needed.");
+ return;
+ }
+
+ game->crystals -= price;
+
+ switch (type) {
case UNIT_SOLDIER:
unit = new unit_soldier_t(game);
break;