cItem: Added useful utility functions
git-svn-id: http://mc-server.googlecode.com/svn/trunk@1599 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "Item.h"
|
||||
#include <json/json.h>
|
||||
#include "Items/ItemHandler.h"
|
||||
|
||||
|
||||
|
||||
@@ -19,6 +20,20 @@ cItem cItem::CopyOne(void) const
|
||||
|
||||
|
||||
|
||||
cItem & cItem::AddCount(char a_AmountToAdd)
|
||||
{
|
||||
m_ItemCount += a_AmountToAdd;
|
||||
if (m_ItemCount <= 0)
|
||||
{
|
||||
Empty();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
short cItem::GetMaxDamage(void) const
|
||||
{
|
||||
switch (m_ItemType)
|
||||
@@ -97,6 +112,25 @@ bool cItem::IsStackableWith(const cItem & a_OtherStack) const
|
||||
|
||||
|
||||
|
||||
bool cItem::IsFullStack(void) const
|
||||
{
|
||||
return (m_ItemCount >= ItemHandler(m_ItemType)->GetMaxStackSize());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// Returns the cItemHandler responsible for this item type
|
||||
cItemHandler * cItem::GetHandler(void) const
|
||||
{
|
||||
return ItemHandler(m_ItemType);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cItem::GetJson(Json::Value & a_OutValue) const
|
||||
{
|
||||
a_OutValue["ID"] = m_ItemType;
|
||||
|
||||
Reference in New Issue
Block a user