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/game.cc')
-rw-r--r--src/game/base/game.cc57
1 files changed, 48 insertions, 9 deletions
diff --git a/src/game/base/game.cc b/src/game/base/game.cc
index 9f8dabc..83d0be8 100644
--- a/src/game/base/game.cc
+++ b/src/game/base/game.cc
@@ -267,34 +267,71 @@ void Game::func_give(core::Player *player, const std::string &args)
}
}
+// sell request from a player
+void Game::func_sell(core::Player *player, const std::string &args)
+{
+ std::istringstream is(args);
+ std::string typestr;
+ std::string labelstr;
+
+ if (!(is >> typestr)) {
+ player->send("Usage: sell [string] [string] [int] sell an item: specify type, label and amount");
+ return;
+ } else {
+ aux::to_label(typestr);
+ }
+
+ if (!(is >> labelstr)) {
+ player->send("Usage: sell [string] [string] [int] sell an item: specify type, label and amount");
+ return;
+ } else {
+ aux::to_label(labelstr);
+ }
+
+ int amount = 0;
+ if (!(is >> amount))
+ amount = 0;
+
+ if (typestr.compare("cargo") == 0) {
+ Cargo *cargo = Cargo::find(labelstr);
+ if (cargo) {
+ cargo->sell(player->control(), player->view(), amount);
+ } else {
+ player->send("Unkown cargo type '" + labelstr + "'");
+ }
+ } else {
+ player->send("Unkown item type '" + typestr + "'");
+ }
+ return;
+}
+
// buy request from a player
void Game::func_buy(core::Player *player, const std::string &args)
{
std::istringstream is(args);
std::string typestr;
std::string labelstr;
- int amount = 0;
if (!(is >> typestr)) {
- player->send("Usage: buy [string] [string] buy an item, specify type and label");
+ player->send("Usage: buy [string] [string] [int] buy an item: specify type, label and amount");
return;
} else {
aux::to_label(typestr);
}
if (!(is >> labelstr)) {
- labelstr.clear();
+ player->send("Usage: buy [string] [string] [int] buy an item: specify type, label and amount");
+ return;
} else {
aux::to_label(labelstr);
}
-
+
+ int amount = 0;
if (!(is >> amount))
amount = 0;
if (typestr.compare("ship") == 0) {
- ShipDealer::func_buy(player, labelstr);
-
-
+ ShipDealer::func_buy(player, labelstr);
} else if (typestr.compare("cargo") == 0) {
Cargo *cargo = Cargo::find(labelstr);
if (cargo) {
@@ -305,7 +342,6 @@ void Game::func_buy(core::Player *player, const std::string &args)
} else {
player->send("Unkown item type '" + typestr + "'");
}
-
return;
}
@@ -495,8 +531,11 @@ Game::Game() : core::Module("Project::OSiRiON", true)
func->set_info("leave the game and spectate");
func = core::Func::add("buy", Game::func_buy);
- func->set_info("[string] [string] buy type of item, name of item");
+ func->set_info("[string] [string] [int] buy an item: specify type, label and amount");
+ func = core::Func::add("sell", Game::func_sell);
+ func->set_info("[string] [string] [int] sell an item: specify type, label and amount");
+
func = core::Func::add("give", Game::func_give);
func->set_info("cheat functions");