예제 #1
0
// 입찰 취소 
void	CGuildCombat1to1Mng::SetCancelTenderGuild( CUser* pUser )
{
	if( m_nState != GC1TO1_CLOSE )
	{
		pUser->AddDiagText( prj.GetText( TID_GAME_GUILDCOMBAT1TO1_NOTENDER ) );
		return;
	}

	// 길드마스터만 입찰 취소 가능
	if( !IsGuildMaster( pUser ) )
	{
		pUser->AddDefinedText( TID_GAME_GUILDCOMBAT1TO1_NOTMASTER );
		return;
	}

	CGuild* pGuild = pUser->GetGuild();
	if( pGuild )
	{
		for( vector<__GC1TO1TENDER>::iterator it=m_vecTenderGuild.begin(); it!=m_vecTenderGuild.end(); it++ )
		{
			if( (*it).ulGuildId == pGuild->GetGuildId() )
			{
				int nReturnGold = (int)( (*it).nPenya * ( (float)m_nCancelReturnRate / 100 ) );
				//인벤 꽉 찼을때 예외처리 해야함..
				int nTotal = pUser->GetGold() + nReturnGold;
				if( nReturnGold > 0 && nTotal < 0 )	// overflow
				{
					pUser->AddDefinedText( TID_GAME_LACKSPACE );
					return;
				}

				pUser->AddGold( nReturnGold );
			
				g_dpDBClient.SendGC1to1Tender( 'U', (*it).ulGuildId, (*it).nPenya, 'C' );
				m_vecTenderGuild.erase( it );
				
				CString strTemp;
				strTemp.Format( prj.GetText( TID_GAME_GUILDCOMBAT1TO1_CANCELTENDER ), nReturnGold );
				pUser->AddDiagText( strTemp );

				// 로그 남김(아이템로그)
				LogItemInfo aLogItem;
				aLogItem.Action = "9";
				aLogItem.SendName = pUser->GetName();
				aLogItem.RecvName = "GUILDCOMBAT1TO1_CANCELRETURN";
				aLogItem.WorldId = pUser->GetWorld()->GetID();
				//aLogItem.ItemName = "SEED";
				_stprintf( aLogItem.szItemName, "%d", II_GOLD_SEED1 );
				aLogItem.Gold = pUser->GetGold() - nReturnGold;
				aLogItem.Gold2 = pUser->GetGold();
				aLogItem.Gold_1 = nReturnGold;
				g_DPSrvr.OnLogItem( aLogItem );
				break;
			}
		}
	}
}
예제 #2
0
// 현재 대전장의 대전이 모두 끝나고 텔레포트전 대기 시간...
void	CGuildCombat1to1::GuildCombat1to1CloseWait()
{
	ClearTime();
	m_nState = GC1TO1WAR_CLOSEWAIT;
	m_nWaitTime = (int)( g_GuildCombat1to1Mng.m_Lua.GetGlobalNumber( "WarCloseWaitTime" ) );
	m_dwTime = GetTickCount();
	SendNowStateAllPlayer();

	// 승리 길드 판별
	int nWinIndex = NULL_ID;
	if( m_vecTenderGuild[m_nIndex[0]].nWinCount > m_vecTenderGuild[m_nIndex[1]].nWinCount )
		nWinIndex = m_nIndex[0];
	else if( m_vecTenderGuild[m_nIndex[0]].nWinCount < m_vecTenderGuild[m_nIndex[1]].nWinCount )
		nWinIndex = m_nIndex[1];
	
	// 길드 승패 메세지 출력(승리 길드는 칩 추가 지급)
	CUser* pUser = NULL;
	for( int i=0; i<2; i++ )
	{
		for( int j=0; j<(int)( m_vecTenderGuild[m_nIndex[i]].vecMemberId.size() ); j++ )
		{
			pUser = (CUser*)prj.GetUserByID( m_vecTenderGuild[m_nIndex[i]].vecMemberId[j] );
			if( IsPossibleUser( pUser ) )
			{
				if( m_nIndex[i] == nWinIndex )	// 승리 길드
				{
					SetWinChip( pUser, NULL, FALSE, FALSE );
					pUser->AddDefinedCaption( TRUE, TID_GAME_GUILDCOMBAT1TO1_WARGUILDWIN, "" );
					pUser->AddDefinedText( TID_GAME_GUILDCOMBAT1TO1_WARGUILDWINCHIP, "%d", GetChipNum() );
				}
				else if( nWinIndex == NULL_ID ) // 비김
				{
					SetWinChip( pUser, NULL, TRUE, FALSE );
					pUser->AddDefinedCaption( TRUE, TID_GAME_GUILDCOMBAT1TO1_WARGUILDDRAW, "" );
				}
				else							// 패배 길드
				{
					SetWinChip( NULL, pUser, FALSE, FALSE );
					pUser->AddDefinedCaption( TRUE, TID_GAME_GUILDCOMBAT1TO1_WARGUILDLOST, "" );
				}

				SendNowState( pUser );
			}
		}
	}

	g_dpDBClient.SendGC1to1Tender( 'U', m_vecTenderGuild[m_nIndex[0]].ulGuildId, m_vecTenderGuild[m_nIndex[0]].nPenya, 'E' );
	g_dpDBClient.SendGC1to1Tender( 'U', m_vecTenderGuild[m_nIndex[1]].ulGuildId, m_vecTenderGuild[m_nIndex[1]].nPenya, 'E' );
	g_dpDBClient.SendGC1to1WarGuild( m_vecTenderGuild[m_nIndex[0]].dwWorldId, 0, 0, 'E' );
}
예제 #3
0
// 입찰 및 입찰금 순서로 정렬
void	CGuildCombat1to1Mng::SetTenderGuild( CUser* pUser, int nPenya )
{
	if( !g_eLocal.GetState( EVE_GUILDCOMBAT1TO1 ) )
		return;
	
	if( m_nState != GC1TO1_CLOSE )
	{
		pUser->AddDiagText( prj.GetText( TID_GAME_GUILDCOMBAT1TO1_NOTENDER ) );
		return;
	}
	
	// 길드대전에 입찰한 길드는 입찰할 수 없다.
	if( IsGCTenderGuild( pUser ) )
	{
		pUser->AddDefinedText( TID_GAME_GUILDCOMBAT1TO1_ISGCTENDER );
		return;
	}
	
	// 길드마스터만 입찰 가능
	if( !IsGuildMaster( pUser ) )
	{
		pUser->AddDefinedText( TID_GAME_GUILDCOMBAT1TO1_NOTMASTER );
		return;
	}

	// 참가할 수 있는 최소 길드레벨 검사...
	if( pUser->GetGuild()->m_nLevel < m_nGuildLevel )
	{
		pUser->AddDefinedText( TID_GAME_GUILDCOMBAT1TO1_LOWGUILDLEVEL, "%d", m_nGuildLevel );
		return;
	}
	
	// 최소 입찰 페냐 보다 많아야 한다.
	if( nPenya < m_nJoinPenya )
	{
		pUser->AddDefinedText( TID_GAME_GUILDCOMBAT1TO1_LIMIT_MIN );
		return;
	}

	// 로그 남길 준비(아이템로그)
	LogItemInfo aLogItem;
	aLogItem.Action = "9";
	aLogItem.SendName = pUser->GetName();
	aLogItem.RecvName = "GUILDCOMBAT1TO1";
	aLogItem.WorldId = pUser->GetWorld()->GetID();
	//aLogItem.ItemName = "SEED";
	_stprintf( aLogItem.szItemName, "%d", II_GOLD_SEED1 );
	
	int nIndex = GetTenderGuildIndexByUser( pUser );
	if( nIndex != NULL_ID ) // 이미 입찰한 길드는 더많은 금액으로 입찰해야 한다.
	{
		if( m_vecTenderGuild[nIndex].nPenya < nPenya )
		{
			if( (DWORD)( nPenya ) > (DWORD)(pUser->GetGold() + m_vecTenderGuild[nIndex].nPenya) )
			{
				pUser->AddDefinedText( TID_GAME_LACKMONEY );	// 페냐가 부족하다.
				return;
			}

			pUser->AddGold( m_vecTenderGuild[nIndex].nPenya - nPenya );
			CString strTemp;
			strTemp.Format( prj.GetText( TID_GAME_GUILDCOMBAT1TO1_MORETENDER ), nPenya - m_vecTenderGuild[nIndex].nPenya, nPenya );
			pUser->AddDiagText( strTemp );
			m_vecTenderGuild[nIndex].nPenya = nPenya;
			// 로그 남김
			aLogItem.Gold = pUser->GetGold() + (nPenya - m_vecTenderGuild[nIndex].nPenya) ;
			aLogItem.Gold2 = pUser->GetGold();
			aLogItem.Gold_1 = m_vecTenderGuild[nIndex].nPenya - nPenya;
			g_DPSrvr.OnLogItem( aLogItem );
			g_dpDBClient.SendGC1to1Tender( 'U', pUser->m_idGuild, nPenya, 'T' );
		}
		else // 기존보다 더 많은 페냐 입찰 요구
		{
			pUser->AddDefinedText( TID_GAME_GUILDCOMBAT1TO1_MORE_CURRENT_REQUEST );
			return;
		}
	}
	else	// 처음 입찰하는 길드이면..
	{
		if( nPenya > pUser->GetGold() )	// 페냐 부족
		{
			pUser->AddDefinedText( TID_GAME_LACKMONEY );
			return;
		}

		__GC1TO1TENDER	TenderGuild;
		TenderGuild.ulGuildId = pUser->m_idGuild;
		TenderGuild.nPenya = nPenya;
		m_vecTenderGuild.push_back( TenderGuild );
		pUser->AddGold( -nPenya );
		CString strTemp;
		strTemp.Format( prj.GetText( TID_GAME_GUILDCOMBAT1TO1_TENDERPENYA ), nPenya );
		pUser->AddDiagText( strTemp );
		// 로그 남김
		aLogItem.Gold = pUser->GetGold() + nPenya;
		aLogItem.Gold2 = pUser->GetGold();
		aLogItem.Gold_1 = -nPenya;
		g_DPSrvr.OnLogItem( aLogItem );
		g_dpDBClient.SendGC1to1Tender( 'I', pUser->m_idGuild, nPenya, 'T' );
	}

	// 입찰금 순서로 정렬
	if( m_vecTenderGuild.size() < 2 )
		return;
	for( int i=0; i<(int)( m_vecTenderGuild.size()-1 ); i++ )
	{
		for( int j=0; j<(int)( m_vecTenderGuild.size()-i-1 ); j++ )
		{
			if( m_vecTenderGuild[j].nPenya < m_vecTenderGuild[j+1].nPenya )
			{
				__GC1TO1TENDER temp = m_vecTenderGuild[j];
				m_vecTenderGuild[j] = m_vecTenderGuild[j+1];
				m_vecTenderGuild[j+1] = temp;
			}
		}
	}
}
예제 #4
0
// 1대1 길드대전 오픈
void	CGuildCombat1to1Mng::GuildCombat1to1Open( BOOL bGMText )
{
	if( !g_eLocal.GetState( EVE_GUILDCOMBAT1TO1 ) )
		return;
	
	vector<__GC1TO1TENDER>::iterator it;
	if( !bGMText )
	{
		for( it=m_vecTenderFailGuild.begin(); it!=m_vecTenderFailGuild.end(); it++ )
		{
			// 이전 1:1길드대전에 입찰 실패 길드가 신청금을 수령하지 않았을 경우
			g_dpDBClient.SendGC1to1Tender( 'U', (*it).ulGuildId, (*it).nPenya, 'N' );
		}
		m_vecTenderFailGuild.clear();
	}
	
	// 신청한  길드수가 최소 참여 길드수보다 적을 때
	if( (int)( m_vecTenderGuild.size() ) < m_nMinJoinGuild )
	{
		// 1대1 길드대전 취소 및 연장 처리
		CString strTemp;
		strTemp.Format( prj.GetText( TID_GAME_GUILDCOMBAT1TO1_NOGAME ), m_nMinJoinGuild );
		g_DPCoreClient.SendCaption( strTemp );	
		ClearTime();
		m_nState = GC1TO1_CLOSE;
		return;
	}
	
	// 1:1길드대전 오픈 메세지..
	g_DPCoreClient.SendCaption( prj.GetText( TID_GAME_GUILDCOMBAT1TO1_OPEN ) );
	g_DPCoreClient.SendCaption( prj.GetText( TID_GAME_GUILDCOMBAT1TO1_LINEUP ) );
	
	// 참가자 구성 시간 설정
	m_nState = GC1TO1_OPEN;
	m_nWaitTime = (int)m_Lua.GetGlobalNumber( "MemberLineUpTime" );
	m_dwTime = GetTickCount();	

	// 입찰 순위에 들지 못한 길드 제거
	int nCount = 0;
	for( it=m_vecTenderGuild.begin(); it!=m_vecTenderGuild.end(); )
	{
		nCount++;
		if( nCount <= m_nMaxJoinGuild )
			it++;
		else // 입찰 순위에서 밀려난 경우
		{
			CGuild* pGuild = g_GuildMng.GetGuild( (*it).ulGuildId );
			if( pGuild )
			{
				CUser* pUser = (CUser*)prj.GetUserByID( pGuild->m_idMaster );
				if( IsValidObj( pUser ) )
					pUser->AddDefinedText( TID_GAME_GUILDCOMBAT1TO1_FAILTENDER );
			}
			
			g_dpDBClient.SendGC1to1Tender( 'U', (*it).ulGuildId, (*it).nPenya, 'F' );
			m_vecTenderFailGuild.push_back( (*it) );
			it = m_vecTenderGuild.erase( it );
		}
	}		

	// 입찰 순위에는 들어갔지만 상대 길드가 없는 경우(홀수)
	if( m_vecTenderGuild.size() % 2 != 0 )
	{
		it = m_vecTenderGuild.end(); it--;	// 마지막 순위		// 노트 :  rbegin()을 사용하시오.
		CGuild* pGuild = g_GuildMng.GetGuild( (*it).ulGuildId );
		if( pGuild )
		{
			CUser* pUser = (CUser*)prj.GetUserByID( pGuild->m_idMaster );
			if( IsValidObj( pUser ) )
				pUser->AddDefinedText( TID_GAME_GUILDCOMBAT1TO1_FAILTENDER );
		}

		g_dpDBClient.SendGC1to1Tender( 'U', (*it).ulGuildId, (*it).nPenya, 'F' );
		m_vecTenderFailGuild.push_back( (*it) );
		m_vecTenderGuild.erase( it );
	}

	// 출전 가능한 길드의 모든 길드원에게 OPEN STATE 알림(길드 마스터는 참가자 구성 시간 출력)
	for( it=m_vecTenderGuild.begin(); it!=m_vecTenderGuild.end(); it++ )
	{
		CGuild* pGuild = g_GuildMng.GetGuild( (*it).ulGuildId );
		if( pGuild )
		{
			for( map<u_long, CGuildMember*>::iterator it2=pGuild->m_mapPMember.begin(); it2!=pGuild->m_mapPMember.end(); it2++ )
			{
				CUser* pUser = (CUser*)prj.GetUserByID( it2->first );
				if( IsValidObj( pUser ) )
					SendNowState( pUser );
			}
		}
	}

	g_dpDBClient.SendGC1to1StateToDBSrvr();	// 1:1길드대전이 오픈되었다고 DBServer에 알림
}