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.cc144
1 files changed, 0 insertions, 144 deletions
diff --git a/src/game/base/shipdealer.cc b/src/game/base/shipdealer.cc
deleted file mode 100644
index e6df18f..0000000
--- a/src/game/base/shipdealer.cc
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- base/shipdealer.cc
- This file is part of the Osirion project and is distributed under
- the terms and conditions of the GNU General Public License version 2
-*/
-
-#include "auxiliary/functions.h"
-#include "base/game.h"
-#include "base/planet.h"
-#include "base/shipdealer.h"
-#include "base/station.h"
-#include "sys/sys.h"
-
-namespace game
-{
-
-ShipDealer::ShipDealer()
-{
-}
-
-ShipDealer::~ShipDealer()
-{
- dealer_models.clear();
-}
-
-ShipModel *ShipDealer::add(const std::string &modelname)
-{
- ShipModel *model = ShipModel::find(modelname);
-
- if (!model) {
- con_warn << "Ship model '" + modelname + "' not found" << std::endl;
- return 0;
- }
-
- for (Models::iterator it = dealer_models.begin(); it != dealer_models.end(); it++) {
- if ((*it) == model) {
- con_warn << "Ship dealer already has " + model->name() << std::endl;
- return 0;
- }
- }
- dealer_models.push_back(model);
- return model;
-}
-
-ShipModel *ShipDealer::find(const std::string &modelname) const
-{
- for (Models::const_iterator it = dealer_models.begin(); it != dealer_models.end(); it++) {
- if ((*it)->label().compare(modelname) == 0) {
- return (*it);
- }
- }
-
- return 0;
-}
-
-ShipModel *ShipDealer::find(ShipModel *shipmodel) const
-{
- for (Models::const_iterator it = dealer_models.begin(); it != dealer_models.end(); it++) {
- if ((*it) == shipmodel) {
- return (*it);
- }
- }
-
- return 0;
-}
-
-// a player buys a ship
-void ShipDealer::func_buy(core::Player *player, const std::string &args)
-{
- core::Entity *dock = player->view();
- ShipDealer *shipdealer = 0;
-
- std::istringstream is(args);
- std::string labelstr;
-
- if (!(is >> labelstr)) {
- player->send("Usage: buy ship [string]");
- }
-
- // find the ship model
- ShipModel *shipmodel = ShipModel::find(labelstr);
- if (!shipmodel) {
- player->send("Unkown ship type '" + labelstr + "'");
- return;
- }
-
- // find the ship dealer we're buying the ship from
- if (player->view()) {
- if (player->view()->moduletype() == station_enttype) {
- shipdealer = static_cast<Station *>(player->view())->shipdealer();
- } else if (player->view()->moduletype() == planet_enttype) {
- shipdealer = static_cast<Planet *>(player->view())->shipdealer();
- }
- }
-
- if (!shipdealer) {
- player->send("No ship dealer available");
- return;
- }
-
- if (!shipdealer->find(shipmodel)) {
- 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
- if (player->control()) {
- player->remove_asset(player->control());
- }
-
- Ship * ship = new Ship(player, shipmodel);
- if (dock) {
- ship->set_zone(dock->zone());
- ship->get_location().assign(dock->location());
- ship->set_state(core::Entity::Docked);
- ship->get_axis().assign(dock->axis());
- ship->get_axis().change_direction(180.0f);
- player->set_control(ship);
- player->set_view(dock);
- } else {
- ship->set_zone(player->zone());
- player->set_control(ship);
- }
-
- // send the ship purchased message
- std::stringstream msgstr;
- msgstr << "^BPurchased " << aux::article(shipmodel->name()) << " for " << shipmodel->price() << " credits";
-
- player->send(msgstr.str());
- player->sound("game/buy-ship");
-}
-
-
-}