diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/info.h | 1 | ||||
-rw-r--r-- | src/core/item.cc | 26 | ||||
-rw-r--r-- | src/core/item.h | 43 | ||||
-rw-r--r-- | src/core/parser.cc | 4 |
4 files changed, 49 insertions, 25 deletions
diff --git a/src/core/info.h b/src/core/info.h index cc480bf..678c48d 100644 --- a/src/core/info.h +++ b/src/core/info.h @@ -25,6 +25,7 @@ class Info public: /// create a new labeled information record Info(const std::string & label); + /// delete the information record ~Info(); diff --git a/src/core/item.cc b/src/core/item.cc index ed73cb6..116685b 100644 --- a/src/core/item.cc +++ b/src/core/item.cc @@ -9,24 +9,24 @@ namespace core { -Item::Item(const unsigned int itemclass, const unsigned int itemtype, const char *infolabel) +ItemClass::ItemClass(const char *label) { - item_class = itemclass; - item_type = itemtype; - item_amount = 0; - - if (infolabel) { - item_infolabel.assign(infolabel); + if (label) { + itemclass_label.assign(label); } else { - item_infolabel.clear(); + itemclass_label.clear(); } } -Item::~Item() +ItemType::ItemType(const char *label) { - item_class = 0; - item_type = 0; - item_amount = 0; + if (label) { + itemtype_label.assign(label); + } else { + itemtype_label.clear(); + } + + itemtype_baseprice = 0; } -}
\ No newline at end of file +} diff --git a/src/core/item.h b/src/core/item.h index 68b6876..d390c2d 100644 --- a/src/core/item.h +++ b/src/core/item.h @@ -11,22 +11,45 @@ namespace core { -class Item +/** + * @brief a class of items + * Examples are armor, cannons, commodities... + */ +class ItemClass { public: - Item(const unsigned int itemclass, const unsigned int itemtype, const char *infolabel); - ~Item(); + ItemClass(const char *label); - inline const unsigned int itemclass() const { return item_class; } - inline const unsigned int itemtype() const { return item_type; } - + inline const std::string &label() { return itemclass_label; } + + inline const std::string &name() { return itemclass_name; } + +private: + std::string itemclass_label; + std::string itemclass_name; +}; + +/** + * @brief a specific type of item in the game + * Examples are tritanium hull armor, ion cannon, gems + */ +class ItemType +{ +public: + ItemType(const char *label); + + inline const std::string &label() { return itemtype_label; } + + inline const std::string &name() { return itemtype_name; } + + inline const float base_price() { return itemtype_baseprice; } private: - unsigned int item_class; - unsigned int item_type; - float item_amount; + std::string itemtype_label; + std::string itemtype_name; - std::string item_infolabel; + ItemClass *itemtype_class; + float itemtype_baseprice; }; } diff --git a/src/core/parser.cc b/src/core/parser.cc index 2cf0e39..0cee506 100644 --- a/src/core/parser.cc +++ b/src/core/parser.cc @@ -67,10 +67,10 @@ bool Parser::got_entity_key(filesystem::IniFile &inifile, core::Entity *entity) return true; } else if (inifile.got_key_vector3f("location", entity->entity_location)) { return true; - } else if (inifile.got_key_color("color", entity->entity_color)) { - return true; } else if (inifile.got_key_color("colorsecond", entity->entity_color_second)) { return true; + } else if (inifile.got_key_color("color", entity->entity_color)) { + return true; } return false; |