Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/base/shipdealer.cc')
-rw-r--r--src/game/base/shipdealer.cc23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/game/base/shipdealer.cc b/src/game/base/shipdealer.cc
index 83bc0dc..5aced0b 100644
--- a/src/game/base/shipdealer.cc
+++ b/src/game/base/shipdealer.cc
@@ -102,6 +102,7 @@ void ShipDealer::func_buy(core::Player *player, const std::string &args)
}
if (!Game::g_devel->value()) {
+
if (!shipdealer) {
player->send("No ship dealer available");
return;
@@ -111,6 +112,16 @@ void ShipDealer::func_buy(core::Player *player, const std::string &args)
player->send("Ship dealer does not sell the " + shipmodel->name());
return;
}
+
+ // check price
+ if (shipmodel->price() > player->credits()) {
+ std::stringstream msgstr;
+ msgstr << "You require " << (shipmodel->price() - player->credits()) << " additional credits to buy the " << shipmodel->name();
+ player->send(msgstr.str());
+ return;
+ }
+
+ player->add_credits(-shipmodel->price());
}
// player has only ship for now
@@ -132,10 +143,14 @@ void ShipDealer::func_buy(core::Player *player, const std::string &args)
player->set_control(ship);
}
- player->send("^BPurchased " + aux::article(shipmodel->name()));
- player->sound("game/buy-ship");
-
-
+ // send the ship purchased message
+ std::stringstream msgstr;
+ msgstr << "^BPurchased " << aux::article(shipmodel->name());
+ if (!Game::g_devel->value()) {
+ msgstr << " for " << shipmodel->price() << " credits";
+ }
+ player->send(msgstr.str());
+ player->sound("game/buy-ship");
}