Ejemplo n.º 1
0
//将对 //就是 碰的牌 和 胡的牌 必须是二,五,八的牌就叫将对
bool CGameLogic::IsJiangDui( const tagAnalyseItem *pAnalyseItem )
{
	//是否大对子
	if( !IsPengPeng(pAnalyseItem) ) return false;

	//检查牌眼
	BYTE cbCardValue = pAnalyseItem->cbCardEye&MASK_VALUE;
	if( cbCardValue != 2 && cbCardValue != 5 && cbCardValue != 8 ) return false;

	for( BYTE i = 0; i < CountArray(pAnalyseItem->cbWeaveKind); i++ )
	{
		if( pAnalyseItem->cbWeaveKind[i]&(WIK_LEFT|WIK_CENTER|WIK_RIGHT) )
		{
			BYTE j = 0;
			for( j = 0; j < 3; j++ )
			{
				cbCardValue = pAnalyseItem->cbCardData[i][j]&MASK_VALUE;
				if( cbCardValue == 2 || cbCardValue == 5 || cbCardValue == 8 ) break;
			}
			if( j == 3 ) return false;
		}
		else
		{
			cbCardValue = pAnalyseItem->cbCenterCard[i]&MASK_VALUE;
			if( cbCardValue != 2 && cbCardValue != 5 && cbCardValue != 8 ) return false;
		}
	}
	return true;
}
Ejemplo n.º 2
0
//吃胡分析
BYTE CGameLogic::AnalyseChiHuCard(const BYTE cbCardIndex[MAX_INDEX], const tagWeaveItem WeaveItem[], BYTE cbWeaveCount, BYTE cbCurrentCard, CChiHuRight &ChiHuRight)
{

	//变量定义
	BYTE cbChiHuKind=WIK_NULL;
	CAnalyseItemArray AnalyseItemArray;

	//设置变量
	AnalyseItemArray.RemoveAll();
	ChiHuRight.SetEmpty();

	//构造扑克
	BYTE cbCardIndexTemp[MAX_INDEX];
	CopyMemory(cbCardIndexTemp,cbCardIndex,sizeof(cbCardIndexTemp));


	//构造扑克
	BYTE cbCardIndexTemp2[MAX_INDEX];
	ZeroMemory(cbCardIndexTemp2,sizeof(cbCardIndexTemp2));
	m_cbGenCount = 0;
	BYTE cbFanShu = 0;
	CChiHuRight tmpChiHuRight;
	

	//cbCurrentCard一定不为0			!!!!!!!!!
	ASSERT( cbCurrentCard != 0 );
	if( cbCurrentCard == 0 ) return WIK_NULL;

	/*
	//	特殊番型
	*/

	//七小对牌
	if( IsQiXiaoDui(cbCardIndex,WeaveItem,cbWeaveCount,cbCurrentCard) ) 
	{
		ChiHuRight |= CHR_QI_XIAO_DUI;
	}

	if( !ChiHuRight.IsEmpty() )
		cbChiHuKind = WIK_CHI_HU;

	//插入扑克
	if (cbCurrentCard!=0)
		cbCardIndexTemp[SwitchToCardIndex(cbCurrentCard)]++;

	//必须缺一门
	if( IsHuaZhu(cbCardIndexTemp,WeaveItem,cbWeaveCount) )
	{
		return WIK_NULL;
	}



	//胡牌分析
 if((ChiHuRight&CHR_QI_XIAO_DUI).IsEmpty())
 {
		//分析扑克
	AnalyseCard(cbCardIndexTemp,WeaveItem,cbWeaveCount,AnalyseItemArray);
	if (AnalyseItemArray.GetCount()>0)
	{
		cbChiHuKind = WIK_CHI_HU;
	
		//牌型分析
		for (INT_PTR i=0;i<AnalyseItemArray.GetCount();i++)
		{
			//变量定义
			tagAnalyseItem * pAnalyseItem=&AnalyseItemArray[i];


			ZeroMemory(cbCardIndexTemp2,sizeof(cbCardIndexTemp2));
			cbCardIndexTemp2[SwitchToCardIndex(pAnalyseItem->cbCardEye)] = 2;
			BYTE cbTmpFanShu = 0;
			tmpChiHuRight.SetEmpty();
			for (BYTE k =0;k<4;k++)
			{

				if (pAnalyseItem->cbWeaveKind[k] == WIK_LEFT)
				{
					BYTE cbTmpIndex =  SwitchToCardIndex(pAnalyseItem->cbCenterCard[k]);
					for (BYTE t = 0;t < 3;t ++)
					{
						cbCardIndexTemp2[cbTmpIndex]++;
						cbTmpIndex++;
					}
					
				}else if (pAnalyseItem->cbWeaveKind[k] == WIK_PENG || pAnalyseItem->cbWeaveKind[k] == WIK_TIE_PAI)
				{
					BYTE cbTmpIndex =  SwitchToCardIndex(pAnalyseItem->cbCenterCard[k]);
					for (BYTE t = 0;t < 3;t ++)
					{
						cbCardIndexTemp2[cbTmpIndex]++; 
					}
				}else if (pAnalyseItem->cbWeaveKind[k] == WIK_GANG)
				{
					BYTE cbTmpIndex =  SwitchToCardIndex(pAnalyseItem->cbCenterCard[k]);
					for (BYTE t = 0;t < 4;t ++)
					{
						cbCardIndexTemp2[cbTmpIndex]++; 
					}

				}

			}


	//  分析根
		BYTE tmpCount = 0;
		for (BYTE k = 0;k<MAX_INDEX;k++)
		{
			// 分析碰贴牌,在手上牌中查找是否有根
			if (cbCardIndexTemp2[k] == 4)
			{
				tmpCount++;
				cbTmpFanShu++;
			}
	
		}
	
		// 判断是否有3个牌精
		if (HaveThreePaiJin(cbCardIndexTemp2,WeaveItem,cbWeaveCount))
		{
			tmpChiHuRight |= CHR_WITH_THREE_PAI_JIN;
			cbTmpFanShu = (cbTmpFanShu == 0)?2:(cbTmpFanShu+=1);
			
		}


			/*
			//	判断番型
			*/
			//碰碰和
			if( IsPengPeng(pAnalyseItem) ) 
			{
				tmpChiHuRight |= CHR_DA_DUI_ZI;
				cbTmpFanShu+=3;
			}



			if(cbTmpFanShu>cbFanShu)
			{
				cbFanShu = cbTmpFanShu;
				DWORD wRightData =0;
				tmpChiHuRight.GetRightData(&wRightData, MAX_RIGHT_COUNT);
				ChiHuRight.SetRightData(&wRightData, MAX_RIGHT_COUNT);
				m_cbGenCount = tmpCount;

			}
	
#if 0

			//带幺
			if( IsDaiYao(pAnalyseItem) )
				ChiHuRight |= CHR_DAI_YAO;
			//将对
			if( IsJiangDui(pAnalyseItem) )
				ChiHuRight |= CHR_JIANG_DUI;
#endif 
		}
	}
 }
	


	if(!(ChiHuRight&CHR_QI_XIAO_DUI).IsEmpty())
	{
		BYTE cbTingYongCardCount = cbCardIndexTemp[m_cbMagicIndex];
		BYTE cbOneCount = 0,cbThreeCount = 0;

		ChiHuRight &=~CHR_DA_DUI_ZI;
		for(BYTE k = 0;k<MAX_INDEX-7;k++)
		{

			if( k == m_cbMagicIndex ) continue;

			if(cbCardIndexTemp[k] == 4)
			{
				m_cbGenCount++;
			}

			BYTE cbCardCount=cbCardIndexTemp[k];
			if(cbCardCount == 1)
			{
				cbOneCount++; 
			}else if(cbCardCount == 3)
			{
				cbThreeCount++; 
			}


		}


		switch (cbTingYongCardCount)
		{
		case 1:
			if (cbThreeCount == 1)
				m_cbGenCount++;
			break;
		case 2:
			if (cbThreeCount == 2 && cbOneCount == 0)
				m_cbGenCount+=2;
			else if (cbThreeCount == 1 && cbOneCount == 1)
				m_cbGenCount++;

			break;
		case 3:
			if (cbThreeCount == 1 && cbOneCount == 0)
				m_cbGenCount+=2;
			else if (cbThreeCount == 3 && cbOneCount == 0)
				m_cbGenCount+=cbThreeCount;
			else if ( cbThreeCount == 2 && cbOneCount == 1)
				m_cbGenCount+=cbThreeCount;
			else if (cbThreeCount == 1 && cbOneCount == 2)
				m_cbGenCount+=cbThreeCount;

			break;
		case 4:
			if (cbThreeCount == 2 && cbOneCount == 0)
 				m_cbGenCount+=3;
			else if (cbThreeCount == 1 && cbOneCount == 1)
				m_cbGenCount+=2;
			else if ( cbThreeCount == 2 && cbOneCount == 2)
				m_cbGenCount+=cbThreeCount;
			else if (cbThreeCount == 1 && cbOneCount == 3)
				m_cbGenCount+=cbThreeCount;

			break;
		default:
			break;
		}

	}
	

	if( cbChiHuKind == WIK_CHI_HU )
	{
		//清一色牌
		if( IsQingYiSe(cbCardIndex,WeaveItem,cbWeaveCount,cbCurrentCard) )
		{
			ChiHuRight |= CHR_QING_YI_SE;
		}

		if (!HaveMagicCard(cbCardIndex,WeaveItem,cbWeaveCount) && IsMagicCard(cbCurrentCard)==false) // 缺听用
		{
			ChiHuRight |= CHR_WITHOUT_TING_YONG;

		}

		if (IsDaDanDiao(cbCardIndex,cbWeaveCount)) // 大单吊
  	    {
			ChiHuRight |= CHR_DA_DAN_DIAO;
		}



		switch(m_cbGenCount)
		{
			case 1:
				ChiHuRight|= CHR_GENG_COUNT_ONE;
				break;
			case 2:
				ChiHuRight|= CHR_GENG_COUNT_TWO;
				break;
			case 3:
				ChiHuRight|= CHR_GENG_COUNT_THREE;
				break;
			case 4:
				ChiHuRight|= CHR_GENG_COUNT_FOUR;
				break;
						
		}

		//素番
		if( cbChiHuKind == WIK_CHI_HU && ChiHuRight.IsEmpty() )
			ChiHuRight |= CHR_SHU_FAN;

	}

	return cbChiHuKind;
}
Ejemplo n.º 3
0
//吃胡分析
BYTE CGameLogic::AnalyseChiHuCard(const BYTE cbCardIndex[MAX_INDEX], const tagWeaveItem WeaveItem[], BYTE cbWeaveCount, BYTE cbCurrentCard, CChiHuRight &ChiHuRight)
{
	//变量定义
	BYTE cbChiHuKind=WIK_NULL;
	CAnalyseItemArray AnalyseItemArray;

	//设置变量
	AnalyseItemArray.RemoveAll();
	ChiHuRight.SetEmpty();

	//构造扑克
	BYTE cbCardIndexTemp[MAX_INDEX];
	CopyMemory(cbCardIndexTemp,cbCardIndex,sizeof(cbCardIndexTemp));

	//cbCurrentCard一定不为0			!!!!!!!!!
	ASSERT( cbCurrentCard != 0 );
	if( cbCurrentCard == 0 ) return WIK_NULL;

	/*
	//	特殊番型
	*/
	//七小对牌
	if( IsQiXiaoDui(cbCardIndex,WeaveItem,cbWeaveCount,cbCurrentCard) ) 
		ChiHuRight |= CHR_QI_XIAO_DUI;

	if( !ChiHuRight.IsEmpty() )
		cbChiHuKind = WIK_CHI_HU;

	//插入扑克
	if (cbCurrentCard!=0)
		cbCardIndexTemp[SwitchToCardIndex(cbCurrentCard)]++;

	//必须缺一门
	if( IsHuaZhu(cbCardIndexTemp,WeaveItem,cbWeaveCount) ) return WIK_NULL;

	//分析扑克
	AnalyseCard(cbCardIndexTemp,WeaveItem,cbWeaveCount,AnalyseItemArray);

	//胡牌分析
	if (AnalyseItemArray.GetCount()>0)
	{
		//
		cbChiHuKind = WIK_CHI_HU;

		//牌型分析
		for (INT_PTR i=0;i<AnalyseItemArray.GetCount();i++)
		{
			//变量定义
			tagAnalyseItem * pAnalyseItem=&AnalyseItemArray[i];

			/*
			//	判断番型
			*/
			//碰碰和
			if( IsPengPeng(pAnalyseItem) ) 
				ChiHuRight |= CHR_DA_DUI_ZI;
			//带幺
			if( IsDaiYao(pAnalyseItem) )
				ChiHuRight |= CHR_DAI_YAO;
			//将对
			if( IsJiangDui(pAnalyseItem) )
				ChiHuRight |= CHR_JIANG_DUI;
		}
	}

	//素番
	if( cbChiHuKind == WIK_CHI_HU && ChiHuRight.IsEmpty() )
		ChiHuRight |= CHR_SHU_FAN;

	if( cbChiHuKind == WIK_CHI_HU )
	{
		//清一色牌
		if( IsQingYiSe(cbCardIndex,WeaveItem,cbWeaveCount,cbCurrentCard) )
			ChiHuRight |= CHR_QING_YI_SE;
	}

	return cbChiHuKind;
}