Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2009-01-25 11:59:24 +0000
committerStijn Buys <ingar@osirion.org>2009-01-25 11:59:24 +0000
commitafb56bf384bbc585f242978b6b5366c474c5c7f7 (patch)
tree9f2d7e006b30ea0be8ebc9f15253b493ef65192f /src/game/base/shipdealer.cc
parent443a8dc2b49be6e1fa668f43a12bf5f886a1bdcd (diff)
make a player pay for ships,
add prize money to the race
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");
}