MLadderGroup.h
00001 #pragma once 00002 00003 00004 #include <list> 00005 #include <map> 00006 using namespace std; 00007 00008 #include "MUID.h" 00009 00010 00011 class MLadderGroup { 00012 protected: 00013 int m_nType; 00014 int m_nID; 00015 int m_nScore; 00016 int m_nTickCount; 00017 bool m_bWantBalancedMatching; 00018 00019 // 클랜전만 사용 ------- 00020 int m_nCLID; 00021 int m_nTotalCharLevel; 00022 int m_nTotalContPoint; 00023 // --------------------- 00024 00025 00026 list<MUID> m_uidPlayerList; 00027 00028 unsigned int m_nRegTime; 00029 public: 00030 MLadderGroup(unsigned int nRegTime) 00031 { 00032 m_nType=0; m_nID=0; m_nScore=0; m_nCLID=0; m_nRegTime=nRegTime; 00033 m_nTickCount = 0; 00034 m_nTotalCharLevel=0; m_nTotalContPoint=0; 00035 m_bWantBalancedMatching = false; 00036 } 00037 int GetLadderType() { return m_nType; } 00038 void SetLadderType(int nType) { m_nType = nType; } 00039 int GetID() { return m_nID; } 00040 void SetID(int nID) { m_nID = nID; } 00041 int GetScore() { return m_nScore; } 00042 int GetCLID() { return m_nCLID; } 00043 void SetCLID(int nCLID) { m_nCLID = nCLID; } 00044 unsigned int GetRegTime() { return m_nRegTime; } 00045 inline int GetCharLevel(); 00046 inline int GetContPoint(); 00047 int GetTickCount() { return m_nTickCount; } 00048 void SetBalancedMatching(bool bValue) { m_bWantBalancedMatching = bValue; } 00049 00050 size_t GetPlayerCount() { return m_uidPlayerList.size(); } 00051 list<MUID>::iterator GetPlayerListBegin() { return m_uidPlayerList.begin(); } 00052 list<MUID>::iterator GetPlayerListEnd() { return m_uidPlayerList.end(); } 00053 00054 void AddPlayer(MMatchObject* pObj) { 00055 _ASSERT(GetID()); 00056 pObj->SetLadderGroupID(GetID()); 00057 pObj->SetLadderChallenging(true); 00058 if (IsEnabledObject(pObj)) 00059 { 00060 m_nTotalCharLevel += pObj->GetCharInfo()->m_nLevel; 00061 m_nTotalContPoint += pObj->GetCharInfo()->m_ClanInfo.m_nContPoint; 00062 } 00063 m_uidPlayerList.push_back(pObj->GetUID()); 00064 } 00065 unsigned long GetChecksum() { 00066 return (unsigned long)(m_nType + m_nID); 00067 } 00068 void UpdateTick() { 00069 if (!m_bWantBalancedMatching) m_nTickCount++; 00070 } // 비슷한 실력의 클랜과만 대전을 원하면 틱을 올리지 않는다. 00071 bool IsSameGroup(MLadderGroup* pTarGroup) 00072 { 00073 if (m_nID == pTarGroup->GetID()) return true; 00074 if ((m_nCLID != 0) && (pTarGroup->GetCLID() != 0) && (m_nCLID == pTarGroup->GetCLID())) return true; 00075 return false; 00076 } 00077 }; 00078 00079 class MLadderGroupMap : public map<int, MLadderGroup*> { 00080 protected: 00081 // int m_idGenerate; 00082 // int GenerateID() { return ++m_idGenerate; } 00083 00084 public: 00085 MLadderGroupMap() { 00086 // m_idGenerate = 0; 00087 } 00088 virtual ~MLadderGroupMap() { } 00089 00090 void Add(MLadderGroup* pGroup) { 00091 // int nID = GenerateID(); 00092 // pGroup->SetID(nID); 00093 _ASSERT(pGroup->GetID()); 00094 insert(value_type(pGroup->GetID(), pGroup)); 00095 } 00096 void Remove(int nID) { // NO Delete the Data 00097 iterator i = find(nID); 00098 if(i==end()) return; 00099 00100 MLadderGroup* pGroup = (*i).second; 00101 erase(i); 00102 } 00103 MLadderGroup* Find(int nID) { 00104 iterator i = find(nID); 00105 if(i==end()) return NULL; 00106 00107 MLadderGroup* pGroup = (*i).second; 00108 return pGroup; 00109 } 00110 }; 00111 00112 00113 00114 // inline functions //////////////////////////////////////////////////////////////////////// 00115 inline int MLadderGroup::GetCharLevel() 00116 { 00117 int nPlayerCount = (int)GetPlayerCount(); 00118 if (nPlayerCount > 0) return (m_nTotalCharLevel / nPlayerCount); 00119 return 1; 00120 } 00121 inline int MLadderGroup::GetContPoint() 00122 { 00123 int nPlayerCount = (int)GetPlayerCount(); 00124 if (nPlayerCount > 0) return (m_nTotalContPoint / nPlayerCount); 00125 return 0; 00126 }
MAIET entertainment