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-11-12 20:53:35 +0000
committerStijn Buys <ingar@osirion.org>2009-11-12 20:53:35 +0000
commit5ddb64795cc959916eeedbec8dc3f65c06f49698 (patch)
treeee7231607b0bf49528570e5d3badcdedcb33f54e /src/core/item.h
parent3605a7bd8fffebfba38d31025b6f33cb82626a3b (diff)
initial commodities and entity inventory, bump network proto version to 18
Diffstat (limited to 'src/core/item.h')
-rw-r--r--src/core/item.h116
1 files changed, 38 insertions, 78 deletions
diff --git a/src/core/item.h b/src/core/item.h
index 0845c21..f88da57 100644
--- a/src/core/item.h
+++ b/src/core/item.h
@@ -7,93 +7,53 @@
#ifndef __INCLUDED_CORE_ITEM_H__
#define __INCLUDED_CORE_ITEM_H__
-#include <string>
-#include <vector>
+#include "core/info.h"
namespace core
{
/**
- * @brief a specific type of item in the game
- * Examples are tritanium hull armor, ion cannon, iron ore
+ * @brief an item in the inventory of an entity
+ * The info record represents the type of the item
*/
-class ItemType
+class Item
{
public:
- ItemType(const char *label);
-
- inline const std::string &label() {
- return itemtype_label;
- }
-
- inline const std::string &name() {
- return itemtype_name;
- }
-
- inline const float baseprice() {
- return itemtype_baseprice;
- }
-
- void set_name(const std::string &name);
-
- void set_baseprice(const float baseprice);
-
+ Item(const unsigned int class_id, const unsigned int info_id);
+
+ ~Item();
+
+ /* ---- inspectors --------------------------------------------- */
+
+ inline unsigned int class_id() const { return item_class_id; }
+
+ inline unsigned int info_id() const { return item_info_id; }
+
+ /**
+ * @brief associated amount
+ */
+ inline int amount() const { return item_amount; }
+
+ /**
+ * @brief information record
+ */
+ inline Info *info();
+
+ /* ---- mutators ----------------------------------------------- */
+
+ /**
+ * @brief set associated amount
+ */
+ void set_amount(const int amount);
+
private:
- std::string itemtype_label;
- std::string itemtype_name;
-
- float itemtype_baseprice;
+ unsigned int item_class_id;
+ unsigned int item_info_id;
+ int item_amount;
+
+ Info *item_info;
};
+} // namespace core
-/**
- * @brief a class of items
- * Examples are armor, cannons, commodities...
- */
-class ItemClass
-{
-public:
- typedef std::vector<ItemType *> Types;
-
- ItemClass(const char *label);
- ~ItemClass();
-
- inline const std::string &label() {
- return itemclass_label;
- }
-
- inline const std::string &name() {
- return itemclass_name;
- }
-
- ItemType *find_type(const char *label);
-
- void set_name(const std::string &name);
-
- void add_type(ItemType *itemtype);
-
- void list();
-
-private:
- std::string itemclass_label;
- std::string itemclass_name;
-
- Types itemclass_types;
-};
-
-class Item
-{
-public:
- typedef std::vector<ItemClass *> Registry;
-
- static void add_class(ItemClass * itemclass);
- static void add_type(ItemClass * itemclass, ItemType *itemtype);
- static void find_class(const char *label);
- static void clear();
- static void list();
-
- static Registry item_registry;
-};
-
-}
-#endif
+#endif // __INCLUDED_CORE_ITEM_H__