#pragma once //---------------------------------------------------------------------------- // ½Å·ÚÇÒ ¼ö ÀÖ´Â È®·ü ÃßÃâ±â È®Àå // // @author Kim Chang Hyun < shogen@webzen.co.kr > // @since 2007. 8. 24 // @remarks // - È®·üÀÇ È®·ü¹üÀǸ¦ À§ÇÑ Å¬·¡½º //---------------------------------------------------------------------------- template< DWORD nSeperator, class Type = DWORD, class ListType = INT, typename KeyType = DWORD > class ReliableRatioRandomizerEX { public: ReliableRatioRandomizerEX(void) { Clear(); } ~ReliableRatioRandomizerEX(void){} BOOL AddRatio( KeyType Key, Type numerator, Type denominator ); VOID SetMin( ListType Value, DWORD Num ); VOID SetMax( ListType Value, DWORD Num ); ListType GetRandomizedValue(); VOID Clear(); private: ListType m_Min[nSeperator]; ListType m_Max[nSeperator]; ReliableRatioRandomizer m_Randomizer; }; template< DWORD nSeperator, class Type, class ListType, typename KeyType > BOOL ReliableRatioRandomizerEX::AddRatio( KeyType Key, Type numerator, Type denominator ) { return m_Randomizer.AddRatio( Key, numerator, denominator ); } template< DWORD nSeperator, class Type, class ListType, typename KeyType > VOID ReliableRatioRandomizerEX::SetMin( ListType Value, DWORD Num ) { if( Num == 0 || Num > nSeperator ) { ASSERT(FALSE); return; } m_Min[Num - 1] = Value; } template< DWORD nSeperator, class Type, class ListType, typename KeyType > VOID ReliableRatioRandomizerEX::SetMax( ListType Value, DWORD Num ) { if( Num == 0 || Num > nSeperator ) { ASSERT(FALSE); return; } m_Max[Num - 1] = Value; } template< DWORD nSeperator, class Type, class ListType, typename KeyType > ListType ReliableRatioRandomizerEX::GetRandomizedValue() { KeyType Key = m_Randomizer.RandomizedKey(); ListType Min = m_Min[Key-1]; ListType Max = m_Max[Key-1]; return random(Min, Max); } template< DWORD nSeperator, class Type, class ListType, typename KeyType > VOID ReliableRatioRandomizerEX::Clear() { memset( m_Min, 0, sizeof(ListType)*nSeperator ); memset( m_Max, 0, sizeof(ListType)*nSeperator ); m_Randomizer.Clear(); }