/* ==========================================================================
* 파    일 : ItemMixManager.h
* 목    적 : 
* 작 성 자 : 김가람
* 작 성 일 : 2009-01-15
* 주의사항 :
*===========================================================================*/

/// 네트워크 락
enum
{
	eLOCK_ITEMMIXNONE,
	eLOCK_ITEMMIXDELETE,
	eLOCK_ITEMMIXSTART,
	eLOCK_ITEMMIXEND,
};

/// 보유 레시피 정보
struct sKeepRecipe
{
	unsigned long mRestTime;
	unsigned long mStartTime;
	
	sKeepRecipe()
	{
		mRestTime = 0;
		mStartTime = 0;
	}
};

class cItemMixManager
{
public:
	cItemMixManager();
	~cItemMixManager();

	void Close();

	/// 스킬,레시피 등록 아이템 사용
	bool ItemMixUseMakeSkill( unsigned short slot, unsigned long makeSkillIdx );
	bool ItemMixUseRecipe( unsigned short slot, unsigned long recipeIdx );
	bool ItemMixUseRecipeGroup( unsigned short slot, unsigned long recipeGroupIdx );

	///
	void ItemMixStart( unsigned char index, unsigned long recipeIdx, int count );
	void ItemMixDelete( unsigned char index );
	void ItemMixCancel( bool hide = true );
	void ItemMixEndRequest();

	///
	void ItemMixOpen();

	///
	void NetworkMsgParserLoad( char* msg );
	void NetworkMsgParserGame( char* msg );

	/// 레시피인덱스
	sKeepRecipe* GetKeepMixSkill1( unsigned long recipeIdx );
	sKeepRecipe* GetKeepMixSkill2( unsigned long recipeIdx );
	unsigned long GetKeepSkillText( unsigned char index );
	unsigned long GetTypeText( int index, unsigned long type );
	bool IsMixContinue() { return (mContinueDescCount > mContinueCount); }
	bool IsNetLock() { return mNetLock; }

	tPointerHashMap<unsigned long, void*>* GetKeepSkillMap1() { return &mKeepSkillMap1; }
	tPointerHashMap<unsigned long, void*>* GetKeepSkillMap2() { return &mKeepSkillMap2; }

public:
	static cItemMixManager*	mpSingleton;
	static cItemMixManager* GetSingleton();

protected:
	bool AddKeepSkill1( unsigned long recipeIdx, unsigned long restTime );
	bool AddKeepSkill2( unsigned long recipeIdx, unsigned long restTime );
	void DeleteKeepSkill1();
	void DeleteKeepSkill2();

	void ItemMixContinue();
	
	/// 락걸기
	void NetLock( int lockTry );
	void NetUnLock( int lockTry );

private:
	typedef tPointerHashMap<unsigned long, void*> cKeepRecipeMap;
	cKeepRecipeMap	mKeepSkillMap1;	// 전문기술 1
	cKeepRecipeMap	mKeepSkillMap2;	// 전문기술 2

	/// 네트워크 관련 락
	bool	mNetLock;
	int		mLockTry;

	/// 연속 진행 정보
	int			  mContinueDescCount;	/// 목표치
	int			  mContinueCount;
	unsigned char mContinueSkill;
	unsigned long mContinueRecipe;
};

inline cItemMixManager* cItemMixManager::GetSingleton() 
{
	return mpSingleton;
}

#define ITEMMIXMAN cItemMixManager::GetSingleton()