예제 #1
0
//是否爆牌
bool CGameLogic::IsBurst(const BYTE bCardBuffer[], BYTE bCardCount)
{
	WORD wCardSum = 0;
	
	for(int i = 0; i < bCardCount; i++)
	{
		wCardSum += GetCardValue(bCardBuffer[i]);
	}

	if(wCardSum > 21)
	{
		for(int i = 0; i < bCardCount; i++)
		{
			//是否有A
			if(GetCardValue(bCardBuffer[i]) == 11)
			{
				//按1计算
				wCardSum -= 10;
			}
		}
	}

	if(wCardSum > 21) return true;
	
	return false;
}
예제 #2
0
//对比单只扑克
bool CGameLogic::CompareOnlyOne(BYTE bFirstCard, BYTE bLastCard)
{
	BYTE bFirstValue = GetCardValue(bFirstCard);
	BYTE bLastValue  = GetCardValue(bLastCard);
	if (bFirstValue == bLastValue) return bFirstValue > bLastValue;
	return bFirstValue > bLastValue;
}
예제 #3
0
//对比扑克
bool CCardControl::CompareOnlyOne(BYTE bFirstCard, BYTE bLastCard)
{
	BYTE bFirstVolae=GetCardValue(bFirstCard);
	BYTE bLastVolae=GetCardValue(bLastCard);
	if (bFirstVolae==bLastVolae) return bFirstCard>bLastCard;
	return bFirstVolae>bLastVolae;
}
예제 #4
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;
}
예제 #5
0
//获取倍数
BYTE CGameLogic::GetCardTimes(BYTE cbCardData[], BYTE cbCardCount)
{
	//获取类型
	BYTE cbCardType=GetCardType(cbCardData,cbCardCount);

	//获取倍数
	switch (cbCardType)
	{
	case CT_VALUES:			//点值类型
		{
			//变量定义
			BYTE cbValueList=0;
			BYTE cbValueCard=0;

			//获取数值
			for (BYTE i=0;i<cbCardCount;i++)
			{
				cbValueCard=GetCardValue(cbCardData[i]);
				if (cbValueCard<10) cbValueList+=cbValueCard;
			}

			return ((cbValueList%10)>=8)?2:1;
		}
	case CT_THREE_JQK:		//三公类型
		{
			return 3;
		}
	case CT_THREE_KING:		//三条类型
		{
			return (GetCardValue(cbCardData[0])>10)?9:5;
		}
	}

	return 0;
}
예제 #6
0
//是否777牌
bool CGameLogic::IsSevensCard(const BYTE bCardBuffer[],BYTE bCardCunt)
{
	if(bCardCunt!=3)
		return false;
	if((GetCardValue(bCardBuffer[0])==7)
		&&(GetCardValue(bCardBuffer[1])==7)
		&&(GetCardValue(bCardBuffer[2])==7))
		return true;
	return false;
}
예제 #7
0
//获取类型
BYTE CGameLogic::GetCardType( BYTE cbCardData[], BYTE cbCardCount, BYTE cbOutCard[]/*=NULL*/, bool bGet/*=false*/ )
{
    ASSERT(cbCardCount==MAX_COUNT);

    BYTE bKingCount=0,bJokeCount=0;
    for(BYTE i=0; i<cbCardCount; i++)
    {
        if(GetCardValue(cbCardData[i])>10)
        {
            bKingCount++;
            if(GetCardValue(cbCardData[i])>=0xE)
            {
                bJokeCount++;
            }
        }
    }

    if(bKingCount==MAX_COUNT)
    {
        if(bJokeCount == 2) return OX_DOUBLE_JOKE;
        return OX_GOLD;
    }

    BYTE bTemp[MAX_COUNT];
    BYTE bSum=0;
    for (BYTE i=0; i<cbCardCount; i++)
    {
        bTemp[i]=GetCardLogicValue(cbCardData[i]);
        bSum+=bTemp[i];
    }

    for (BYTE i=0; i<cbCardCount-1; i++)
    {
        for (BYTE j=i+1; j<cbCardCount; j++)
        {
            if((bSum-bTemp[i]-bTemp[j])%10==0)
            {
                if (bGet)
                {
                    cbOutCard[0] = cbCardData[i];
                    cbOutCard[1] = cbCardData[j];
                }
                return ((bTemp[i]+bTemp[j])>10)?(bTemp[i]+bTemp[j]-10):(bTemp[i]+bTemp[j]);
            }
        }
    }

    return OX_VALUE0;
}
예제 #8
0
//获取积分
WORD CGameLogic::GetCardScore(const BYTE cbCardData[], BYTE cbCardCount)
{
    //变量定义
    WORD wCardScore=0;

    //扑克累计
    for (BYTE i=0; i<cbCardCount; i++)
    {
        //获取数值
        BYTE cbCardValue=GetCardValue(cbCardData[i]);

        //累计积分
        if (cbCardValue==5)
        {
            wCardScore+=5;
            continue;
        }

        //累计积分
        if ((cbCardValue==10)||(cbCardValue==13))
        {
            wCardScore+=10;
            continue;
        }
    }

    return wCardScore;
}
예제 #9
0
BOOL CGameLogic::ValidCardValue( BYTE cbCardBuffer[] , BYTE cbBufferCount )
{
    BYTE cbTemp[GAME_PLAYER*MAX_COUNT]= {0};
    CopyMemory(cbTemp , cbCardBuffer , cbBufferCount);
    for (int i=0 ; i<GAME_PLAYER*MAX_COUNT; i++)
    {
        if(cbTemp[i] != 0)
        {
            cbTemp[i] = GetCardValue(cbTemp[i]);
        }
    }
    sort(cbTemp , cbTemp+GAME_PLAYER*MAX_COUNT);
    BYTE cbCount=1;
    for (int k=0 ; k<GAME_PLAYER*MAX_COUNT-1; k++)
    {
        if(cbTemp[k] == 0) continue;
        if(cbTemp[k] != cbTemp[k+1])
        {
            cbCount = 1;
        }
        else
        {
            if(cbTemp[k] == 0xE || cbTemp[k] == 0xF)
            {
                return false;
            }
            cbCount++;
        }
        if(cbCount > 4)
        {
            return false;
        }
    }
    return true;
}
예제 #10
0
//排列扑克
void CGameLogic::SortCardList(BYTE cbCardData[], BYTE cbCardCount)
{
    //转换数值
    BYTE cbLogicValue[MAX_COUNT];
    for (BYTE i=0; i<cbCardCount; i++) cbLogicValue[i]=GetCardValue(cbCardData[i]);

    //排序操作
    bool bSorted=true;
    BYTE cbTempData,bLast=cbCardCount-1;
    do
    {
        bSorted=true;
        for (BYTE i=0; i<bLast; i++)
        {
            if ((cbLogicValue[i]<cbLogicValue[i+1])||
                    ((cbLogicValue[i]==cbLogicValue[i+1])&&(cbCardData[i]<cbCardData[i+1])))
            {
                //交换位置
                cbTempData=cbCardData[i];
                cbCardData[i]=cbCardData[i+1];
                cbCardData[i+1]=cbTempData;
                cbTempData=cbLogicValue[i];
                cbLogicValue[i]=cbLogicValue[i+1];
                cbLogicValue[i+1]=cbTempData;
                bSorted=false;
            }
        }
        bLast--;
    } while(bSorted==false);

    return;
}
예제 #11
0
//逻辑数值
BYTE CGameLogic::GetCardLogicValue(BYTE cbCardData)
{
	//转换数值
	BYTE cbCardValue=GetCardValue(cbCardData);
	BYTE cbLogicValue=(cbCardValue<=2)?(cbCardValue+13):cbCardValue;

	return cbLogicValue;
}
예제 #12
0
//»ñÈ¡ÅƵã
BYTE CGameLogic::GetCardPip(BYTE cbCardData)
{
	//¼ÆËãÅƵã
	BYTE cbCardValue=GetCardValue(cbCardData);
	BYTE cbPipCount=(cbCardValue>=10)?0:cbCardValue;

	return cbPipCount;
}
예제 #13
0
//逻辑数值
BYTE CGameLogic::GetCardLogicValue(BYTE cbCardData)
{
	//扑克属性
	BYTE bCardColor=GetCardColor(cbCardData);
	BYTE bCardValue=GetCardValue(cbCardData);

	//转换数值
	return (bCardValue<=2)?(bCardValue+13):bCardValue;
}
예제 #14
0
파일: aaaaaaaaaa.cpp 프로젝트: AAAA8/test
BYTE CGameLogic::GetCardNewValueEx(BYTE cbCardData)
{
	//扑克属性
	BYTE cbCardColor=GetCardColor(cbCardData);
	BYTE cbCardValue=GetCardValue(cbCardData);
	//转换数值
	if (cbCardColor!=0x04) return cbCardValue+10;
	return cbCardValue;
}
예제 #15
0
NS_IMETHODIMP nsAbView::GetCellText(PRInt32 row, nsITreeColumn* col, nsAString& _retval)
{
  NS_ENSURE_TRUE(row >= 0 && row < mCards.Count(), NS_ERROR_UNEXPECTED);

  nsIAbCard *card = ((AbCard *)(mCards.ElementAt(row)))->card;
  const PRUnichar* colID;
  col->GetIdConst(&colID);
  return GetCardValue(card, colID, _retval);
}
예제 #16
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;
}
예제 #17
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;
}
예제 #18
0
파일: Card.cpp 프로젝트: lbland/BlackJack
 /************************************************
  
  IsAce - returns true if the card is an ace.
  
  *************************************************/
 bool Card::IsAce( ) const
 {
     unsigned int value = GetCardValue( );
     if( value == 11 )
     {
         return true;
     }
     
     return false;
     
 }
예제 #19
0
//获取类型
BYTE CGameLogic::GetCardType(const BYTE cbCardData[], BYTE cbCardCount)
{
    BYTE j = 0;
    BYTE i = 0;
    //状态效验
    ASSERT(m_cbMainColor!=COLOR_ERROR);
    ASSERT(m_cbMainValue!=VALUE_ERROR);

    //数目判断
    ASSERT((cbCardCount>0)&&(cbCardCount<=MAX_COUNT));
    if ((cbCardCount==0)||(cbCardCount>MAX_COUNT)) return CT_ERROR;

    //同花判断
    if (GetCardLogicColor(cbCardData,cbCardCount)==COLOR_ERROR) return CT_ERROR;

    //同牌判断
    BYTE cbSameCount=1;
    for (i=1; i<cbCardCount; i++)
    {
        if (cbCardData[i]==cbCardData[0]) cbSameCount++;
        else break;
    }
    if (cbSameCount==cbCardCount) return CT_SINGLE+cbSameCount-1;

    //拖牌判断
    if ((cbSameCount>=2)&&(cbCardCount%cbSameCount)==0)
    {
        //变量定义
        BYTE cbBlockCount=cbCardCount/cbSameCount;

        //单元判断
        for (i=1; i<cbBlockCount; i++)
        {
            //变量定义
            BYTE cbIndex=i*cbSameCount;
            BYTE cbFirstValue=GetCardValue(cbCardData[0]);

            //相同分析
            for (j=0; j<cbSameCount; j++)
            {
                if (cbCardData[cbIndex+j]!=cbCardData[cbIndex]) break;
            }
            if (j!=cbSameCount) break;

            //相连分析
            if (IsLineValue(cbCardData[cbIndex-cbSameCount],cbCardData[cbIndex])==false) break;
        }

        //成功判断
        if (i==cbBlockCount) return CT_TRACKOR_2+cbSameCount-2;
    }

    return CT_THROW_CARD;
}
예제 #20
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;
}
예제 #21
0
//逻辑数值
BYTE CGameLogic::GetCardLogicValue(BYTE cbCardData)
{
	//扑克属性
	BYTE cbCardColor=GetCardColor(cbCardData);
	BYTE cbCardValue=GetCardValue(cbCardData);

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

	//转换数值
	return (cbCardValue*4)+(cbCardColor>>4);
}
예제 #22
0
파일: aaaaaaaaaa.cpp 프로젝트: AAAA8/test
//排列扑克
void CGameLogic::SortCardList(BYTE cbCardData[], BYTE cbCardCount, BYTE cbSortType)
{
	//数目过虑
	if (cbCardCount==0) return;

	//转换数值
	BYTE cbSortValue[CARD_COUNT];
	if (ST_VALUE==cbSortType)
	{
		for (BYTE i=0;i<cbCardCount;i++) cbSortValue[i]=GetCardValue(cbCardData[i]);	
	}
	else 
	{
		if(cbSortType==ST_NEW)
		{
			for (BYTE i=0;i<cbCardCount;i++) cbSortValue[i]=GetCardNewValue(cbCardData[i]);	

		}else
		{
			for (BYTE i=0;i<cbCardCount;i++) cbSortValue[i]=GetCardLogicValue(cbCardData[i]);	

		}

	}


	//排序操作
	bool bSorted=true;
	BYTE cbThreeCount,cbLast=cbCardCount-1;
	do
	{
		bSorted=true;
		for (BYTE i=0;i<cbLast;i++)
		{
			if ((cbSortValue[i]<cbSortValue[i+1])||
				((cbSortValue[i]==cbSortValue[i+1])&&(cbCardData[i]<cbCardData[i+1])))
			{
				//交换位置
				cbThreeCount=cbCardData[i];
				cbCardData[i]=cbCardData[i+1];
				cbCardData[i+1]=cbThreeCount;
				cbThreeCount=cbSortValue[i];
				cbSortValue[i]=cbSortValue[i+1];
				cbSortValue[i+1]=cbThreeCount;
				bSorted=false;
			}	
		}
		cbLast--;
	} while(bSorted==false);

	return;
}
예제 #23
0
//手牌中是否有王
int CGameLogic::IsHaveJoker( BYTE cbCardData[], BYTE cbCardCount )
{
    BYTE tempCardData[MAX_COUNT];
    CopyMemory(tempCardData, cbCardData, sizeof(tempCardData));
    int iJokerCount =0;
    for(int i=0; i<MAX_COUNT; i++)
    {
        if (GetCardValue(tempCardData[i])>=14)
        {
            iJokerCount ++;
        }
    }
    return iJokerCount;
}
예제 #24
0
//获取点数
BYTE CGameLogic::GetCardValue(BYTE cbCardData[], BYTE cbCardCount)
{
	//变量定义
	BYTE cbValueList=0;

	//计算点数
	for (BYTE i=0;i<MAX_COUNT;i++)
	{
		BYTE cbCardValue=GetCardValue(cbCardData[i]);
		if (cbCardValue<10) cbValueList=(cbValueList+cbCardValue)%10;
	}

	return cbValueList;
}
예제 #25
0
//获取扑克总值
BYTE CGameLogic::GetCardSum(const BYTE bCardBuffer[], const BYTE bCardCount)
{
	BYTE cbCardSum = 0;
	
	for(int i = 0; i < bCardCount; i++)
	{
		cbCardSum += GetCardValue(bCardBuffer[i]);
	}
	
	if(cbCardSum > 21)
	{
		for(int i = 0; i < bCardCount; i++)
		{
			//是否有A
			if(GetCardValue(bCardBuffer[i]) == 11)
			{
				//按1计算
				cbCardSum -= 10;
			}
		}
	}

	return cbCardSum;
}
예제 #26
0
파일: aaaaaaaaaa.cpp 프로젝트: AAAA8/test
//逻辑大小
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;
}
예제 #27
0
파일: aaaaaaaaaa.cpp 프로젝트: AAAA8/test
//获取牌点
BYTE CGameLogic::GetCardListPip(const BYTE cbCardData[], BYTE cbCardCount)
{
	//变量定义
	BYTE cbPipCount=0;

	//获取牌点
	BYTE cbCardValue=0;
	for (BYTE i=0;i<cbCardCount;i++)
	{
		cbCardValue=GetCardValue(cbCardData[i]);
		if(cbCardValue>10)
		{
			cbCardValue = 10;

		}
		cbPipCount+=cbCardValue;
	}
	return (cbPipCount%10);
}
예제 #28
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];
    }
예제 #29
0
nsresult nsAbView::GenerateCollationKeysForCard(const PRUnichar *colID, AbCard *abcard)
{
  nsresult rv;
  nsString value;

  if (!mCollationKeyGenerator)
  {
    nsCOMPtr<nsILocaleService> localeSvc = do_GetService(NS_LOCALESERVICE_CONTRACTID,&rv); 
    NS_ENSURE_SUCCESS(rv, rv);

    nsCOMPtr<nsILocale> locale; 
    rv = localeSvc->GetApplicationLocale(getter_AddRefs(locale));
    NS_ENSURE_SUCCESS(rv, rv);

    nsCOMPtr <nsICollationFactory> factory = do_CreateInstance(NS_COLLATIONFACTORY_CONTRACTID, &rv); 
    NS_ENSURE_SUCCESS(rv, rv);

    rv = factory->CreateCollation(locale, getter_AddRefs(mCollationKeyGenerator));
    NS_ENSURE_SUCCESS(rv, rv);
  }

  rv = GetCardValue(abcard->card, colID, value);
  NS_ENSURE_SUCCESS(rv,rv);
  
  PR_FREEIF(abcard->primaryCollationKey);
  rv = mCollationKeyGenerator->AllocateRawSortKey(nsICollation::kCollationCaseInSensitive,
    value, &(abcard->primaryCollationKey), &(abcard->primaryCollationKeyLen));
  NS_ENSURE_SUCCESS(rv,rv);
  
  // Hardcode email to be our secondary key. As we are doing this, just call
  // the card's GetCardValue direct, rather than our own function which will
  // end up doing the same as then we can save a bit of time.
  rv = abcard->card->GetPrimaryEmail(value);
  NS_ENSURE_SUCCESS(rv,rv);
  
  PR_FREEIF(abcard->secondaryCollationKey);
  rv = mCollationKeyGenerator->AllocateRawSortKey(nsICollation::kCollationCaseInSensitive,
    value, &(abcard->secondaryCollationKey), &(abcard->secondaryCollationKeyLen));
  NS_ENSURE_SUCCESS(rv,rv);
  return rv;
}
예제 #30
0
//获取积分
BYTE CGameLogic::GetScoreCard(const BYTE cbCardData[], BYTE cbCardCount, BYTE cbScoreCard[], BYTE cbMaxCount)
{
    //变量定义
    BYTE cbPostion=0;

    //扑克累计
    for (BYTE i=0; i<cbCardCount; i++)
    {
        //获取数值
        BYTE cbCardValue=GetCardValue(cbCardData[i]);

        //累计扑克
        if ((cbCardValue==5)||(cbCardValue==10)||(cbCardValue==13))
        {
            ASSERT(cbPostion<cbMaxCount);
            cbScoreCard[cbPostion++]=cbCardData[i];
        }
    }

    return cbPostion;
}