Example #1
0
//是否同花顺
bool CGameLogic::IsTongHuaShun(BYTE cbCardData[], BYTE cbCardCount)
{
	//数目判断
	if (cbCardCount!=5) return false;
	
	//变量定义
	BYTE bFirstColor=GetCardColor(cbCardData[0]);
	BYTE bFirstValue=GetCardLogicValue(cbCardData[0]);

	//特殊处理
	if (bFirstValue==15)
	{
		for (BYTE i=1;i<cbCardCount;i++)
		{
			BYTE cbLogicValue=GetCardLogicValue(cbCardData[i]);
			if (GetCardColor(cbCardData[i])!=bFirstColor) return false;
			if ((bFirstValue!=(cbLogicValue+i))&&(bFirstValue!=(cbLogicValue+i+8))) return false;
		}

		return true;
	}

	//分析处理
	for (BYTE i=1;i<cbCardCount;i++)
	{
		if (GetCardColor(cbCardData[i])!=bFirstColor) return false;
		if (bFirstValue!=(GetCardLogicValue(cbCardData[i])+i)) return false;
	}

	return true;
}
Example #2
0
//对比扑克
bool CGameLogic::CompareCard(BYTE cbFirstData[], BYTE cbNextData[], BYTE cbCardCount,BOOL FirstOX,BOOL NextOX)
{
    if(FirstOX!=NextOX)return (FirstOX>NextOX);

    //比较牛大小
    if(FirstOX==TRUE)
    {
        //获取点数
        BYTE cbNextType=GetCardType(cbNextData,cbCardCount);
        BYTE cbFirstType=GetCardType(cbFirstData,cbCardCount);

        //点数判断
        if (cbFirstType!=cbNextType) return (cbFirstType>cbNextType);
    }

    //排序大小
    BYTE bFirstTemp[MAX_COUNT],bNextTemp[MAX_COUNT];
    CopyMemory(bFirstTemp,cbFirstData,cbCardCount);
    CopyMemory(bNextTemp,cbNextData,cbCardCount);
    SortCardList(bFirstTemp,cbCardCount);
    SortCardList(bNextTemp,cbCardCount);

    //比较数值
    BYTE cbNextMaxValue=GetCardValue(bNextTemp[0]);
    BYTE cbFirstMaxValue=GetCardValue(bFirstTemp[0]);
    if(cbNextMaxValue!=cbFirstMaxValue)return cbFirstMaxValue>cbNextMaxValue;

    //比较颜色
    return GetCardColor(bFirstTemp[0]) > GetCardColor(bNextTemp[0]);

    return false;
}
Example #3
0
//对比扑克
bool CGameLogic::CompareCard(BYTE cbFirstCardData, BYTE cbNextCardData)
{
	//数值判断
	BYTE cbNextValue=GetCardLogicValue(cbNextCardData);
	BYTE cbFirstValue=GetCardLogicValue(cbFirstCardData);
	if (cbFirstValue!=cbNextValue) return (cbFirstValue>cbNextValue);

	//花色判断
	BYTE cbNextColor=GetCardColor(cbNextCardData);
	BYTE cbFirstColor=GetCardColor(cbFirstCardData);

	return (cbFirstColor>cbNextColor);
}
Example #4
0
//是否同花
bool CGameLogic::IsTongHua(BYTE cbCardData[], BYTE cbCardCount)
{
	//数目判断
	if (cbCardCount!=5) return false;
	
	//变量定义
	BYTE bFirstColor=GetCardColor(cbCardData[0]);

	//分析处理
	for (BYTE i=1;i<cbCardCount;i++)
	{
		if (GetCardColor(cbCardData[i])!=bFirstColor) return false;
	}

	return true;
}
Example #5
0
BYTE CGameLogic::GetCardNewValueEx(BYTE cbCardData)
{
	//扑克属性
	BYTE cbCardColor=GetCardColor(cbCardData);
	BYTE cbCardValue=GetCardValue(cbCardData);
	//转换数值
	if (cbCardColor!=0x04) return cbCardValue+10;
	return cbCardValue;
}
Example #6
0
//逻辑数值
BYTE CGameLogic::GetCardLogicValue(BYTE cbCardData)
{
	//扑克属性
	BYTE bCardColor=GetCardColor(cbCardData);
	BYTE bCardValue=GetCardValue(cbCardData);

	//转换数值
	return (bCardValue<=2)?(bCardValue+13):bCardValue;
}
Example #7
0
//点数的大小: 3>2>A>K>Q>J>10>9>8>7>6>5>4
//逻辑数值
BYTE CGameLogic::GetCardLogicValue(BYTE bCardData)
{
	//扑克属性
	BYTE bCardColor=GetCardColor(bCardData);
	BYTE bCardValue=GetCardValue(bCardData);

	//转换数值
	if (bCardColor==0x40) return bCardValue+15;
	return (bCardValue<=3)?(bCardValue+13):bCardValue;
}
Example #8
0
//逻辑数值
BYTE CGameLogic::GetCardLogicValue(BYTE cbCardData)
{
	//扑克属性
	BYTE cbCardColor=GetCardColor(cbCardData);
	BYTE cbCardValue=GetCardValue(cbCardData);

	//转换数值
	if (cbCardColor==0x40) return cbCardValue+2;
	return (cbCardValue<=2)?(cbCardValue+13):cbCardValue;
}
Example #9
0
//有效判断
bool CGameLogic::IsValidCard(BYTE cbCardData)
{
	//变量定义
	BYTE cbColor=GetCardColor(cbCardData);
	BYTE cbValue=GetCardValue(cbCardData);

	//有效判断
	if ((cbColor<=0x30)&&(cbValue>=0x01)&&(cbValue<=0x0D)) return true;

	return false;
}
Example #10
0
//逻辑数值
BYTE CGameLogic::GetCardLogicValue(BYTE cbCardData)
{
	//扑克属性
	BYTE cbCardColor=GetCardColor(cbCardData);
	BYTE cbCardValue=GetCardValue(cbCardData);

	//属性调整
	if (cbCardValue==10) cbCardValue=0;

	//转换数值
	return (cbCardValue*4)+(cbCardColor>>4);
}
Example #11
0
//逻辑大小
BYTE CGameLogic::GetCardLogicValue(BYTE cbCardData)
{
	BYTE cbValue=GetCardValue(cbCardData);

	//获取花色
	BYTE cbColor=GetCardColor(cbCardData);

	if(cbValue>10)
	{
		cbValue = 10;

	}
	if(cbColor==0x4)
	{
		return 11;
	}
	return cbValue;
}
Example #12
0
//排序等级
BYTE CGameLogic::GetCardSortOrder(BYTE cbCardData)
{
    //逻辑数值
    BYTE cbCardColor=GetCardColor(cbCardData);
    BYTE cbCardValue=GetCardValue(cbCardData);

    //鬼牌过滤
    if ((cbCardData==0x4E)||(cbCardData==0x4F))
    {
        BYTE cbSortValue=cbCardValue+11;
        return cbSortValue+m_cbSortRight[4];
    }

    //常主过滤
    if (cbCardValue==m_cbNTValue)
    {
        BYTE cbSortValue=(cbCardColor>>4)+15;
        if (cbCardColor==m_cbMainColor) cbSortValue=19;
        return cbSortValue+m_cbSortRight[4];
    }
Example #13
0
//获取牌型
BYTE CGameLogic::GetCardType(const BYTE cbCardData[], BYTE cbCardCount,BYTE *bcOutCadData )
{
	//合法判断
	ASSERT(5==cbCardCount);
	if (5!=cbCardCount) return CT_ERROR;

	//排序扑克
	BYTE cbCardDataSort[CARD_COUNT];
	CopyMemory(cbCardDataSort,cbCardData,sizeof(BYTE)*cbCardCount);
	SortCardList(cbCardDataSort,cbCardCount,ST_NEW);

	if(bcOutCadData != NULL)
	{
		CopyMemory(bcOutCadData,cbCardDataSort,cbCardCount);
	}



	int n = 0;
	BYTE bcMakeMax[5];
	memset(bcMakeMax,0,5);
	int iBigValue = 0;
	BYTE iSingleA[2];
	int iIndex = 0;
	bcMakeMax[0]= cbCardDataSort[n];

	int iGetTenCount = 0;

	for (int iten = 0;iten<cbCardCount;iten++)
	{
		if(GetCardLogicValue(cbCardDataSort[iten])==10||GetCardLogicValue(cbCardDataSort[iten])==11)
		{
			iGetTenCount++;

		}
	}
	if( iGetTenCount>=3)
	{
		if(GetCardColor(cbCardDataSort[0])==0x04&&GetCardColor(cbCardDataSort[1])==0x04)
		{
			if(bcOutCadData != NULL)
			{
				bcOutCadData[0] = cbCardDataSort[0];
				bcOutCadData[1] = cbCardDataSort[3];
				bcOutCadData[2] = cbCardDataSort[4];
				bcOutCadData[3] = cbCardDataSort[1];
				bcOutCadData[4] = cbCardDataSort[2];

			}
			return CT_SPECIAL_NIUNIUDW;

		}
		if(GetCardColor(cbCardDataSort[0])==0x04)
		{
			//大小王与最小的组合成牛 
			if(bcOutCadData != NULL)
			{
				bcOutCadData[0] = cbCardDataSort[0];
				bcOutCadData[1] = cbCardDataSort[3];
				bcOutCadData[2] = cbCardDataSort[4];
				bcOutCadData[3] = cbCardDataSort[1];
				bcOutCadData[4] = cbCardDataSort[2];
			}
			if(cbCardDataSort[0]==0x42)
				return CT_SPECIAL_NIUNIUDW;
			else
				return CT_SPECIAL_NIUNIUXW;
		}else
		{
			return RetType(GetCardLogicValue(cbCardDataSort[3])+GetCardLogicValue(cbCardDataSort[4]));
		}

	}
	if(iGetTenCount==2||(iGetTenCount==1&&GetCardColor(cbCardDataSort[0])==0x04))
	{

		if(GetCardColor(cbCardDataSort[0])==0x04&&GetCardColor(cbCardDataSort[1])==0x04)
		{
			if(bcOutCadData != NULL)
			{
				bcOutCadData[0] = cbCardDataSort[0];
				bcOutCadData[1] = cbCardDataSort[3];
				bcOutCadData[2] = cbCardDataSort[4];
				bcOutCadData[3] = cbCardDataSort[1];
				bcOutCadData[4] = cbCardDataSort[2];
			}
			return CT_SPECIAL_NIUNIUDW;
		}else
		{
			//如果有一张王 其他任意三张组合为10则是牛牛
			if(GetCardColor(cbCardDataSort[0])==0x04)
			{

				for ( n=1;n<cbCardCount;n++)
				{
					for (int j = 1;j<cbCardCount;j++)
					{
						if(j != n)
						{
							for (int w = 1;w<cbCardCount;w++)
							{
								if(w != n&&w!=j)
								{
									//如果剩余的四张中任意三张能组合位10的整数倍

									if((GetCardLogicValue(cbCardDataSort[n])+GetCardLogicValue(cbCardDataSort[j])+GetCardLogicValue(cbCardDataSort[w]))%10==0)
									{

										int add = 0;
										for (int y = 1;y<cbCardCount;y++)
										{
											if(y != n&&y!=j&&y!=w)
											{
												iSingleA[add] =cbCardDataSort[y]; 
												add++;

											}

										}
										if(bcOutCadData != NULL)
										{
											bcOutCadData[0] = cbCardDataSort[n];
											bcOutCadData[1] = cbCardDataSort[j];
											bcOutCadData[2] = cbCardDataSort[w];
											bcOutCadData[3] = cbCardDataSort[0];
											bcOutCadData[4] = iSingleA[0];
										}
										if(cbCardDataSort[0]==0x42)
											return CT_SPECIAL_NIUNIUDW;
										else
											return CT_SPECIAL_NIUNIUXW;


									}
								}
							}
						}
					}
				}
				//如果有一张王 其他任意三张组合不为10则 取两张点数最大的组合
				BYTE bcTmp[4];
				int iBig = 0;
				int in = 0;
				for ( in = 1;in<cbCardCount;in++)
				{
					for (int j = 1;j<cbCardCount;j++)
					{
						if(in != j)
						{
							BYTE bclogic = (GetCardLogicValue(cbCardDataSort[in])+GetCardLogicValue(cbCardDataSort[j]))%10;
							if(bclogic>iBig)
							{
								iBig = bclogic;
								int add = 0;
								bcTmp[0]=cbCardDataSort[in];
								bcTmp[1]=cbCardDataSort[j];
								for (int y = 1;y<cbCardCount;y++)
								{
									if(y != in&&y!=j)
									{
										iSingleA[add] =cbCardDataSort[y]; 
										add++;
									}

								}
								bcTmp[2]=iSingleA[0];
								bcTmp[3]=iSingleA[1];

							}

						}
					}   
				}

				if(bcOutCadData != NULL)
				{
					bcOutCadData[0] = cbCardDataSort[0];
					bcOutCadData[1] = bcTmp[2];
					bcOutCadData[2] = bcTmp[3];
					bcOutCadData[3] = bcTmp[0];
					bcOutCadData[4] = bcTmp[1];
				}
				if(iGetTenCount==1&&GetCardColor(cbCardDataSort[0])==0x04)
				{
					//下面还能组合 有两张为 10 也可以组合成牛牛

				}else
				{
					//如果没有则比较 完与最小组合最大点数和组合
					return RetType(GetCardLogicValue(bcTmp[0])+GetCardLogicValue(bcTmp[1]));
				}

			
			}else
			{
				if((GetCardLogicValue(cbCardDataSort[2])+GetCardLogicValue(cbCardDataSort[3])+GetCardLogicValue(cbCardDataSort[4]))%10==0)
				{
					if(bcOutCadData != NULL)
					{
						bcOutCadData[0] = cbCardDataSort[2];
						bcOutCadData[1] = cbCardDataSort[3];
						bcOutCadData[2] = cbCardDataSort[4];
						bcOutCadData[3] = cbCardDataSort[0];
						bcOutCadData[4] = cbCardDataSort[1];
					}
					return CT_SPECIAL_NIUNIU;
				}else
				{
					for ( n= 2;n<cbCardCount;n++)
					{
						for (int j = 2;j<cbCardCount;j++)
						{
							if(j != n)
							{
								if((GetCardLogicValue(cbCardDataSort[n])+GetCardLogicValue(cbCardDataSort[j]))%10==0)
								{
									int add = 0;
									for (int y = 2;y<cbCardCount;y++)
									{
										if(y != n&&y!=j)
										{
											iSingleA[add] =cbCardDataSort[y]; 
											add++;

										}
									}
									if(iBigValue<=iSingleA[0]%10)
									{
										iBigValue = GetCardLogicValue(iSingleA[0])%10;
										if(bcOutCadData != NULL)
										{
											bcOutCadData[0]= cbCardDataSort[0];
											bcOutCadData[1]= cbCardDataSort[n]; 
											bcOutCadData[2]= cbCardDataSort[j]; 
											bcOutCadData[3]= cbCardDataSort[1];
											bcOutCadData[4]= iSingleA[0]; 

										}

										if(iBigValue==0)
										{

											return CT_SPECIAL_NIUNIU;
										}
									}

								}
							}
						}
					}
					if(iBigValue != 0)
					{
						return RetType(iBigValue);
					}
				}
			}

		}

		iGetTenCount = 1;

	}
	//4个组合
	if(iGetTenCount==1)
	{
		if(GetCardColor(cbCardDataSort[0])==0x04)
		{
			for ( n= 1;n<cbCardCount;n++)
			{
				for (int j = 1;j<cbCardCount;j++)
				{
					if(j != n)
					{
						//任意两张组合成牛
						if((GetCardLogicValue(cbCardDataSort[n])+GetCardLogicValue(cbCardDataSort[j]))%10==0)
						{
							int add = 0;
							for (int y = 1;y<cbCardCount;y++)
							{
								if(y != n&&y!=j)
								{
									iSingleA[add] =cbCardDataSort[y]; 
									add++;

								}

							}

							if(bcOutCadData != NULL)
							{
								bcOutCadData[0] = cbCardDataSort[0];
								bcOutCadData[1] = iSingleA[0];
								bcOutCadData[2] = iSingleA[1];
								bcOutCadData[3] = cbCardDataSort[n];
								bcOutCadData[4] = cbCardDataSort[j];
							}
							if(cbCardDataSort[0]==0x42)
								return CT_SPECIAL_NIUNIUDW;
							else
								return CT_SPECIAL_NIUNIUXW;

						}
					}

				}
			}

			//取4张中组合最大的点数

			BYTE bcTmp[4];
			int iBig = 0;
			int in = 0;
			for ( in = 1;in<cbCardCount;in++)
			{
				for (int j = 1;j<cbCardCount;j++)
				{
					if(in != j)
					{
						BYTE bclogic = (GetCardLogicValue(cbCardDataSort[in])+GetCardLogicValue(cbCardDataSort[j]))%10;
						if(bclogic>iBig)
						{
							iBig = bclogic;
							int add = 0;
							bcTmp[0]=cbCardDataSort[in];
							bcTmp[1]=cbCardDataSort[j];
							for (int y = 1;y<cbCardCount;y++)
							{
								if(y != in&&y!=j)
								{
									iSingleA[add] =cbCardDataSort[y]; 
									add++;
								}

							}
							bcTmp[2]=iSingleA[0];
							bcTmp[3]=iSingleA[1];

						}

					}
				}   
			}

			if(bcOutCadData != NULL)
			{
				bcOutCadData[0] = cbCardDataSort[0];
				bcOutCadData[1] = bcTmp[2];
				bcOutCadData[2] = bcTmp[3];
				bcOutCadData[3] = bcTmp[0];
				bcOutCadData[4] = bcTmp[1];
			}
			return RetType(GetCardLogicValue(bcTmp[0])+GetCardLogicValue(bcTmp[1]));

		}
		//取4张中任两张组合为10 然后求另外两张的组合看是否是组合中最大
		for ( n= 1;n<cbCardCount;n++)
		{
			for (int j = 1;j<cbCardCount;j++)
			{
				if(j != n)
				{
					if((GetCardLogicValue(cbCardDataSort[n])+GetCardLogicValue(cbCardDataSort[j]))%10==0)
					{
						int add = 0;
						for (int y = 1;y<cbCardCount;y++)
						{
							if(y != n&&y!=j)
							{
								iSingleA[add] =cbCardDataSort[y]; 
								add++;

							}

						}
						if(iBigValue<=(GetCardLogicValue(iSingleA[0])+GetCardLogicValue(iSingleA[1]))%10)
						{
							iBigValue = GetCardLogicValue(iSingleA[0])+GetCardLogicValue(iSingleA[1])%10;
							bcMakeMax[0]= cbCardDataSort[0];
							bcMakeMax[1]= cbCardDataSort[j];
							bcMakeMax[2]= cbCardDataSort[n]; 
							bcMakeMax[3]= iSingleA[0]; 
							bcMakeMax[4]= iSingleA[1]; 

							if(bcOutCadData != NULL)
							{
								CopyMemory(bcOutCadData,bcMakeMax,cbCardCount);
							}
							if(iBigValue==0)
							{

								return CT_SPECIAL_NIUNIU;
							}
						}

					}
				}
			}
		}
		if(iBigValue!= 0)
		{
			return RetType(iBigValue);
		}else
		{
			//如果组合不成功
			iGetTenCount = 0;
		}

	}
	if(iGetTenCount==0)
	{
		//5个组合
		for ( n= 0;n<cbCardCount;n++)
		{
			for (int j = 0;j<cbCardCount;j++)
			{
				if(j != n)
				{
					for (int w = 0;w<cbCardCount;w++)
					{
						if(w != n&&w!=j)
						{
							int valueAdd = GetCardLogicValue(cbCardDataSort[n]);
							valueAdd += GetCardLogicValue(cbCardDataSort[j]);
							valueAdd += GetCardLogicValue(cbCardDataSort[w]);

							if(valueAdd%10==0)
							{
								int add = 0;
								for (int y = 0;y<cbCardCount;y++)
								{
									if(y != n&&y!=j&&y!=w)
									{
										iSingleA[add] =cbCardDataSort[y]; 
										add++;

									}

								}
								if(iBigValue<=(GetCardLogicValue(iSingleA[0])+GetCardLogicValue(iSingleA[1]))%10)
								{
									iBigValue = GetCardLogicValue(iSingleA[0])+GetCardLogicValue(iSingleA[1])%10;
									bcMakeMax[0]= cbCardDataSort[n];
									bcMakeMax[1]= cbCardDataSort[j];
									bcMakeMax[2]= cbCardDataSort[w]; 
									bcMakeMax[3]= iSingleA[0]; 
									bcMakeMax[4]= iSingleA[1]; 

									if(bcOutCadData != NULL)
									{
										CopyMemory(bcOutCadData,bcMakeMax,cbCardCount);
									}
									if(iBigValue==0)
									{

										return CT_SPECIAL_NIUNIU;
									}
								}

							}

						}
					}
				}
			}		
		}
		if(iBigValue!=0)
		{
			return RetType(iBigValue);
		}	
		else
		{
			return CT_POINT;
		}

	}

	return CT_POINT;
}
Example #14
0
//Multiple 比较出来的倍数
int CGameLogic::CompareCard(const BYTE cbFirstCardData[], BYTE cbFirstCardCount,const BYTE cbNextCardData[], BYTE cbNextCardCount,BYTE &Multiple)
{
	//合法判断
	ASSERT(5==cbFirstCardCount && 5==cbNextCardCount);
	if (!(5==cbFirstCardCount && 5==cbNextCardCount)) return 0;

	//获取牌型
	BYTE cbFirstCardType=GetCardType(cbFirstCardData, cbFirstCardCount);
	BYTE cbNextCardType=GetCardType(cbNextCardData, cbNextCardCount);

	//牌型比较
	if (cbFirstCardType != cbNextCardType) 
	{
		if (cbNextCardType > cbFirstCardType)
		{
			if(cbNextCardType>=12)
				Multiple = 10;
			else
				Multiple = cbNextCardType-2;
			return 1;
		}
		else
		{
			if(cbFirstCardType>=12)
				Multiple = 10;
			else
				Multiple = cbFirstCardType-2;
			return -1;
		}
	}

	//特殊牌型判断
	if (CT_POINT!=cbFirstCardType && cbFirstCardType==cbNextCardType)
	{
		//排序扑克
		BYTE cbFirstCardDataTmp[CARD_COUNT], cbNextCardDataTmp[CARD_COUNT];

		CopyMemory(cbFirstCardDataTmp,cbFirstCardData,sizeof(BYTE)*cbFirstCardCount);
		CopyMemory(cbNextCardDataTmp,cbNextCardData,sizeof(BYTE)*cbNextCardCount);
		SortCardList(cbFirstCardDataTmp,cbFirstCardCount,ST_NEW);
		SortCardList(cbNextCardDataTmp,cbNextCardCount,ST_NEW);

		if(cbFirstCardType>=12)
			Multiple = 10;
		else
			Multiple = cbFirstCardType-2;

		BYTE firstValue = GetCardNewValueEx(cbFirstCardDataTmp[0]);
		BYTE NextValue = GetCardNewValueEx(cbNextCardDataTmp[0]);
		BYTE firstColor = GetCardColor(cbFirstCardDataTmp[0]);
		BYTE NextColor = GetCardColor(cbNextCardDataTmp[0]);


		if(firstValue<NextValue) return 1;
		else
		{
			if(firstValue==NextValue)
			{
				if(firstColor<NextColor) return 1;
				else return -1;
			}
			return -1;
		}

	}

	//排序扑克
	BYTE cbFirstCardDataTmp[CARD_COUNT], cbNextCardDataTmp[CARD_COUNT];
	CopyMemory(cbFirstCardDataTmp,cbFirstCardData,sizeof(BYTE)*cbFirstCardCount);
	CopyMemory(cbNextCardDataTmp,cbNextCardData,sizeof(BYTE)*cbNextCardCount);
	SortCardList(cbFirstCardDataTmp,cbFirstCardCount,ST_NEW);
	SortCardList(cbNextCardDataTmp,cbNextCardCount,ST_NEW);

	BYTE firstValue = GetCardNewValue(cbFirstCardDataTmp[0]);
	BYTE NextValue = GetCardNewValue(cbNextCardDataTmp[0]);
	BYTE firstColor = GetCardColor(cbFirstCardDataTmp[0]);
	BYTE NextColor = GetCardColor(cbNextCardDataTmp[0]);

	if(firstValue<NextValue)return 1;
	else
	{
		if(firstValue==NextValue)
		{
			if(firstColor<NextColor) return 1;
			else return -1;
		}
		return -1;
	}

}
Example #15
0
//获取类型
BYTE CGameLogic::GetCardGenre(BYTE cbCardData[], BYTE cbCardCount)
{
	//简单牌形
	switch (cbCardCount)
	{
	case 1: //单牌
		{
			return CT_SINGLE;
		}
	case 2:	//对牌
		{
			return (GetCardLogicValue(cbCardData[0])==GetCardLogicValue(cbCardData[1]))?CT_ONE_DOUBLE:CT_SINGLE;
		}
	}

	//五条类型
	if (cbCardCount>=4)
	{
		//变量定义
		bool cbSameColor=true,bLineCard=true;
		BYTE cbFirstColor=GetCardColor(cbCardData[0]);
		BYTE cbFirstValue=GetCardLogicValue(cbCardData[0]);

		//牌形分析
		for (BYTE i=1;i<cbCardCount;i++)
		{
			//数据分析
			if (GetCardColor(cbCardData[i])!=cbFirstColor) cbSameColor=false;
			if (cbFirstValue!=(GetCardLogicValue(cbCardData[i])+i)) bLineCard=false;

			//结束判断
			if ((cbSameColor==false)&&(bLineCard==false)) break;
		}

		//特殊
		if(!bLineCard)
		{
			//A J 10 9 8特殊
			for (BYTE i=1;i<cbCardCount;i++)
			{
				if ((cbFirstValue-2)!=(GetCardLogicValue(cbCardData[i])+i)) break;
			}
			if(i==cbCardCount) bLineCard=true;
		}

		//顺子类型
		if ((cbSameColor==false)&&(bLineCard==true)) return CT_SHUN_ZI;
		
		//同花类型
		if ((cbSameColor==true)&&(bLineCard==false)) return CT_TONG_HUA;

		//同花顺类型
		if ((cbSameColor==true)&&(bLineCard==true)) return CT_TONG_HUA_SHUN;
	}

	//扑克分析
	tagAnalyseResult AnalyseResult;
	AnalysebCardData(cbCardData,cbCardCount,AnalyseResult);

	//四条类型
	if (AnalyseResult.cbFourCount==1) return CT_TIE_ZHI;

	//两对类型
	if (AnalyseResult.cbDoubleCount==2) return CT_TWO_DOUBLE;

	//对牌类型
	if ((AnalyseResult.cbDoubleCount==1)&&(AnalyseResult.cbThreeCount==0)) return CT_ONE_DOUBLE;

	//葫芦类型
	if (AnalyseResult.cbThreeCount==1) return (AnalyseResult.cbDoubleCount==1)?CT_HU_LU:CT_THREE_TIAO;

	return CT_SINGLE;
}
Example #16
0
//对比扑克
bool CGameLogic::CompareCard(BYTE cbFirstCardData[], BYTE cbNextCardData[], BYTE cbCardCount)
{
	//获取类型
	BYTE cbNextGenre=GetCardGenre(cbNextCardData,cbCardCount);
	BYTE cbFirstGenre=GetCardGenre(cbFirstCardData,cbCardCount);

	//类型判断
	if (cbFirstGenre!=cbNextGenre) return (cbFirstGenre>cbNextGenre);

	//类型对比
	switch(cbFirstGenre)
	{
	case CT_SINGLE:			//单牌
		{
			//对比数值
			for (BYTE i=0;i<cbCardCount;i++)
			{
				BYTE cbNextValue=GetCardLogicValue(cbNextCardData[i]);
				BYTE cbFirstValue=GetCardLogicValue(cbFirstCardData[i]);
				if (cbFirstValue!=cbNextValue) return cbFirstValue>cbNextValue;
			}

			//对比花色
			return GetCardColor(cbFirstCardData[0])>GetCardColor(cbNextCardData[0]);
		}
	case CT_HU_LU:			//葫芦
	case CT_TIE_ZHI:		//铁支
	case CT_ONE_DOUBLE:		//对子
	case CT_TWO_DOUBLE:		//两对
	case CT_THREE_TIAO:		//三条
		{
			//分析扑克
			tagAnalyseResult AnalyseResultNext;
			tagAnalyseResult AnalyseResultFirst;
			AnalysebCardData(cbNextCardData,cbCardCount,AnalyseResultNext);
			AnalysebCardData(cbFirstCardData,cbCardCount,AnalyseResultFirst);

			//四条数值
			if (AnalyseResultFirst.cbFourCount>0)
			{
				BYTE cbNextValue=AnalyseResultNext.cbFourLogicVolue[0];
				BYTE cbFirstValue=AnalyseResultFirst.cbFourLogicVolue[0];
				return cbFirstValue>cbNextValue;
			}

			//三条数值
			if (AnalyseResultFirst.cbThreeCount>0)
			{
				BYTE cbNextValue=AnalyseResultNext.cbThreeLogicVolue[0];
				BYTE cbFirstValue=AnalyseResultFirst.cbThreeLogicVolue[0];
				return cbFirstValue>cbNextValue;
			}

			//对子数值
			for (BYTE i=0;i<AnalyseResultFirst.cbDoubleCount;i++)
			{
				BYTE cbNextValue=AnalyseResultNext.cbDoubleLogicVolue[i];
				BYTE cbFirstValue=AnalyseResultFirst.cbDoubleLogicVolue[i];
				if (cbFirstValue!=cbNextValue) return cbFirstValue>cbNextValue;
			}

			//散牌数值
			for (BYTE i=0;i<AnalyseResultFirst.cbSignedCount;i++)
			{
				BYTE cbNextValue=AnalyseResultNext.cbSignedLogicVolue[i];
				BYTE cbFirstValue=AnalyseResultFirst.cbSignedLogicVolue[i];
				if (cbFirstValue!=cbNextValue) return cbFirstValue>cbNextValue;
			}

			//对子花色
			if (AnalyseResultFirst.cbDoubleCount>0)
			{
				BYTE cbNextColor=GetCardColor(AnalyseResultNext.cbDoubleCardData[0]);
				BYTE cbFirstColor=GetCardColor(AnalyseResultFirst.cbDoubleCardData[0]);
				return cbFirstColor>cbNextColor;
			}

			//散牌花色
			if (AnalyseResultFirst.cbSignedCount>0)
			{
				BYTE cbNextColor=GetCardColor(AnalyseResultNext.cbSignedCardData[0]);
				BYTE cbFirstColor=GetCardColor(AnalyseResultFirst.cbSignedCardData[0]);
				return cbFirstColor>cbNextColor;
			}

			break;
		}
	case CT_SHUN_ZI:		//顺子
	case CT_TONG_HUA:		//同花
	case CT_TONG_HUA_SHUN:	//同花顺
		{
			//数值判断
			BYTE cbNextValue=GetCardLogicValue(cbNextCardData[0]);
			BYTE cbFirstValue=GetCardLogicValue(cbFirstCardData[0]);

			//特殊列:A J 10 9 8
			if( cbFirstGenre == CT_SHUN_ZI )
			{
				if( GetCardLogicValue(cbNextCardData[0])-3 == GetCardLogicValue(cbNextCardData[1]) )
					cbNextValue = GetCardLogicValue(cbNextCardData[1]);
				if( GetCardLogicValue(cbFirstCardData[0])-3 == GetCardLogicValue(cbFirstCardData[1]) )
					cbFirstValue = GetCardLogicValue(cbFirstCardData[1]);
			}

			if (cbFirstValue!=cbNextValue) return (cbFirstValue>cbNextValue);

			//花色判断
			BYTE cbNextColor=GetCardColor(cbNextCardData[0]);
			BYTE cbFirstColor=GetCardColor(cbFirstCardData[0]);

			return (cbFirstColor>cbNextColor);
		}
	}

	//错误断言
	ASSERT(FALSE);

	return false;
}
Example #17
0
//对比扑克(通比牛牛)
bool CGameLogic::RatioCompareCard( BYTE cbFirstData[], BYTE cbNextData[], BYTE cbCardCount,BOOL FirstOX,BOOL NextOX )
{
    if(FirstOX!=NextOX)return (FirstOX>NextOX);
    //比较牛大小
    if(FirstOX==TRUE)
    {
        //获取点数
        BYTE cbNextType=GetBestCardType(cbNextData,cbCardCount);
        BYTE cbFirstType=GetBestCardType(cbFirstData,cbCardCount);

        //点数判断
        if (cbFirstType!=cbNextType) return (cbFirstType>cbNextType);
    }

    if (IsHaveJoker(cbFirstData, cbCardCount)&& !IsHaveJoker(cbNextData, cbCardCount))
    {
        return false;
    }
    else if(!IsHaveJoker(cbFirstData, cbCardCount)&& IsHaveJoker(cbNextData, cbCardCount))
    {
        return true;
    }
    else if(IsHaveJoker(cbFirstData, cbCardCount)&& IsHaveJoker(cbNextData, cbCardCount))
    {
        //排序大小
        BYTE bFirstTemp[MAX_COUNT-1],bNextTemp[MAX_COUNT-1];
        for (BYTE i=0,j=0; i<cbCardCount; i++)
        {
            if (GetCardValue(cbFirstData[i])>=14 )
            {
                continue;
            }
            bFirstTemp[j] = cbFirstData[i];
            j++;
        }

        for (BYTE i=0,j=0; i<cbCardCount; i++)
        {
            if (GetCardValue(cbNextData[i])>=14 )
            {
                continue;
            }
            bNextTemp[j] = cbNextData[i];
            j++;
        }

        SortCardList(bFirstTemp,MAX_COUNT-1);
        SortCardList(bNextTemp,MAX_COUNT-1);

        //比较数值
        BYTE cbNextMaxValue=GetCardValue(bNextTemp[0]);
        BYTE cbFirstMaxValue=GetCardValue(bFirstTemp[0]);
        if(cbNextMaxValue!=cbFirstMaxValue)return cbFirstMaxValue>cbNextMaxValue;

        //比较颜色
        return GetCardColor(bFirstTemp[0]) > GetCardColor(bNextTemp[0]);
    }

    //排序大小
    BYTE bFirstTemp[MAX_COUNT],bNextTemp[MAX_COUNT];
    CopyMemory(bFirstTemp,cbFirstData,cbCardCount);
    CopyMemory(bNextTemp,cbNextData,cbCardCount);
    SortCardList(bFirstTemp,cbCardCount);
    SortCardList(bNextTemp,cbCardCount);

    //比较数值
    BYTE cbNextMaxValue=GetCardValue(bNextTemp[0]);
    BYTE cbFirstMaxValue=GetCardValue(bFirstTemp[0]);
    if(cbNextMaxValue!=cbFirstMaxValue)return cbFirstMaxValue>cbNextMaxValue;

    //比较颜色
    return GetCardColor(bFirstTemp[0]) > GetCardColor(bNextTemp[0]);
}