2017-08-08 13:53:47 +02:00
|
|
|
#ifndef _ITEMCONTAINER_H_
|
|
|
|
#define _ITEMCONTAINER_H_
|
|
|
|
|
|
|
|
#include <map>
|
2018-03-06 22:22:19 +01:00
|
|
|
#include <Common.h>
|
2018-09-09 23:56:22 +02:00
|
|
|
#include "ForwardsZone.h"
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2018-11-29 16:55:48 +01:00
|
|
|
namespace Sapphire
|
2018-10-28 21:53:21 +01:00
|
|
|
{
|
2018-08-29 21:40:59 +02:00
|
|
|
|
2018-12-05 21:29:33 +11:00
|
|
|
using ItemMap = std::map< uint16_t, ItemPtr >;
|
2018-08-29 21:40:59 +02:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
class ItemContainer
|
|
|
|
{
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
public:
|
2018-12-05 21:29:33 +11:00
|
|
|
ItemContainer( uint16_t storageId, uint16_t maxSize, const std::string& tableName, bool isMultiStorage,
|
2018-12-29 00:53:52 +01:00
|
|
|
FrameworkPtr pFw, bool isPersistentStorage = true );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
~ItemContainer();
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
uint16_t getId() const;
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2018-12-05 21:29:33 +11:00
|
|
|
uint16_t getEntryCount() const;
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2018-12-29 21:51:43 +11:00
|
|
|
void removeItem( uint16_t slotId, bool removeFromDb = true );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
ItemMap& getItemMap();
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
const ItemMap& getItemMap() const;
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2018-12-05 21:29:33 +11:00
|
|
|
ItemPtr getItem( uint16_t slotId );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2018-12-05 21:29:33 +11:00
|
|
|
void setItem( uint16_t slotId, ItemPtr item );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2018-12-05 21:29:33 +11:00
|
|
|
int16_t getFreeSlot();
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2018-12-05 21:29:33 +11:00
|
|
|
uint16_t getMaxSize() const;
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
std::string getTableName() const;
|
2018-07-25 14:03:43 +02:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
bool isMultiStorage() const;
|
2018-07-25 14:03:43 +02:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
bool isPersistentStorage() const;
|
2018-08-12 22:53:21 +10:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
private:
|
|
|
|
uint16_t m_id;
|
2018-12-05 21:29:33 +11:00
|
|
|
uint16_t m_size;
|
2018-10-28 21:53:21 +01:00
|
|
|
std::string m_tableName;
|
|
|
|
bool m_bMultiStorage;
|
2018-12-29 00:53:52 +01:00
|
|
|
FrameworkPtr m_pFw;
|
2018-10-28 21:53:21 +01:00
|
|
|
bool m_isPersistentStorage;
|
|
|
|
ItemMap m_itemMap;
|
|
|
|
Entity::PlayerPtr m_pOwner;
|
|
|
|
};
|
2017-08-08 13:53:47 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-12-08 15:38:25 +01:00
|
|
|
#endif
|