124 lines
4.0 KiB
C++
124 lines
4.0 KiB
C++
#include "stdafx.h"
|
|
#include "stdafx.h"
|
|
#include "ArenaJoinSituationConcreter.h"
|
|
#include "ArenaJoinSituationChecker.h"
|
|
//#include "SGameMessageUI.h"
|
|
#include "SGameLocalPlayer.h"
|
|
#include "SGameManager.h"
|
|
#include "SGameInterface.h"
|
|
#include "SGameSystem.h"
|
|
#include "SGameWorld.h"
|
|
#include "CommonUtil.h"
|
|
#include "SStringDB.h"
|
|
#include "SGame.h"
|
|
//#include "Util.h"
|
|
extern SGameSystem * g_pCurrentGameSystem;
|
|
|
|
cArenaJoinSituationChecker::cArenaJoinSituationChecker()
|
|
{
|
|
createConcreters();
|
|
}
|
|
|
|
cArenaJoinSituationChecker::~cArenaJoinSituationChecker()
|
|
{
|
|
deleteConcreters();
|
|
}
|
|
|
|
void cArenaJoinSituationChecker::createConcreters()
|
|
{
|
|
for (int situation = 0; situation < SITUATION_MAX; ++situation)
|
|
m_situationConcreter[situation] = createConcreter(situation);
|
|
}
|
|
|
|
cSituationConcreter* cArenaJoinSituationChecker::createConcreter(int situation)
|
|
{
|
|
switch (situation)
|
|
{
|
|
case SITUATION_NONE: return new cSituationConcreterNone;
|
|
case SITUATION_DEATH: return new cSituationConcreterDeath;
|
|
case SITUATION_TRADE: return new cSituationConcreterTrade;
|
|
case SITUATION_SIEGE_PLAYING: return new cSituationConcreterSiegePlaying;
|
|
case SITUATION_INSTANCE_PLAYING: return new cSituationConcreterInstancePlaying;
|
|
case SITUATION_PENALTY: return new cSituationConcreterPenalty;
|
|
case SITUATION_PARTY_PLAYING: return new cSituationConcreterPartyPlaying;
|
|
case SITUATION_NORMAL_PARTY_PLAYING: return new cSituationConcreterNormalPartyPlaying;
|
|
case SITUATION_ARENA_PLAYING: return new cSituationConcreterArenaPlaying;
|
|
case SITUATION_ARENA_WAITING: return new cSituationConcreterArenaWaiting;
|
|
case SITUATION_ARENA_WAITING_COUNT: return new cSituationConcreterArenaWaitingCount;
|
|
default: return NULL;
|
|
}
|
|
|
|
assert(0 && "failed create concreter");
|
|
}
|
|
|
|
void cArenaJoinSituationChecker::deleteConcreters()
|
|
{
|
|
for (int i = 0; i < SITUATION_MAX; ++i)
|
|
SAFE_DELETE(m_situationConcreter[i]);
|
|
}
|
|
|
|
bool cArenaJoinSituationChecker::isValidSituation(sArenaJoinSituationCondition const& situationCondition)
|
|
{
|
|
SGameWorld* gameWorld = dynamicCast<SGameWorld*>(g_pCurrentGameSystem->GetGame());
|
|
SGameLocalPlayer* localPlayer = dynamicCast<SGameLocalPlayer*>(g_pCurrentGameSystem->GetLocalPlayer());
|
|
/// localPlayer의 NULL체크는 concreter에서 각자 한다,
|
|
/// 왜냐면 localPlayer가 null일 때도 출력이 되야 되는 상황이 있기 때문이다.
|
|
//if (!localPlayer)
|
|
// return true;
|
|
|
|
sArenaJoinSituationCondition::cit_situation it = situationCondition.m_list.begin();
|
|
for (; it != situationCondition.m_list.end(); ++it)
|
|
{
|
|
int situation = it->m_situation;
|
|
if (!isValidSituation(situation))
|
|
continue;
|
|
if (!m_situationConcreter[situation])
|
|
continue;
|
|
|
|
if (m_situationConcreter[situation]->isSatisfaction(gameWorld, localPlayer))
|
|
{
|
|
setNotification(situation, it->m_string.c_str(), situationCondition.m_notificationWays, it->m_extractTag);
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
bool cArenaJoinSituationChecker::isValidSituation(int situation) const
|
|
{
|
|
if (SITUATION_NONE > situation)
|
|
return false;
|
|
if (SITUATION_MAX <= situation)
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
void cArenaJoinSituationChecker::setNotification(int situation, char const* string, int notificationWay, bool extractTag)
|
|
{
|
|
if (WAY_NOTIFICATION_WND & notificationWay)
|
|
{
|
|
g_pCurrentGameSystem->GetGame()->SendGameInterfaceMsg(&SIMSG_UI_SEND_DATA(SIMSG_TOGGLE_UIWINDOW::UIWINDOW_NOTIFICATION, "pushNotification", string));
|
|
}
|
|
if (WAY_CENTER_NOTICE & notificationWay)
|
|
{
|
|
g_pCurrentGameSystem->GetGame()->SendGameInterfaceMsg(&SIMSG_ANNOUNCE(string));
|
|
}
|
|
if (WAY_MSG_BOX & notificationWay)
|
|
{
|
|
g_pCurrentGameSystem->GetGame()->GetGameManager()->GetGameInterface()->OpenMessageBox(SIMSG_REQ_OPEN_MSGBOX::MSGBOX_OK, SIMSG_REQ_OPEN_MSGBOX::MSGBOX_GENERAL, 0, -1, string);
|
|
}
|
|
|
|
std::string strText;
|
|
// 2012. 6. 22 - marine 스트링에서 태그만 걷어서 출력
|
|
if (extractTag)
|
|
{
|
|
std::string strToken;
|
|
extractTokenAndText( string, strToken, strText );
|
|
}
|
|
else
|
|
{
|
|
strText = string;
|
|
}
|
|
g_pCurrentGameSystem->GetGame()->AddChatMessage(strText.c_str());
|
|
}
|