Exemplo n.º 1
0
        //
        public static bool SearchOutCard(byte[] cbHandCardData, byte cbHandCardCount, byte[] cbTurnCardData, byte cbTurnCardCount, ref tagOutCardResult OutCardResult)
        {
            byte[] cbCardData  = new byte[MAX_COUNT];
            byte   cbCardCount = cbHandCardCount;

            Buffer.BlockCopy(cbHandCardData, 0, cbCardData, 0, cbHandCardCount);


            SortCardList(ref cbCardData, cbCardCount, ST_ORDER);


            byte cbTurnOutType = GetCardType(cbTurnCardData, cbTurnCardCount);


            switch (cbTurnOutType)
            {
            case CT_ERROR:
            {
                byte cbLogicValue = GetCardLogicValue(cbCardData[cbCardCount - 1]);


                byte cbSameCount = 1;
                for (byte i = 1; i < cbCardCount; i++)
                {
                    if (GetCardLogicValue(cbCardData[cbCardCount - i - 1]) == cbLogicValue)
                    {
                        cbSameCount++;
                    }
                    else
                    {
                        break;
                    }
                }


                if (cbSameCount > 1)
                {
                    OutCardResult.cbCardCount = cbSameCount;
                    for (byte j = 0; j < cbSameCount; j++)
                    {
                        OutCardResult.cbResultCard[j] = cbCardData[cbCardCount - 1 - j];
                    }
                    return(true);
                }


                OutCardResult.cbCardCount     = 1;
                OutCardResult.cbResultCard[0] = cbCardData[cbCardCount - 1];

                return(true);
            }

            case CT_SINGLE:
            case CT_DOUBLE:
            case CT_THREE:
            {
                byte cbLogicValue = GetCardLogicValue(cbTurnCardData[0]);


                tagAnalyseResult AnalyseResult = new tagAnalyseResult();
                AnalysebCardData(ref cbCardData, cbCardCount, ref AnalyseResult);


                if (cbTurnCardCount <= 1)
                {
                    for (byte i = 0; i < AnalyseResult.cbSignedCount; i++)
                    {
                        byte cbIndex = (byte)(AnalyseResult.cbSignedCount - i - 1);
                        if (GetCardLogicValue(AnalyseResult.cbSignedCardData[cbIndex]) > cbLogicValue)
                        {
                            OutCardResult.cbCardCount = cbTurnCardCount;
                            Buffer.BlockCopy(AnalyseResult.cbSignedCardData, cbIndex, OutCardResult.cbResultCard, 0, cbTurnCardCount);
                            return(true);
                        }
                    }
                }


                if (cbTurnCardCount <= 2)
                {
                    for (byte i = 0; i < AnalyseResult.cbDoubleCount; i++)
                    {
                        byte cbIndex = (byte)((AnalyseResult.cbDoubleCount - i - 1) * 2);
                        if (GetCardLogicValue(AnalyseResult.cbDoubleCardData[cbIndex]) > cbLogicValue)
                        {
                            OutCardResult.cbCardCount = cbTurnCardCount;
                            Buffer.BlockCopy(AnalyseResult.cbDoubleCardData, cbIndex, OutCardResult.cbResultCard, 0, cbTurnCardCount);

                            return(true);
                        }
                    }
                }


                if (cbTurnCardCount <= 3)
                {
                    for (byte i = 0; i < AnalyseResult.cbThreeCount; i++)
                    {
                        byte cbIndex = (byte)((AnalyseResult.cbThreeCount - i - 1) * 3);
                        if (GetCardLogicValue(AnalyseResult.cbThreeCardData[cbIndex]) > cbLogicValue)
                        {
                            OutCardResult.cbCardCount = cbTurnCardCount;
                            Buffer.BlockCopy(AnalyseResult.cbThreeCardData, cbIndex, OutCardResult.cbResultCard, 0, cbTurnCardCount);
                            return(true);
                        }
                    }
                }

                break;
            }

            case CT_SINGLE_LINE:
            {
                if (cbCardCount < cbTurnCardCount)
                {
                    break;
                }


                byte cbLogicValue = GetCardLogicValue(cbTurnCardData[0]);


                for (byte i = (byte)(cbTurnCardCount - 1); i < cbCardCount; i++)
                {
                    byte cbHandLogicValue = GetCardLogicValue(cbCardData[cbCardCount - i - 1]);


                    if (cbHandLogicValue >= 15)
                    {
                        break;
                    }
                    if (cbHandLogicValue <= cbLogicValue)
                    {
                        continue;
                    }


                    byte cbLineCount = 0;
                    for (byte j = (byte)(cbCardCount - i - 1); j < cbCardCount; j++)
                    {
                        if ((GetCardLogicValue(cbCardData[j]) + cbLineCount) == cbHandLogicValue)
                        {
                            OutCardResult.cbResultCard[cbLineCount++] = cbCardData[j];


                            if (cbLineCount == cbTurnCardCount)
                            {
                                OutCardResult.cbCardCount = cbTurnCardCount;
                                return(true);
                            }
                        }
                    }
                }

                break;
            }

            case CT_DOUBLE_LINE:
            {
                if (cbCardCount < cbTurnCardCount)
                {
                    break;
                }


                byte cbLogicValue = GetCardLogicValue(cbTurnCardData[0]);


                for (byte i = (byte)(cbTurnCardCount - 1); i < cbCardCount; i++)
                {
                    byte cbHandLogicValue = GetCardLogicValue(cbCardData[cbCardCount - i - 1]);


                    if (cbHandLogicValue <= cbLogicValue)
                    {
                        continue;
                    }
                    if ((cbTurnCardCount > 1) && (cbHandLogicValue >= 15))
                    {
                        break;
                    }


                    byte cbLineCount = 0;
                    for (byte j = (byte)(cbCardCount - i - 1); j < (cbCardCount - 1); j++)
                    {
                        if (((GetCardLogicValue(cbCardData[j]) + cbLineCount) == cbHandLogicValue) &&
                            ((GetCardLogicValue(cbCardData[j + 1]) + cbLineCount) == cbHandLogicValue))
                        {
                            OutCardResult.cbResultCard[cbLineCount * 2]         = cbCardData[j];
                            OutCardResult.cbResultCard[(cbLineCount++) * 2 + 1] = cbCardData[j + 1];


                            if (cbLineCount * 2 == cbTurnCardCount)
                            {
                                OutCardResult.cbCardCount = cbTurnCardCount;
                                return(true);
                            }
                        }
                    }
                }

                break;
            }

            case CT_THREE_LINE:
            case CT_THREE_LINE_TAKE_ONE:
            case CT_THREE_LINE_TAKE_TWO:
            {
                if (cbCardCount < cbTurnCardCount)
                {
                    break;
                }


                byte cbLogicValue = 0;
                for (byte i = 0; i < cbTurnCardCount - 2; i++)
                {
                    cbLogicValue = GetCardLogicValue(cbTurnCardData[i]);
                    if (GetCardLogicValue(cbTurnCardData[i + 1]) != cbLogicValue)
                    {
                        continue;
                    }
                    if (GetCardLogicValue(cbTurnCardData[i + 2]) != cbLogicValue)
                    {
                        continue;
                    }
                    break;
                }


                byte cbTurnLineCount = 0;
                if (cbTurnOutType == CT_THREE_LINE_TAKE_ONE)
                {
                    cbTurnLineCount = (byte)(cbTurnCardCount / 4);
                }
                else if (cbTurnOutType == CT_THREE_LINE_TAKE_TWO)
                {
                    cbTurnLineCount = (byte)(cbTurnCardCount / 5);
                }
                else
                {
                    cbTurnLineCount = (byte)(cbTurnCardCount / 3);
                }


                for (byte i = (byte)(cbTurnLineCount * 3 - 1); i < cbCardCount; i++)
                {
                    byte cbHandLogicValue = GetCardLogicValue(cbCardData[cbCardCount - i - 1]);


                    if (cbHandLogicValue <= cbLogicValue)
                    {
                        continue;
                    }
                    if ((cbTurnLineCount > 1) && (cbHandLogicValue >= 15))
                    {
                        break;
                    }


                    byte cbLineCount = 0;
                    for (byte j = (byte)(cbCardCount - i - 1); j < (byte)(cbCardCount - 2); j++)
                    {
                        OutCardResult.cbCardCount = 0;


                        if ((GetCardLogicValue(cbCardData[j]) + cbLineCount) != cbHandLogicValue)
                        {
                            continue;
                        }
                        if ((GetCardLogicValue(cbCardData[j + 1]) + cbLineCount) != cbHandLogicValue)
                        {
                            continue;
                        }
                        if ((GetCardLogicValue(cbCardData[j + 2]) + cbLineCount) != cbHandLogicValue)
                        {
                            continue;
                        }


                        OutCardResult.cbResultCard[cbLineCount * 3]         = cbCardData[j];
                        OutCardResult.cbResultCard[cbLineCount * 3 + 1]     = cbCardData[j + 1];
                        OutCardResult.cbResultCard[(cbLineCount++) * 3 + 2] = cbCardData[j + 2];


                        if (cbLineCount == cbTurnLineCount)
                        {
                            OutCardResult.cbCardCount = (byte)(cbLineCount * 3);


                            byte[] cbLeftCardData = new byte[MAX_COUNT];
                            byte   cbLeftCount    = (byte)(cbCardCount - OutCardResult.cbCardCount);
                            //CopyMemory(cbLeftCardData,cbCardData,sizeof(byte)*cbCardCount);
                            Buffer.BlockCopy(cbCardData, 0, cbLeftCardData, 0, cbCardCount);
                            RemoveCard(OutCardResult.cbResultCard, OutCardResult.cbCardCount, ref cbLeftCardData, ref cbCardCount);


                            tagAnalyseResult AnalyseResultLeft = new tagAnalyseResult();
                            AnalysebCardData(ref cbLeftCardData, cbLeftCount, ref AnalyseResultLeft);


                            if (cbTurnOutType == CT_THREE_LINE_TAKE_ONE)
                            {
                                for (byte k = 0; k < AnalyseResultLeft.cbSignedCount; k++)
                                {
                                    if (OutCardResult.cbCardCount == cbTurnCardCount)
                                    {
                                        break;
                                    }


                                    byte cbIndex      = (byte)(AnalyseResultLeft.cbSignedCount - k - 1);
                                    byte cbSignedCard = AnalyseResultLeft.cbSignedCardData[cbIndex];
                                    OutCardResult.cbResultCard[OutCardResult.cbCardCount++] = cbSignedCard;
                                }


                                for (byte k = 0; k < AnalyseResultLeft.cbDoubleCount * 2; k++)
                                {
                                    if (OutCardResult.cbCardCount == cbTurnCardCount)
                                    {
                                        break;
                                    }


                                    byte cbIndex      = (byte)(AnalyseResultLeft.cbDoubleCount * 2 - k - 1);
                                    byte cbSignedCard = AnalyseResultLeft.cbDoubleCardData[cbIndex];
                                    OutCardResult.cbResultCard[OutCardResult.cbCardCount++] = cbSignedCard;
                                }


                                for (byte k = 0; k < AnalyseResultLeft.cbThreeCount * 3; k++)
                                {
                                    if (OutCardResult.cbCardCount == cbTurnCardCount)
                                    {
                                        break;
                                    }


                                    byte cbIndex      = (byte)(AnalyseResultLeft.cbThreeCount * 3 - k - 1);
                                    byte cbSignedCard = AnalyseResultLeft.cbThreeCardData[cbIndex];
                                    OutCardResult.cbResultCard[OutCardResult.cbCardCount++] = cbSignedCard;
                                }


                                for (byte k = 0; k < AnalyseResultLeft.cbFourCount * 4; k++)
                                {
                                    if (OutCardResult.cbCardCount == cbTurnCardCount)
                                    {
                                        break;
                                    }


                                    byte cbIndex      = (byte)(AnalyseResultLeft.cbFourCount * 4 - k - 1);
                                    byte cbSignedCard = AnalyseResultLeft.cbFourCardData[cbIndex];
                                    OutCardResult.cbResultCard[OutCardResult.cbCardCount++] = cbSignedCard;
                                }
                            }


                            if (cbTurnOutType == CT_THREE_LINE_TAKE_TWO)
                            {
                                for (byte k = 0; k < AnalyseResultLeft.cbDoubleCount; k++)
                                {
                                    if (OutCardResult.cbCardCount == cbTurnCardCount)
                                    {
                                        break;
                                    }


                                    byte cbIndex     = (byte)((AnalyseResultLeft.cbDoubleCount - k - 1) * 2);
                                    byte cbCardData1 = AnalyseResultLeft.cbDoubleCardData[cbIndex];
                                    byte cbCardData2 = AnalyseResultLeft.cbDoubleCardData[cbIndex + 1];
                                    OutCardResult.cbResultCard[OutCardResult.cbCardCount++] = cbCardData1;
                                    OutCardResult.cbResultCard[OutCardResult.cbCardCount++] = cbCardData2;
                                }


                                for (byte k = 0; k < AnalyseResultLeft.cbThreeCount; k++)
                                {
                                    if (OutCardResult.cbCardCount == cbTurnCardCount)
                                    {
                                        break;
                                    }


                                    byte cbIndex     = (byte)((AnalyseResultLeft.cbThreeCount - k - 1) * 3);
                                    byte cbCardData1 = AnalyseResultLeft.cbThreeCardData[cbIndex];
                                    byte cbCardData2 = AnalyseResultLeft.cbThreeCardData[cbIndex + 1];
                                    OutCardResult.cbResultCard[OutCardResult.cbCardCount++] = cbCardData1;
                                    OutCardResult.cbResultCard[OutCardResult.cbCardCount++] = cbCardData2;
                                }


                                for (byte k = 0; k < AnalyseResultLeft.cbFourCount; k++)
                                {
                                    if (OutCardResult.cbCardCount == cbTurnCardCount)
                                    {
                                        break;
                                    }


                                    byte cbIndex     = (byte)((AnalyseResultLeft.cbFourCount - k - 1) * 4);
                                    byte cbCardData1 = AnalyseResultLeft.cbFourCardData[cbIndex];
                                    byte cbCardData2 = AnalyseResultLeft.cbFourCardData[cbIndex + 1];
                                    OutCardResult.cbResultCard[OutCardResult.cbCardCount++] = cbCardData1;
                                    OutCardResult.cbResultCard[OutCardResult.cbCardCount++] = cbCardData2;
                                }
                            }


                            if (OutCardResult.cbCardCount == cbTurnCardCount)
                            {
                                return(true);
                            }
                        }
                    }
                }

                break;
            }
            }


            if ((cbCardCount >= 4) && (cbTurnOutType != CT_MISSILE_CARD))
            {
                byte cbLogicValue = 0;
                if (cbTurnOutType == CT_BOMB_CARD)
                {
                    cbLogicValue = GetCardLogicValue(cbTurnCardData[0]);
                }


                for (byte i = 3; i < cbCardCount; i++)
                {
                    byte cbHandLogicValue = GetCardLogicValue(cbCardData[cbCardCount - i - 1]);


                    if (cbHandLogicValue <= cbLogicValue)
                    {
                        continue;
                    }


                    byte cbTempLogicValue = GetCardLogicValue(cbCardData[cbCardCount - i - 1]);
                    byte j = 0;
                    for (j = 1; j < 4; j++)
                    {
                        if (GetCardLogicValue(cbCardData[cbCardCount + j - i - 1]) != cbTempLogicValue)
                        {
                            break;
                        }
                    }
                    if (j != 4)
                    {
                        continue;
                    }


                    OutCardResult.cbCardCount     = 4;
                    OutCardResult.cbResultCard[0] = cbCardData[cbCardCount - i - 1];
                    OutCardResult.cbResultCard[1] = cbCardData[cbCardCount - i];
                    OutCardResult.cbResultCard[2] = cbCardData[cbCardCount - i + 1];
                    OutCardResult.cbResultCard[3] = cbCardData[cbCardCount - i + 2];

                    return(true);
                }
            }


            if ((cbCardCount >= 2) && (cbCardData[0] == 0x4F) && (cbCardData[1] == 0x4E))
            {
                OutCardResult.cbCardCount     = 2;
                OutCardResult.cbResultCard[0] = cbCardData[0];
                OutCardResult.cbResultCard[1] = cbCardData[1];

                return(true);
            }

            return(false);
        }
Exemplo n.º 2
0
        //
        public static void SortCardList(ref byte[] cbCardData, byte cbCardCount, byte cbSortType)
        {
            if (cbCardCount == 0)
            {
                return;
            }


            byte[] cbSortValue = new byte[MAX_COUNT];
            for (byte i = 0; i < cbCardCount; i++)
            {
                cbSortValue[i] = GetCardLogicValue(cbCardData[i]);
            }
            bool bSorted = true;
            byte cbThreeCount, cbLast = (byte)(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);


            if (cbSortType == ST_COUNT)
            {
                byte             cbIndex       = 0;
                tagAnalyseResult AnalyseResult = new tagAnalyseResult();
                AnalysebCardData(ref cbCardData, cbCardCount, ref AnalyseResult);


                Buffer.BlockCopy(AnalyseResult.cbFourCardData, 0, cbCardData, cbIndex, sizeof(byte) * AnalyseResult.cbFourCount * 4);
                cbIndex += (byte)(AnalyseResult.cbFourCount * 4);


                Buffer.BlockCopy(AnalyseResult.cbThreeCardData, 0, cbCardData, cbIndex, sizeof(byte) * AnalyseResult.cbThreeCount * 3);
                cbIndex += (byte)(AnalyseResult.cbThreeCount * 3);


                Buffer.BlockCopy(AnalyseResult.cbDoubleCardData, 0, cbCardData, cbIndex, sizeof(byte) * AnalyseResult.cbDoubleCount * 2);
                cbIndex += (byte)(AnalyseResult.cbDoubleCount * 2);


                Buffer.BlockCopy(AnalyseResult.cbSignedCardData, 0, cbCardData, cbIndex, sizeof(byte) * AnalyseResult.cbSignedCount);
                cbIndex += (byte)(AnalyseResult.cbSignedCount);
            }

            return;
        }
Exemplo n.º 3
0
        //
        public static byte GetCardType(byte[] cbCardData, byte cbCardCount)
        {
            switch (cbCardCount)
            {
            case 0:
            {
                return(CT_ERROR);
            }

            case 1:
            {
                return(CT_SINGLE);
            }

            case 2:
            {
                if ((cbCardData[0] == 0x4F) && (cbCardData[1] == 0x4E))
                {
                    return(CT_MISSILE_CARD);
                }
                if (GetCardLogicValue(cbCardData[0]) == GetCardLogicValue(cbCardData[1]))
                {
                    return(CT_DOUBLE);
                }

                return(CT_ERROR);
            }
            }

            tagAnalyseResult AnalyseResult = new tagAnalyseResult();

            AnalysebCardData(ref cbCardData, cbCardCount, ref AnalyseResult);


            if (AnalyseResult.cbFourCount > 0)
            {
                if ((AnalyseResult.cbFourCount == 1) && (cbCardCount == 4))
                {
                    return(CT_BOMB_CARD);
                }
                if ((AnalyseResult.cbFourCount == 1) && (AnalyseResult.cbSignedCount == 2) && (cbCardCount == 6))
                {
                    return(CT_FOUR_LINE_TAKE_ONE);
                }
                if ((AnalyseResult.cbFourCount == 1) && (AnalyseResult.cbDoubleCount == 2) && (cbCardCount == 8))
                {
                    return(CT_FOUR_LINE_TAKE_TWO);
                }

                return(CT_ERROR);
            }


            if (AnalyseResult.cbThreeCount > 0)
            {
                if (AnalyseResult.cbThreeCount == 1 && cbCardCount == 3)
                {
                    return(CT_THREE);
                }


                if (AnalyseResult.cbThreeCount > 1)
                {
                    byte bCardData         = AnalyseResult.cbThreeCardData[0];
                    byte cbFirstLogicValue = GetCardLogicValue(bCardData);


                    if (cbFirstLogicValue >= 15)
                    {
                        return(CT_ERROR);
                    }


                    for (byte i = 1; i < AnalyseResult.cbThreeCount; i++)
                    {
                        byte bCard = AnalyseResult.cbThreeCardData[i * 3];
                        if (cbFirstLogicValue != (GetCardLogicValue(bCard) + i))
                        {
                            return(CT_ERROR);
                        }
                    }
                }


                if (AnalyseResult.cbThreeCount * 3 == cbCardCount)
                {
                    return(CT_THREE_LINE);
                }
                if (AnalyseResult.cbThreeCount * 4 == cbCardCount)
                {
                    return(CT_THREE_LINE_TAKE_ONE);
                }
                if ((AnalyseResult.cbThreeCount * 5 == cbCardCount) && (AnalyseResult.cbDoubleCount == AnalyseResult.cbThreeCount))
                {
                    return(CT_THREE_LINE_TAKE_TWO);
                }

                return(CT_ERROR);
            }


            if (AnalyseResult.cbDoubleCount >= 3)
            {
                byte bCardData         = AnalyseResult.cbDoubleCardData[0];
                byte cbFirstLogicValue = GetCardLogicValue(bCardData);


                if (cbFirstLogicValue >= 15)
                {
                    return(CT_ERROR);
                }


                for (byte i = 1; i < AnalyseResult.cbDoubleCount; i++)
                {
                    byte bCard = AnalyseResult.cbDoubleCardData[i * 2];
                    if (cbFirstLogicValue != (GetCardLogicValue(bCard) + i))
                    {
                        return(CT_ERROR);
                    }
                }


                if ((AnalyseResult.cbDoubleCount * 2) == cbCardCount)
                {
                    return(CT_DOUBLE_LINE);
                }

                return(CT_ERROR);
            }


            if ((AnalyseResult.cbSignedCount >= 5) && (AnalyseResult.cbSignedCount == cbCardCount))
            {
                byte bCardData         = AnalyseResult.cbSignedCardData[0];
                byte cbFirstLogicValue = GetCardLogicValue(bCardData);


                if (cbFirstLogicValue >= 15)
                {
                    return(CT_ERROR);
                }


                for (byte i = 1; i < AnalyseResult.cbSignedCount; i++)
                {
                    byte bCard = AnalyseResult.cbSignedCardData[i];
                    if (cbFirstLogicValue != (GetCardLogicValue(bCard) + i))
                    {
                        return(CT_ERROR);
                    }
                }

                return(CT_SINGLE_LINE);
            }

            return(CT_ERROR);
        }
Exemplo n.º 4
0
        //
        public static bool CompareCard(byte[] cbFirstCard, byte[] cbNextCard, byte cbFirstCount, byte cbNextCount)
        {
            byte cbNextType  = GetCardType(cbNextCard, cbNextCount);
            byte cbFirstType = GetCardType(cbFirstCard, cbFirstCount);


            if (cbNextType == CT_ERROR)
            {
                return(false);
            }
            if (cbNextType == CT_MISSILE_CARD)
            {
                return(true);
            }


            if ((cbFirstType != CT_BOMB_CARD) && (cbNextType == CT_BOMB_CARD))
            {
                return(true);
            }
            if ((cbFirstType == CT_BOMB_CARD) && (cbNextType != CT_BOMB_CARD))
            {
                return(false);
            }


            if ((cbFirstType != cbNextType) || (cbFirstCount != cbNextCount))
            {
                return(false);
            }


            switch (cbNextType)
            {
            case CT_SINGLE:
            case CT_DOUBLE:
            case CT_THREE:
            case CT_SINGLE_LINE:
            case CT_DOUBLE_LINE:
            case CT_THREE_LINE:
            case CT_BOMB_CARD:
            {
                byte cbNextLogicValue  = GetCardLogicValue(cbNextCard[0]);
                byte cbFirstLogicValue = GetCardLogicValue(cbFirstCard[0]);


                return(cbNextLogicValue > cbFirstLogicValue);
            }

            case CT_THREE_LINE_TAKE_ONE:
            case CT_THREE_LINE_TAKE_TWO:
            {
                tagAnalyseResult NextResult  = new tagAnalyseResult();
                tagAnalyseResult FirstResult = new tagAnalyseResult();
                AnalysebCardData(ref cbNextCard, cbNextCount, ref NextResult);
                AnalysebCardData(ref cbFirstCard, cbFirstCount, ref FirstResult);


                byte cbNextLogicValue  = GetCardLogicValue(NextResult.cbThreeCardData[0]);
                byte cbFirstLogicValue = GetCardLogicValue(FirstResult.cbThreeCardData[0]);


                return(cbNextLogicValue > cbFirstLogicValue);
            }

            case CT_FOUR_LINE_TAKE_ONE:
            case CT_FOUR_LINE_TAKE_TWO:
            {
                tagAnalyseResult NextResult  = new tagAnalyseResult();
                tagAnalyseResult FirstResult = new tagAnalyseResult();
                AnalysebCardData(ref cbNextCard, cbNextCount, ref NextResult);
                AnalysebCardData(ref cbFirstCard, cbFirstCount, ref FirstResult);


                byte cbNextLogicValue  = GetCardLogicValue(NextResult.cbFourCardData[0]);
                byte cbFirstLogicValue = GetCardLogicValue(FirstResult.cbFourCardData[0]);


                return(cbNextLogicValue > cbFirstLogicValue);
            }
            }

            return(false);
        }
Exemplo n.º 5
0
        //
        public static bool AnalysebCardData(ref byte[] cbCardData, byte cbCardCount, ref tagAnalyseResult AnalyseResult)
        {
            for (byte i = 0; i < cbCardCount; i++)
            {
                byte cbSameCount  = 1;
                byte cbLogicValue = GetCardLogicValue(cbCardData[i]);
                if (cbLogicValue <= 0)
                {
                    return(false);
                }

                for (byte j = (byte)(i + 1); j < cbCardCount; j++)
                {
                    if (GetCardLogicValue(cbCardData[j]) != cbLogicValue)
                    {
                        break;
                    }

                    cbSameCount++;
                }


                switch (cbSameCount)
                {
                case 1:
                {
                    byte cbIndex = AnalyseResult.cbSignedCount++;
                    AnalyseResult.cbSignedCardData[cbIndex * cbSameCount] = cbCardData[i];
                    break;
                }

                case 2:
                {
                    byte cbIndex = AnalyseResult.cbDoubleCount++;
                    AnalyseResult.cbDoubleCardData[cbIndex * cbSameCount]     = cbCardData[i];
                    AnalyseResult.cbDoubleCardData[cbIndex * cbSameCount + 1] = cbCardData[i + 1];
                    break;
                }

                case 3:
                {
                    byte cbIndex = AnalyseResult.cbThreeCount++;
                    AnalyseResult.cbThreeCardData[cbIndex * cbSameCount]     = cbCardData[i];
                    AnalyseResult.cbThreeCardData[cbIndex * cbSameCount + 1] = cbCardData[i + 1];
                    AnalyseResult.cbThreeCardData[cbIndex * cbSameCount + 2] = cbCardData[i + 2];
                    break;
                }

                case 4:
                {
                    byte cbIndex = AnalyseResult.cbFourCount++;
                    AnalyseResult.cbFourCardData[cbIndex * cbSameCount]     = cbCardData[i];
                    AnalyseResult.cbFourCardData[cbIndex * cbSameCount + 1] = cbCardData[i + 1];
                    AnalyseResult.cbFourCardData[cbIndex * cbSameCount + 2] = cbCardData[i + 2];
                    AnalyseResult.cbFourCardData[cbIndex * cbSameCount + 3] = cbCardData[i + 3];
                    break;
                }
                }


                i = (byte)(i + cbSameCount - 1);
            }

            return(true);
        }