summaryrefslogtreecommitdiffstats
path: root/source/cItem.h
diff options
context:
space:
mode:
Diffstat (limited to 'source/cItem.h')
-rw-r--r--source/cItem.h61
1 files changed, 34 insertions, 27 deletions
diff --git a/source/cItem.h b/source/cItem.h
index 4311cc3f0..28eed0d42 100644
--- a/source/cItem.h
+++ b/source/cItem.h
@@ -12,34 +12,41 @@ namespace Json
-class cItem //tolua_export
-{ //tolua_export
+// tolua_begin
+class cItem
+{
public:
- cItem( ENUM_ITEM_ID a_ItemID = E_ITEM_EMPTY, char a_ItemCount = 0, short a_ItemHealth = 0 ) //tolua_export
+ cItem( ENUM_ITEM_ID a_ItemID = E_ITEM_EMPTY, char a_ItemCount = 0, short a_ItemHealth = 0 )
: m_ItemID ( a_ItemID )
, m_ItemCount ( a_ItemCount )
, m_ItemHealth ( a_ItemHealth )
- { //tolua_export
+ {
if(!IsValidItem( m_ItemID ) ) m_ItemID = E_ITEM_EMPTY;
- } //tolua_export
- void Empty() //tolua_export
- { //tolua_export
+ }
+ void Empty()
+ {
+ m_ItemID = E_ITEM_EMPTY;
+ m_ItemCount = 0;
+ m_ItemHealth = 0;
+ }
+ void Clear(void)
+ {
m_ItemID = E_ITEM_EMPTY;
m_ItemCount = 0;
m_ItemHealth = 0;
- } //tolua_export
- bool IsEmpty(void) const //tolua_export
- { //tolua_export
+ }
+ bool IsEmpty(void) const
+ {
return (m_ItemID <= 0 || m_ItemCount <= 0);
- } //tolua_export
- bool Equals( cItem & a_Item ) const //tolua_export
- { //tolua_export
+ }
+ bool Equals( cItem & a_Item ) const
+ {
return ( (m_ItemID == a_Item.m_ItemID) && (m_ItemHealth == a_Item.m_ItemHealth) );
- } //tolua_export
+ }
- //TODO Sorry for writing the functions in the header. But somehow it doesn´t worked when I put them into the cpp File :s
+ // TODO Sorry for writing the functions in the header. But somehow it doesn´t worked when I put them into the cpp File :s
- inline int GetMaxDuration()
+ inline int GetMaxDuration(void) const
{
switch(m_ItemID)
{
@@ -74,31 +81,31 @@ public:
}
}
- //Damages a weapon. Returns true when destroyed
- inline bool DamageItem() {
- if(HasDuration())
+ // Damages a weapon / tool. Returns true when destroyed
+ inline bool DamageItem()
+ {
+ if (HasDuration())
{
m_ItemHealth++;
-
if(m_ItemHealth >= GetMaxDuration())
return true;
-
}
return false;
}
inline bool HasDuration() { return GetMaxDuration() > 0; }
- void GetJson( Json::Value & a_OutValue ) const; //tolua_export
- void FromJson( const Json::Value & a_Value ); //tolua_export
+ void GetJson( Json::Value & a_OutValue ) const;
+ void FromJson( const Json::Value & a_Value );
static bool IsEnchantable(ENUM_ITEM_ID item);
- ENUM_ITEM_ID m_ItemID; //tolua_export
- char m_ItemCount; //tolua_export
- short m_ItemHealth; //tolua_export
+ ENUM_ITEM_ID m_ItemID;
+ char m_ItemCount;
+ short m_ItemHealth;
-}; //tolua_export
+};
+// tolua_end
typedef std::vector<cItem> cItems;