CSCommon: MMatchRule.h 소스 파일

MAIET

MMatchRule.h

00001 #ifndef _MMATCHRULE_H
00002 #define _MMATCHRULE_H
00003 
00004 #include "MMatchItem.h"
00005 #include "MMatchTransDataType.h"
00006 #include "MUID.h"
00007 #include "MMatchGameType.h"
00008 
00009 class MMatchObject;
00010 class MMatchStage;
00011 
00012 
00014 enum MMATCH_ROUNDSTATE {
00015     MMATCH_ROUNDSTATE_PREPARE       = 0,            
00016     MMATCH_ROUNDSTATE_COUNTDOWN     = 1,            
00017     MMATCH_ROUNDSTATE_PLAY          = 2,            
00018     MMATCH_ROUNDSTATE_FINISH        = 3,            
00019     MMATCH_ROUNDSTATE_EXIT          = 4,            
00020     MMATCH_ROUNDSTATE_FREE          = 5,            
00021     MMATCH_ROUNDSTATE_END   // Not using, just a END mark
00022 };
00023 
00024 enum MMATCH_ROUNDRESULT {
00025     MMATCH_ROUNDRESULT_DRAW = 0,
00026     MMATCH_ROUNDRESULT_REDWON,
00027     MMATCH_ROUNDRESULT_BLUEWON,
00028     MMATCH_ROUNDRESULT_END
00029 };
00030 
00031 
00034 class MMatchRule {
00035 protected:
00036     MMatchGameTypeInfo* m_pGameTypeInfo;                            
00037 
00038     MMatchStage*        m_pStage;                                   
00039     MMATCH_ROUNDSTATE   m_nRoundState;                              
00040     int                 m_nRoundCount;                              
00041     int                 m_nRoundArg;                                
00042     unsigned long       m_tmRoundStateTimer;
00043     int                 m_nLastTimeLimitAnnounce;                   // 60, 30, 10 중 하나
00044 
00045 protected:
00046     virtual bool RoundCount() { return false; }                     
00047     virtual bool OnRun();                                           
00048     virtual void OnBegin();                                         
00049     virtual void OnEnd();                                           
00050     virtual void OnRoundBegin();                                    
00051     virtual void OnRoundEnd();                                      
00052     virtual void OnRoundTimeOut();                                  
00053 
00054     virtual bool OnCheckRoundFinish() = 0;                          
00055     virtual bool OnCheckEnableBattleCondition() { return true; }    
00056     virtual bool OnCheckBattleTimeOut(unsigned int tmTimeSpend);    
00057 
00058     void SetRoundStateTimer(unsigned long tmTime)   { m_tmRoundStateTimer = tmTime; }
00059     void InitRound();                                               
00060     void SetRoundState(MMATCH_ROUNDSTATE nState);                   
00061 public:
00062     MMatchRule()                    { _ASSERT(false); }             
00063     MMatchRule(MMatchStage* pStage);                                
00064     virtual ~MMatchRule()           {}                              
00065     MMatchStage* GetStage()         { return m_pStage; }            
00066 
00067     int GetRoundCount()             { return m_nRoundCount; }       
00068     void SetRoundCount(int nRound)  { m_nRoundCount = nRound; }     
00069     int GetRoundArg()               { return m_nRoundArg; }         
00070     void SetRoundArg(int nArg)      { m_nRoundArg = nArg; }         
00071 
00072     MMATCH_ROUNDSTATE GetRoundState()   { return m_nRoundState; }               
00073     unsigned long GetRoundStateTimer()  { return m_tmRoundStateTimer; }
00074     unsigned long GetLastTimeLimitAnnounce()    { return m_nLastTimeLimitAnnounce; }
00075     void SetLastTimeLimitAnnounce(int nSeconds) { m_nLastTimeLimitAnnounce = nSeconds; }
00076 
00077     virtual void* CreateRuleInfoBlob()      { return NULL; }
00078 
00085     virtual void CalcTeamBonus(MMatchObject* pAttacker,
00086                                MMatchObject* pVictim,
00087                                int nSrcExp,
00088                                int* poutAttackerExp,
00089                                int* poutTeamExp);
00091     virtual void OnEnterBattle(MUID& uidChar) {}        
00092     // 게임중 나갔을때 호출된다.
00093     virtual void OnLeaveBattle(MUID& uidChar) {}        
00095     virtual void OnCommand(MCommand* pCommand) {}       
00097     virtual void OnObtainWorldItem(MMatchObject* pObj, int nItemID, int nExtraValue) {}     
00098     virtual void OnRequestDropSacrificeItemOnSlot( MCommand* pCmd )     {}
00099     virtual void OnResponseDropSacrificeItemOnSlot( MCommand* pCmd )    {}
00100     
00101     bool Run();                                                     
00102     void Begin();                                                   
00103     void End();                                                     
00104 
00105     void DebugTest();                                               
00106 };
00107 
00108 
00110 
00111 
00112 
00113 
00114 
00115 
00116 
00117 
00118 inline bool IsGameRuleDeathMatch(MMATCH_GAMETYPE nGameType)
00119 {
00120     return (
00121         (nGameType == MMATCH_GAMETYPE_DEATHMATCH_SOLO) || 
00122         (nGameType == MMATCH_GAMETYPE_DEATHMATCH_TEAM) ||
00123         (nGameType == MMATCH_GAMETYPE_TRAINING)
00124     );
00125 }
00126 inline bool IsGameRuleGladiator(MMATCH_GAMETYPE nGameType)
00127 {
00128     return ((nGameType == MMATCH_GAMETYPE_GLADIATOR_SOLO) || 
00129             (nGameType == MMATCH_GAMETYPE_GLADIATOR_TEAM));
00130 }
00131 
00132 #endif


MAIET entertainment