// 
// ClearState()
//
// clears the internal state of all conventions in use
//
void CConventionSet::ClearState()
{
	if (m_listConventions.IsEmpty()) 
		return;
	//
	POSITION pos = m_listConventions.GetHeadPosition();
	CConvention* pConvention = m_listConventions.GetNext(pos);
	while(pConvention)
	{
		pConvention->ClearState();
		pConvention = m_listConventions.GetNext(pos);
	}
}
//
// IsConventionEnabled()
//
// replaces the old PLAYING_XXX macros to test whether 
// a convention is being played in this convention set
//
BOOL CConventionSet::IsConventionEnabled(int nConventionID) const
{
	// look through the list of conventions and see if it's in the list
	// this is slower than, say, a switch/case expression to check
	// individual member variables (i.e., case tbBlackwood: return m_bBlackwood),
	// but is simpler and doesn't need to change when new conventions
	// are added
	if (m_listConventions.IsEmpty()) return FALSE;

	// look in the conventions list
	POSITION pos = m_listConventions.GetHeadPosition();
	CConvention* pConvention = m_listConventions.GetNext(pos);
	while(pConvention)
	{
//		ASSERT(pConvention->GetID() != -1);	// make sure it's initialized
		if (pConvention->GetID() == nConventionID)
			return TRUE;
		if (pos)
			pConvention = m_listConventions.GetNext(pos);
		else
			pConvention = NULL;
	}

	// see if it's a convention that's currently not implemented in the list
	switch(nConventionID)
	{
		case tid5CardMajors:
			return m_bFiveCardMajors;
		case tidLimitRaises:
			return m_bLimitRaises;
		case tidWeakJumpOvercalls:
			return m_bWeakJumpOvercalls;
		case tb4SuitTransfers:
			return m_b4SuitTransfers;
		case tidOgust:
			return m_bOgust;
		case tbStructuredReverses:
			return m_bStructuredReverses;
		case tb3LevelTakeouts:
			return m_b3LevelTakeouts;
		//
//		case tbGerber:
//			return m_bGerber;
	}
	

	//
	return FALSE;
}
//
// ApplyConventionTests()
//
BOOL CConventionSet::ApplyConventionTests(const CPlayer& player, CHandHoldings& hand, CCardLocation& cardLocation, CGuessedHandHoldings** ppGuessedHands, CBidEngine& bidState, CPlayerStatusDialog& status) 
{
	if (m_listConventions.IsEmpty()) 
		return FALSE;
	//
	POSITION pos = m_listConventions.GetHeadPosition();
	CConvention* pConvention = m_listConventions.GetNext(pos);
	while(pConvention)
	{
		if (pConvention->ApplyTest(player, *this, hand, cardLocation, ppGuessedHands, bidState, status))
			return TRUE;
		if (pos)
			pConvention = m_listConventions.GetNext(pos);
		else
			pConvention = NULL;
	}
	//
	return FALSE;
}
//
// ApplyConventionTests()
//
BOOL CConventionSet::ApplyConventionTests(const CPlayer& player, CHandHoldings& hand, CCardLocation& cardLocation, CGuessedHandHoldings** ppGuessedHands, CBidEngine& bidState, CPlayerStatusDialog& status) 
{
	if (m_listConventions.IsEmpty()) 
		return FALSE;
	//
	POSITION pos = m_listConventions.GetHeadPosition();
	CConvention* pConvention = m_listConventions.GetNext(pos);
	while(pConvention)
	{
		if (pConvention->ApplyTest(player, *this, hand, cardLocation, ppGuessedHands, bidState, status)) { // NCR-SCU
#ifdef _DEBUG
			CEasyBDoc::m_pDoc->AddSCU(pConvention->m_nID); // NCR-SCU add this convention's id
#endif
			return TRUE;
		} // end NCR-SCU
		if (pos)
			pConvention = m_listConventions.GetNext(pos);
		else
			pConvention = NULL;
	}
	//
	return FALSE;
}