2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
|
|
|
|
|
2012-09-23 18:09:57 -04:00
|
|
|
#include "Item.h"
|
2012-06-14 09:06:06 -04:00
|
|
|
#include <json/json.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-04-10 15:52:03 -04:00
|
|
|
bool cItem::IsStackableWith(const cItem & a_OtherStack)
|
|
|
|
{
|
|
|
|
if (a_OtherStack.m_ItemType != m_ItemType)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: match enchantments etc.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-06-14 09:06:06 -04:00
|
|
|
void cItem::GetJson( Json::Value & a_OutValue ) const
|
|
|
|
{
|
2013-01-11 23:46:01 -05:00
|
|
|
a_OutValue["ID"] = m_ItemType;
|
|
|
|
if( m_ItemType > 0 )
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
|
|
|
a_OutValue["Count"] = m_ItemCount;
|
2013-01-11 23:46:01 -05:00
|
|
|
a_OutValue["Health"] = m_ItemDamage;
|
2012-06-14 09:06:06 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cItem::FromJson( const Json::Value & a_Value )
|
|
|
|
{
|
2013-01-11 23:46:01 -05:00
|
|
|
m_ItemType = (ENUM_ITEM_ID)a_Value.get("ID", -1 ).asInt();
|
|
|
|
if( m_ItemType > 0 )
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
|
|
|
m_ItemCount = (char)a_Value.get("Count", -1 ).asInt();
|
2013-01-11 23:46:01 -05:00
|
|
|
m_ItemDamage = (short)a_Value.get("Health", -1 ).asInt();
|
2012-06-14 09:06:06 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-18 05:56:28 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool cItem::IsEnchantable(short item)
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
2012-08-18 05:56:28 -04:00
|
|
|
if ((item >= 256) && (item <= 259))
|
2012-06-14 09:06:06 -04:00
|
|
|
return true;
|
2012-08-18 05:56:28 -04:00
|
|
|
if ((item >= 267) && (item <= 279))
|
2012-06-14 09:06:06 -04:00
|
|
|
return true;
|
2012-08-18 05:56:28 -04:00
|
|
|
if ((item >= 283) && (item <= 286))
|
2012-06-14 09:06:06 -04:00
|
|
|
return true;
|
2012-08-18 05:56:28 -04:00
|
|
|
if ((item >= 290) && (item <= 294))
|
2012-06-14 09:06:06 -04:00
|
|
|
return true;
|
2012-08-18 05:56:28 -04:00
|
|
|
if ((item >= 298) && (item <= 317))
|
2012-06-14 09:06:06 -04:00
|
|
|
return true;
|
2012-08-18 05:56:28 -04:00
|
|
|
if ((item >= 290) && (item <= 294))
|
2012-06-14 09:06:06 -04:00
|
|
|
return true;
|
|
|
|
|
2012-08-18 05:56:28 -04:00
|
|
|
if ((item == 346) || (item == 359) || (item == 261))
|
2012-06-14 09:06:06 -04:00
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2012-08-18 05:56:28 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|