diff options
author | Stijn Buys <ingar@osirion.org> | 2009-11-13 22:25:09 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2009-11-13 22:25:09 +0000 |
commit | a993d31910b63a1f897e470842934e6ffefad32c (patch) | |
tree | fef52482d762acbbd35e97f382b60ff24ce5071f /src/game/base/shipmodel.h | |
parent | 5ddb64795cc959916eeedbec8dc3f65c06f49698 (diff) |
added core::InfoType, refactored game::ShipModel as core::Info subclass, introduced core::Label
Diffstat (limited to 'src/game/base/shipmodel.h')
-rw-r--r-- | src/game/base/shipmodel.h | 105 |
1 files changed, 30 insertions, 75 deletions
diff --git a/src/game/base/shipmodel.h b/src/game/base/shipmodel.h index d3048b2..19b2a77 100644 --- a/src/game/base/shipmodel.h +++ b/src/game/base/shipmodel.h @@ -7,7 +7,6 @@ #ifndef __INCLUDED_BASE_SHIPMODEL_H__ #define __INCLUDED_BASE_SHIPMODEL_H__ -#include <map> #include <string> #include "core/info.h" @@ -15,15 +14,23 @@ namespace game { -/// ship model specifications -class ShipModel +/// ship model specification +class ShipModel : public core::Info { public: - ShipModel(const unsigned int type_id); - ~ShipModel(); + /// default constructor + ShipModel(); - void print(); + /// default destructor + virtual ~ShipModel(); + /* ---- inspectors ------------------------------------------------ */ + + /// indicates if this model can be equiped with a jump drive + inline const bool jumpdrive() const { + return shipmodel_jumpdrive; + } + /// acceleration inline const float acceleration() const { return shipmodel_acceleration; @@ -39,36 +46,13 @@ public: return shipmodel_turnspeed; } - /// label of the ship model - inline const std::string &label() const { - return shipmodel_label; - } - - /// name of the ship model - inline const std::string & name() const { - return shipmodel_name; - } - - /// name of the model of the ship - inline const std::string & modelname() const { - return shipmodel_modelname; - } - - /// type id - inline unsigned int type_id() { - return shipmodel_type_id; - } - - /// price of the ship - inline const long price() const { - return shipmodel_price; - } - /// size of the cargo hold inline const float maxcargo() const { return shipmodel_maxcargo; } + /* ---- mutators -------------------------------------------------- */ + /// set acceleration inline void set_acceleration(const float acceleration) { shipmodel_acceleration = acceleration; @@ -84,66 +68,37 @@ public: shipmodel_turnspeed = turnspeed; } - /// set price - inline void set_price(const long price) { - shipmodel_price = price; - } - /// set size of the cargo hold inline void set_maxcargo(const float maxcargo) { shipmodel_maxcargo = maxcargo; } - /// indicates of this model can be equiped with a jump drive - bool shipmodel_jumpdrive; - - std::string shipmodel_label; - std::string shipmodel_name; - std::string shipmodel_modelname; - - /// info text - core::Info::Text shipmodel_infotext; - - /* ---- static registry ------------------------------------ */ + /// set jumpdrive capability + inline void set_jumpdrive(const bool jumpdrive) { + shipmodel_jumpdrive = jumpdrive; + } - typedef std::map<std::string, ShipModel *> Registry; + void generate_info(); - typedef std::map<std::string, ShipModel *>::iterator iterator; - - /// find an exact match - static ShipModel *find(ShipModel *shipmodel); - - /// find an exact match - static ShipModel *find(const std::string label); - - /// search the registry - static ShipModel *search(const std::string label); - - /// the ship model registry - static std::map<std::string, ShipModel *> registry; + /* --- static registry functions ---------------------------------- */ + + static void list(); + + static ShipModel *find(const unsigned int id); - /// clear the ship model registry - static void clear(); + static ShipModel *find(const std::string & label); - /// list the ship model registry - static void list(); + static ShipModel *search(const std::string searchstr); - /// add a new ship model - static void add(ShipModel *shipmodel); - - /// generate info records - static void generate_info(); + static core::InfoType *shipmodel_infotype; private: - + bool shipmodel_jumpdrive; + float shipmodel_acceleration; float shipmodel_maxspeed; float shipmodel_turnspeed; float shipmodel_maxcargo; - - long shipmodel_price; - - unsigned int shipmodel_type_id; }; } |