コード例 #1
0
        public ListViewItemPokerType(PokerType pokerType)
        {
            PokerType = pokerType;

            StackPanel sp = new StackPanel {
                Orientation = Orientation.Horizontal
            };

            Image image = new Image
            {
                Source = new BitmapImage(new Uri(string.Format(@"pack://application:,,,/Images/Resources/Size16x16/tag_blue.png"), UriKind.Absolute)),
                Width  = 16,
                Height = 16,
                Margin = new Thickness(0, 0, 0, 0)
            };

            Label label = new Label
            {
                Content = PokerType.Name,
                Padding = new Thickness(0),
                Margin  = new Thickness(5, 0, 0, 0)
            };

            sp.Children.Add(image);
            sp.Children.Add(label);
            Content = sp;
        }
コード例 #2
0
        private Sprite LoadSprite(List <int> list)
        {
            PokerType pokerType = LookupPokerType.Instance.GetDicPokerType(list);

            Sprite sprite = GuPaiJiuPrefabManager.Instance.LoadSprite(pokerType.ToString());

            return(sprite);
        }
コード例 #3
0
        private void Button_CloneSelected_Click(object sender, RoutedEventArgs e)
        {
            var selectedItem = ListView_PokerTypes.SelectedItem as ListViewItemPokerType;

            if (selectedItem != null)
            {
                var fromXElement = PokerType.FromXElement(selectedItem.PokerType.ToXElement());
                if (fromXElement != null)
                {
                    fromXElement.Name = fromXElement.Name + string.Format(" {0}", DateTime.Now.Ticks);
                    App.PokerTypeManager.Add(fromXElement);
                    UpdateListView();
                }
            }
        }
コード例 #4
0
        private void GetContentTimer(string title, string className, Tournament tournament, decimal sb, decimal bb, out string value, out bool visibility)
        {
            if (!Config.HudTimerShowHandCount)
            {
                int pokerTypeErrors = -1;
                if (PokerType == null)
                {
                    PokerType = App.PokerTypeManager.GetPokerType(title, className, out pokerTypeErrors);
                    if (pokerTypeErrors != 0)
                    {
                        PokerType = null;
                    }
                }
                if (PokerType != null)
                {
                    DateTime dateTimeUtcNow       = DateTime.UtcNow.AddSeconds(-Config.HudTimerDiff);
                    DateTime dateTimeUtcNextLevel = tournament.GetFirstHandTimestampET();
                    while (dateTimeUtcNextLevel < dateTimeUtcNow)
                    {
                        dateTimeUtcNextLevel = dateTimeUtcNextLevel + PokerType.LevelLength;
                    }
                    TimeSpan timeSpan = dateTimeUtcNextLevel - dateTimeUtcNow;
                    value = string.Format("{0:00}:{1:00}", timeSpan.Minutes, timeSpan.Seconds);
                }
                else
                {
                    if (pokerTypeErrors == 1)
                    {
                        value = Config.HudTimerPokerTypeNotFound;
                    }
                    else if (pokerTypeErrors == 2)
                    {
                        value = Config.HudTimerMultiplePokerTypes;
                    }
                    else
                    {
                        value = string.Format("Unknown Error");
                    }
                }
            }
            else
            {
                value = string.Format("{0}", tournament.CountLevelHands(sb, bb) + 1);
            }

            visibility = true;
        }
コード例 #5
0
    public static PokerType CalcPokerType(Poker[] pokers)
    {
        PokerType pokerType = null;

        if (IsBomb(pokers))
        {
            // 炸弹
            // Debug.Log("Bomb--------------------------------------------------");
            pokerType = new BombPokerType(pokers);
        }
        else if (IsFlush(pokers))
        {
            // 同花
            if (IsStraight(pokers))
            {
                // 同花顺
                // Debug.Log("Flush and straight--------------------------------------------------");
                pokerType = new FlushAndStraightPokerType(pokers);
            }
            else
            {
                // Debug.Log("Flush--------------------------------------------------");
                pokerType = new FlushPokerType(pokers);
            }
        }
        else if (IsStraight(pokers))
        {
            // 顺子
            // Debug.Log("Straight--------------------------------------------------");
            pokerType = new StraightPokerType(pokers);
        }
        else if (IsDouble(pokers))
        {
            // 对子
            // Debug.Log("Double--------------------------------------------------");
            pokerType = new DoublePokerType(pokers);
        }
        else
        {
            // 普通牌
            // Debug.Log("Normal--------------------------------------------------");
            pokerType = new NormalPokerType(pokers);
        }
        return(pokerType);
    }
コード例 #6
0
    public Comb(ArrayList intPokers)
    {
        List <int> pokers     = new List <int>();
        int        intpLenght = intPokers.Count;

        for (int f = 0; f < intpLenght; f++)
        {
            pokers.Add((intPokers[f] as GameObject).GetComponent <PokerAttr>().size);
        }

        this.pokers.AddRange(pokers);
        length = pokers.Count;
        if (length == 1)
        {
            size = pokers[0];
            type = PokerType.Single;
            return;
        }
        type = IsSingle(pokers);
        if (type != PokerType.Without)
        {
            return;
        }
        type = IsDouble(pokers);
        if (type != PokerType.Without)
        {
            return;
        }
        type = IsThree(pokers);
        if (type != PokerType.Without)
        {
            return;
        }
        type = IsFour(pokers);
        if (type != PokerType.Without)
        {
            return;
        }
        if (pokers[0] == 16 && pokers[17] == 17)
        {
            type = PokerType.Bomb;
            size = 16;
            return;
        }
    }
コード例 #7
0
 public void draw(LeanCloud.Player player, Poker[] pokers)
 {
     this.gameObject.SetActive(true);
     this.lcPlayer  = player;
     this.pokers    = pokers;
     this.pokerType = PokerType.CalcPokerType(this.pokers);
     for (int i = 0; i < pokers.Length; i++)
     {
         Poker   poker   = this.pokers[i];
         PokerVC pokerVC = this.pokerVCs[i];
         if (this.lcPlayer == Play.Player)
         {
             pokerVC.show(poker);
         }
         else
         {
             pokerVC.showBack();
         }
     }
 }
コード例 #8
0
        private void Button_RestoreDefaults_Click(object sender, RoutedEventArgs e)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("Do you want to restore default poker type values?");
            sb.AppendLine("This will overwrite only default named poker types.");
            sb.AppendLine("Custom poker types will remain untouched.");
            sb.AppendLine();
            sb.AppendLine("Default poker types:");
            sb.AppendLine();
            List <PokerType> defaultPokerTypes = PokerType.GetDefaultValues().ToList();

            foreach (PokerType pokerType in defaultPokerTypes)
            {
                sb.AppendLine("     " + pokerType.Name);
            }

            WindowMessageResult windowMessageResult = WindowMessage.ShowDialog(
                sb.ToString(),
                "Restore Default Poker Types",
                WindowMessageButtons.YesNoCancel,
                WindowMessageImage.Warning,
                App.WindowMain);

            if (windowMessageResult == WindowMessageResult.Yes)
            {
                foreach (PokerType pokerType in App.PokerTypeManager.GetPokerTypesCopy())
                {
                    if (!defaultPokerTypes.Any(a => a.Name.Equals(pokerType.Name)))
                    {
                        defaultPokerTypes.Add(pokerType);
                    }
                }
                App.PokerTypeManager.RemoveAll();
                App.PokerTypeManager.Add(defaultPokerTypes);
                UpdateListView();
            }
        }
コード例 #9
0
 public Comb(List <int> pokers)
 {
     this.pokers.AddRange(pokers);
     length = pokers.Count;
     if (length == 1)
     {
         size = pokers[0];
         type = PokerType.Single;
         return;
     }
     type = IsSingle(pokers);
     if (type != PokerType.Without)
     {
         return;
     }
     type = IsDouble(pokers);
     if (type != PokerType.Without)
     {
         return;
     }
     type = IsThree(pokers);
     if (type != PokerType.Without)
     {
         return;
     }
     type = IsFour(pokers);
     if (type != PokerType.Without)
     {
         return;
     }
     if (pokers[0] == 16 && pokers[17] == 17)
     {
         type = PokerType.Bomb;
         size = 16;
         return;
     }
 }
コード例 #10
0
 /// <summary>
 /// 查找牌的类型
 /// </summary>
 /// <param name="list"></param>
 /// <param name="pokerType1"></param>
 /// <param name="pokerType2"></param>
 public void GetDicPokerType(List <int> list, out PokerType pokerType1, out PokerType pokerType2)
 {
     if (pokerList1.Count != 0)
     {
         pokerList1.Clear();
     }
     if (pokerList2.Count != 0)
     {
         pokerList2.Clear();
     }
     for (int i = 0; i < list.Count; i++)
     {
         if (i < 2)
         {
             pokerList1.Add(list[i]);
         }
         else
         {
             pokerList2.Add(list[i]);
         }
     }
     pokerType1 = GetDicPokerType(pokerList1);
     pokerType2 = GetDicPokerType(pokerList2);
 }
コード例 #11
0
        public void UpdateListView(PokerType pokerTypeToSelect = null)
        {
            var listView = ListView_PokerTypes;

            listView.Items.Clear();
            foreach (var tableTile in App.PokerTypeManager.GetPokerTypesCopy())
            {
                listView.Items.Add(new ListViewItemPokerType(tableTile));
            }

            if (pokerTypeToSelect != null)
            {
                foreach (var item in listView.Items)
                {
                    if (((ListViewItemPokerType)item).PokerType.Name.Equals(pokerTypeToSelect.Name))
                    {
                        listView.SelectedItem = item;
                        break;
                    }
                }
            }

            GridView_Name.ResetColumnWidths();
        }
コード例 #12
0
 public void Reset()
 {
     rank = PokerRank.Rank_4;
     type = PokerType.Type_Unknown;
 }
コード例 #13
0
        /// <summary>
        /// Calculates the power of Five cards of mixed suits in sequence. Stronger than any type of three cards.
        /// </summary>
        /// <param name="currentPlayer"></param>
        /// <param name="winList"></param>
        /// <param name="reserveArray"></param>
        /// <param name="sorted"></param>
        /// <param name="Straight"></param>
        public void rFlush(IPlayer currentPlayer, int index, ref bool vf, List<PokerType> winList, int[] reserveArray, ref PokerType sorted, int[] Straight)
        {
            if (currentPlayer.Type >= -1)
            {
                var clubs = Straight.Where(o => o % 4 == 0).ToArray();
                var diamonds = Straight.Where(o => o % 4 == 1).ToArray();
                var hearths = Straight.Where(o => o % 4 == 2).ToArray();
                var spades = Straight.Where(o => o % 4 == 3).ToArray();

                var flushTypes = new List<int[]>
                                        {
                                            clubs,
                                            diamonds,
                                            hearths,
                                            spades
                                        };
                foreach (var currentFlushType in flushTypes)
                {
                    if (currentFlushType.Length == 3 || currentFlushType.Length == 4)
                    {
                        double playerType = 5;
                        double multiplyer = 0;
                        if (reserveArray[index] % 4 == reserveArray[index + 1] % 4 && reserveArray[index] % 4 == currentFlushType[0] % 4)
                        {
                            if (reserveArray[index] / 4 > currentFlushType.Max() / 4)
                            {
                                multiplyer = reserveArray[index];
                                this.ApplyingCombination(currentPlayer, winList, playerType, multiplyer, ref sorted);
                                vf = true;
                            }

                            if (reserveArray[index + 1] / 4 > currentFlushType.Max() / 4)
                            {
                                multiplyer = reserveArray[index + 1];
                                this.ApplyingCombination(currentPlayer, winList, playerType, multiplyer, ref sorted);
                                vf = true;
                            }
                            else if (reserveArray[index] / 4 < currentFlushType.Max() / 4 && reserveArray[index + 1] / 4 < currentFlushType.Max() / 4)
                            {
                                multiplyer = currentFlushType.Max();
                                this.ApplyingCombination(currentPlayer, winList, playerType, multiplyer, ref sorted);
                                vf = true;
                            }
                        }
                    }

                    if (currentFlushType.Length == 4)//different cards in hand
                    {
                        double playerType = 5;
                        if (reserveArray[index] % 4 != reserveArray[index + 1] % 4 && reserveArray[index] % 4 == currentFlushType[0] % 4)
                        {
                            double multiplyer = 0;
                            if (reserveArray[index] / 4 > currentFlushType.Max() / 4)
                            {
                                multiplyer = reserveArray[index];
                            }
                            else
                            {
                                multiplyer = currentFlushType.Max();
                            }

                            ApplyingCombination(currentPlayer, winList, playerType, multiplyer, ref sorted);
                            vf = true;
                        }

                        if (reserveArray[index + 1] % 4 != reserveArray[index] % 4 && reserveArray[index + 1] % 4 == currentFlushType[0] % 4)
                        {
                            double multiplyer = 0;
                            if (reserveArray[index + 1] / 4 > currentFlushType.Max() / 4)
                            {
                                multiplyer = reserveArray[index + 1];
                            }

                            else
                            {
                                multiplyer = currentFlushType.Max();
                            }

                            ApplyingCombination(currentPlayer, winList, playerType, multiplyer, ref sorted);
                            vf = true;
                        }
                    }

                    if (currentFlushType.Length == 5)
                    {
                        double playerType = 5;
                        double multiplyer = 0;
                        if (reserveArray[index] % 4 == currentFlushType[0] % 4 && reserveArray[index] / 4 > currentFlushType.Min() / 4)
                        {
                            multiplyer = reserveArray[index];
                            ApplyingCombination(currentPlayer, winList, playerType, multiplyer, ref sorted);
                            vf = true;
                        }

                        if (reserveArray[index + 1] % 4 == currentFlushType[0] % 4 && reserveArray[index + 1] / 4 > currentFlushType.Min() / 4)
                        {
                            multiplyer = reserveArray[index + 1];
                            ApplyingCombination(currentPlayer, winList, playerType, multiplyer, ref sorted);
                            vf = true;
                        }
                        else if (reserveArray[index] / 4 < currentFlushType.Min() / 4 && reserveArray[index + 1] / 4 < currentFlushType.Min())
                        {
                            multiplyer = currentFlushType.Max();
                            ApplyingCombination(currentPlayer, winList, playerType, multiplyer, ref sorted);
                            vf = true;
                        }
                    }

                    //ace
                    if (currentFlushType.Length > 0)
                    {
                        double playerType = 5.5;
                        double multiplyer = 13;
                        if (reserveArray[index] / 4 == 0 && reserveArray[index] % 4 == currentFlushType[0] % 4 && vf && currentFlushType.Length > 0)
                        {
                            ApplyingCombination(currentPlayer, winList, playerType, multiplyer, ref sorted);
                        }
                        if (reserveArray[index + 1] / 4 == 0 && reserveArray[index + 1] % 4 == currentFlushType[0] % 4 && vf
                            && clubs.Length > 0)
                        {
                            ApplyingCombination(currentPlayer, winList, playerType, multiplyer, ref sorted);
                        }
                    }
                }
            }
        }
コード例 #14
0
 public void set(PokerType Type, List <Card> cards, int val)
 {
     this.Type  = Type;
     this.cards = cards;
     value      = val;
 }
コード例 #15
0
        /// <summary>
        /// Calculate the power of one pair and three cards of the same kind. Stronger than any flush.
        /// </summary>
        /// <param name="currentPlayer"></param>
        /// <param name="type"></param>
        /// <param name="done"></param>
        /// <param name="winList"></param>
        /// <param name="reserveArray"></param>
        /// <param name="sorted"></param>
        /// <param name="Straight"></param>
        public void rFullHouse(IPlayer currentPlayer, ref double type, ref bool done, List<PokerType> winList, int[] reserveArray, ref PokerType sorted, int[] Straight)
        {
            if (currentPlayer.Type >= -1)
            {
                double playerType = 6;
                type = currentPlayer.Power;
                for (int j = 0; j <= 12; j++)
                {
                    var fh = Straight.Where(o => o / 4 == j).ToArray();
                    if (fh.Length == 3 || done)
                    {
                        if (fh.Length == 2)
                        {
                            double multiplyer = 0;
                            if (fh.Max() / 4 == 0)
                            {
                                multiplyer = 13 * 2;
                                this.ApplyingCombination(currentPlayer, winList, playerType, multiplyer, ref sorted);
                                break;
                            }
                            if (fh.Max() / 4 > 0)
                            {
                                multiplyer = fh.Max() / 4 * 2;
                                this.ApplyingCombination(currentPlayer, winList, playerType, multiplyer, ref sorted);
                                break;
                            }
                        }
                        if (!done)
                        {
                            if (fh.Max() / 4 == 0)
                            {
                                currentPlayer.Power = 13;
                                done = true;
                                j = -1;
                            }
                            else
                            {
                                currentPlayer.Power = fh.Max() / 4;
                                done = true;
                                j = -1;
                            }
                        }
                    }
                }

                if (currentPlayer.Type != 6)
                {
                    currentPlayer.Power = type;
                }
            }
        }
コード例 #16
0
 public Comb()
 {
     type = PokerType.Empty;
 }
コード例 #17
0
        /// <summary>
        /// Calculating the power of pair of cards in the current player hand
        /// </summary>
        /// <param name="currentPlayer"></param>
        /// <param name="index"></param>
        /// <param name="winList"></param>
        /// <param name="reserveArray"></param>
        /// <param name="sorted"></param>
        public void rPairTwoPair(IPlayer currentPlayer, int index, List<PokerType> winList, int[] reserveArray, ref PokerType sorted)
        {
            if (currentPlayer.Type >= -1)
            {
                bool msgbox = false;
                bool msgbox1 = false;
                for (int tc = 16; tc >= 12; tc--)
                {
                    int max = tc - 12;
                    for (int k = 1; k <= max; k++)
                    {
                        if (tc - k < 12)
                        {
                            max--;
                        }
                        if (tc - k >= 12)
                        {
                            if (reserveArray[tc] / 4 == reserveArray[tc - k] / 4)
                            {
                                if (reserveArray[tc] / 4 != reserveArray[index] / 4 && reserveArray[tc] / 4 != reserveArray[index + 1] / 4 && currentPlayer.Type == 1)
                                {
                                    if (!msgbox)
                                    {
                                        double playerType = 2;
                                        double multiplyer = 0;
                                        if (reserveArray[index + 1] / 4 == 0)
                                        {
                                            multiplyer = (reserveArray[index] / 4) * 2 + 13 * 4;
                                            this.ApplyingCombination(currentPlayer, winList, playerType, multiplyer, ref sorted);
                                        }

                                        if (reserveArray[index] / 4 == 0)
                                        {
                                            multiplyer = (reserveArray[index + 1] / 4) * 2 + 13 * 4;
                                            this.ApplyingCombination(currentPlayer, winList, playerType, multiplyer, ref sorted);
                                        }

                                        if (reserveArray[index + 1] / 4 != 0)
                                        {
                                            multiplyer = (reserveArray[tc] / 4) * 2 + (reserveArray[index + 1] / 4) * 2;
                                            this.ApplyingCombination(currentPlayer, winList, playerType, multiplyer, ref sorted);
                                        }

                                        if (reserveArray[index] / 4 != 0)
                                        {
                                            multiplyer = (reserveArray[tc] / 4) * 2 + (reserveArray[index] / 4) * 2;
                                            this.ApplyingCombination(currentPlayer, winList, playerType, multiplyer, ref sorted);
                                        }
                                    }

                                    msgbox = true;
                                }

                                if (currentPlayer.Type == -1)
                                {
                                    if (!msgbox1)
                                    {
                                        double playerType = 0;
                                        double multiplyer = 0;
                                        if (reserveArray[index] / 4 > reserveArray[index + 1] / 4)
                                        {
                                            if (reserveArray[tc] / 4 == 0)
                                            {
                                                multiplyer = 13 + reserveArray[index] / 4;
                                            }

                                            else
                                            {
                                                multiplyer = reserveArray[tc] / 4 + reserveArray[index] / 4 + currentPlayer.Type * 100;
                                            }
                                        }
                                        else
                                        {
                                            if (reserveArray[tc] / 4 == 0)
                                            {
                                                multiplyer = 13 + reserveArray[index + 1];
                                            }
                                            else
                                            {
                                                multiplyer = reserveArray[tc] / 4 + reserveArray[index + 1] / 4 + currentPlayer.Type * 100;
                                            }
                                        }

                                        ApplyingCombination(currentPlayer, winList, playerType, multiplyer, ref sorted);
                                    }

                                    msgbox1 = true;
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #18
0
 private void ApplyingCombination(IPlayer currentPlayer, List<PokerType> winList, double type, double multiplyer, ref PokerType sorted)
 {
     currentPlayer.Type = type;
     currentPlayer.Power = multiplyer + currentPlayer.Type * 100;
     winList.Add(new PokerType() { Power = currentPlayer.Power, Current = type });
     sorted = winList.OrderByDescending(op1 => op1.Current).ThenByDescending(op1 => op1.Power).First();
 }
コード例 #19
0
        /// <summary>
        /// Calculates the power of five cards from same suit in a sequance. The strongest combination in the game.
        /// </summary>
        /// <param name="currentPlayer"></param>
        /// <param name="winList"></param>
        /// <param name="reserveArray"></param>
        /// <param name="sorted"></param>
        /// <param name="clubs"></param>
        /// <param name="diamonds"></param>
        /// <param name="hearts"></param>
        /// <param name="spades"></param>
        public void rStraightFlush(IPlayer currentPlayer, List<PokerType> winList, int[] reserveArray, ref PokerType sorted, int[] clubs, int[] diamonds, int[] hearts, int[] spades)
        {
            var straightTypes = new List<int[]>() { clubs, diamonds, hearts, spades };
            if (currentPlayer.Type >= -1)
            {
                foreach (var currentStraightType in straightTypes)
                {
                    if (currentStraightType.Length >= 5)
                    {
                        double multiplyer = currentStraightType.Max() / 4;
                        if (currentStraightType[0] + 4 == currentStraightType[4])
                        {
                            double playerType = 8;
                            this.ApplyingCombination(currentPlayer, winList, playerType, multiplyer, ref sorted);
                        }

                        if (currentStraightType[0] == 0 && currentStraightType[1] == 9 &&
                            currentStraightType[2] == 10 && currentStraightType[3] == 11 &&
                            currentStraightType[0] + 12 == currentStraightType[4])
                        {
                            double playerType = 9;
                            this.ApplyingCombination(currentPlayer, winList, playerType, multiplyer, ref sorted);
                        }
                    }
                }

            }
        }
コード例 #20
0
        /// <summary>
        /// Calculating the power of three cards from the same kind. Stronger than any type of pair.
        /// </summary>
        /// <param name="currentPlayer"></param>
        /// <param name="winList"></param>
        /// <param name="reserveArray"></param>
        /// <param name="sorted"></param>
        /// <param name="Straight"></param>
        public void rStraight(IPlayer currentPlayer, List<PokerType> winList, int[] reserveArray, ref PokerType sorted, int[] Straight)
        {
            if (currentPlayer.Type >= -1)
            {
                var op = Straight.Select(o => o / 4).Distinct().ToArray();
                double playerType = 4;
                for (int j = 0; j < op.Length - 4; j++)
                {
                    if (op[j] + 4 == op[j + 4])
                    {
                        double multiplyer = 0;
                        if (op.Max() - 4 == op[j])
                        {
                            multiplyer = op.Max();
                        }

                        else
                        {
                            multiplyer = op[j + 4];
                        }

                        this.ApplyingCombination(currentPlayer, winList, playerType, multiplyer, ref sorted);
                    }

                    if (op[j] == 0 && op[j + 1] == 9 && op[j + 2] == 10 && op[j + 3] == 11 && op[j + 4] == 12)
                    {
                        double multiplyer = 13;
                        this.ApplyingCombination(currentPlayer, winList, playerType, multiplyer, ref sorted);
                    }
                }
            }
        }
コード例 #21
0
        /// <summary>
        /// Calculating the power of a current card when there are no pairs or higher priority card combinations
        /// </summary>
        /// <param name="currentPlayer"></param>
        /// <param name="index"></param>
        /// <param name="winList"></param>
        /// <param name="reserveArray"></param>
        /// <param name="sorted"></param>
        public void rThreeOfAKind(IPlayer currentPlayer, List<PokerType> winList, int[] reserveArray, ref PokerType sorted, int[] Straight)
        {
            if (currentPlayer.Type >= -1)
            {
                for (int j = 0; j <= 12; j++)
                {
                    var fh = Straight.Where(o => o / 4 == j).ToArray();
                    if (fh.Length == 3)
                    {
                        double playerType = 3;
                        double multiplyer = 0;
                        if (fh.Max() / 4 == 0)
                        {
                            multiplyer = 13 * 3;
                        }
                        else
                        {
                            multiplyer = fh[0] / 4 + fh[1] / 4 + fh[2] / 4;
                        }

                        this.ApplyingCombination(currentPlayer, winList, playerType, multiplyer, ref sorted);
                    }
                }
            }
        }
コード例 #22
0
        /// <summary>
        /// Calculating the power of two pairs of cards
        /// </summary>
        /// <param name="currentPlayer"></param>
        /// <param name="index"></param>
        /// <param name="winList"></param>
        /// <param name="reserveArray"></param>
        /// <param name="sorted"></param>
        public void rHighCard(IPlayer currentPlayer, int index, List<PokerType> winList, int[] reserveArray, ref PokerType sorted)
        {
            if (currentPlayer.Type == -1)
            {
                currentPlayer.Power = -1;
                if (reserveArray[index] / 4 > reserveArray[index + 1] / 4)
                {
                    currentPlayer.Power = reserveArray[index] / 4;
                }

                else
                {
                    currentPlayer.Power = reserveArray[index + 1] / 4;
                }

                winList.Add(new PokerType() { Power = currentPlayer.Power, Current = -1 });
                sorted = winList.OrderByDescending(op1 => op1.Current).ThenByDescending(op1 => op1.Power).First();

                if (reserveArray[index] / 4 == 0 || reserveArray[index + 1] / 4 == 0)
                {
                    currentPlayer.Power = 13;
                    winList.Add(new PokerType() { Power = currentPlayer.Power, Current = -1 });
                    sorted = winList.OrderByDescending(op1 => op1.Current).ThenByDescending(op1 => op1.Power).First();
                }
            }
        }
コード例 #23
0
 public PokerHand(PokerType Type, List <Card> cards, int val)
 {
     this.Type  = Type;
     this.cards = cards;
     this.value = val;
 }
コード例 #24
0
        /// <summary>
        /// <summary>
        /// Calculate the power of four cards from the same kind. Stronger than any type of full house.
        /// </summary>
        /// <param name="currentPlayer"></param>
        /// <param name="winList"></param>
        /// <param name="reserveArray"></param>
        /// <param name="sorted"></param>
        /// <param name="Straight"></param>
        public void rFourOfAKind(IPlayer currentPlayer, List<PokerType> winList, int[] reserveArray, ref PokerType sorted, int[] Straight)
        {
            if (currentPlayer.Type >= -1)
            {
                double playerType = 7;
                for (int j = 0; j <= 3; j++)
                {
                    double multiplyer = 0;
                    if (Straight[j] / 4 == Straight[j + 1] / 4 && Straight[j] / 4 == Straight[j + 2] / 4 &&
                        Straight[j] / 4 == Straight[j + 3] / 4)
                    {
                        multiplyer = (Straight[j] / 4) * 4;
                        this.ApplyingCombination(currentPlayer, winList, playerType, multiplyer, ref sorted);
                    }

                    if (Straight[j] / 4 == 0 && Straight[j + 1] / 4 == 0 && Straight[j + 2] / 4 == 0 && Straight[j + 3] / 4 == 0)
                    {
                        multiplyer = 13 * 4;
                        this.ApplyingCombination(currentPlayer, winList, playerType, multiplyer, ref sorted);
                    }
                }
            }
        }
コード例 #25
0
 public PokerHand(PokerType Type, List <Card> cards)
 {
     this.Type  = Type;
     this.cards = cards;
 }
コード例 #26
0
        public void rPairFromHand(IPlayer currentPlayer, int index, List<PokerType> winList, int[] reserveArray, ref PokerType sorted)
        {
            if (currentPlayer.Type >= -1)
            {
                bool msgbox = false;
                double playerType = 1;
                double multiplyer = 0;
                if (reserveArray[index] / 4 == reserveArray[index + 1] / 4)
                {
                    if (!msgbox)
                    {
                        if (reserveArray[index] / 4 == 0)
                        {
                            multiplyer = 13 * 4 + currentPlayer.Type * 100;
                        }
                        else
                        {
                            multiplyer = (reserveArray[index + 1] / 4) * 4;
                        }

                        this.ApplyingCombination(currentPlayer, winList, playerType, multiplyer, ref sorted);
                    }
                    msgbox = true;
                }
                for (int tc = 16; tc >= 12; tc--)
                {
                    if (reserveArray[index + 1] / 4 == reserveArray[tc] / 4)
                    {
                        if (!msgbox)
                        {
                            if (reserveArray[index + 1] / 4 == 0)
                            {
                                multiplyer = 13 * 4 + reserveArray[index] / 4;
                            }
                            else
                            {
                                multiplyer = (reserveArray[index + 1] / 4) * 4 + reserveArray[index] / 4;
                            }

                            this.ApplyingCombination(currentPlayer, winList, playerType, multiplyer, ref sorted);
                        }
                        msgbox = true;
                    }
                    if (reserveArray[index] / 4 == reserveArray[tc] / 4)
                    {
                        if (!msgbox)
                        {
                            if (reserveArray[index] / 4 == 0)
                            {
                                multiplyer = 13 * 4 + reserveArray[index + 1] / 4;
                            }
                            else
                            {
                                multiplyer = (reserveArray[tc] / 4) * 4 + reserveArray[index + 1] / 4;
                            }

                            this.ApplyingCombination(currentPlayer, winList, playerType, multiplyer, ref sorted);
                        }

                        msgbox = true;
                    }
                }
            }
        }