Example #1
0
        public void UpdateMenu()
        {
            BTPlayerHand hand = Hand;

            if (SortBySuit)
            {
                hand.SortBySuit();
            }
            else
            {
                hand.SortByNumber();
            }

            var rows = new List <InlineKeyboardButton[]>();

            var cardButtons = new List <Tuple <string, string> >();

            foreach (BTCard card in hand)
            {
                if (ChosenIndexes.Contains(card.Index))
                {
                    cardButtons.Add(new Tuple <string, string>(card.Selected(), $"{GameId}|{TelegramId}|card|{card.Index}"));
                }
                else
                {
                    cardButtons.Add(new Tuple <string, string>(card.GetCardName(), $"{GameId}|{TelegramId}|card|{card.Index}"));
                }
            }


            var row = new List <InlineKeyboardButton>();

            for (int i = 0; i < cardButtons.Count; i += 5)
            {
                row.Clear();
                var subButtons = cardButtons.Skip(i).Take(5).ToList();
                foreach (var button in subButtons)
                {
                    row.Add(new InlineKeyboardCallbackButton(button.Item1, button.Item2));
                }
                rows.Add(row.ToArray());
            }

            var footer1 = new List <InlineKeyboardButton>();

            if (ChosenIndexes.Count > 0)
            {
                var chosen     = Hand.Cards.Where(x => ChosenIndexes.Contains(x.Index)).ToList();
                var chosenText = chosen.Select(x => x.GetName()).Aggregate((x, y) => x + " " + y);
                var pokerType  = chosen.CheckChosenCards();
                if (pokerType != null)
                {
                    // footer1.Add(new InlineKeyboardCallbackButton(pokerType.ToString() + chosenText, $"{GameId}|{TelegramId}|card|go|{ChosenIndexes.Select(x => x.ToString()).Aggregate((x, y) => x + "," + y)}"));
                    footer1.Add(new InlineKeyboardCallbackButton(GetTranslation(pokerType.ToString(), Language) + chosenText, $"{GameId}|{TelegramId}|card|go"));
                    LastValidIndexes = ChosenIndexes;
                }
                else
                {
                    footer1.Add(new InlineKeyboardCallbackButton(GetTranslation("Invalid", Language), $"{GameId}|{TelegramId}|card|invalid"));
                }
            }
            else
            {
                footer1.Add(new InlineKeyboardCallbackButton(GetTranslation("ChooseCardButton", Language), $"{GameId}|{TelegramId}|card|dummy"));
            }
            var footer2 = new List <InlineKeyboardButton>();

            footer2.Add(new InlineKeyboardCallbackButton(GetTranslation("Pass", Language), $"{GameId}|{TelegramId}|card|skip"));
            footer2.Add(new InlineKeyboardCallbackButton(GetTranslation(!SortBySuit ? "SortBySuit" : "SortByNumber", Language), $"{GameId}|{TelegramId}|card|sort"));
            footer2.Add(new InlineKeyboardCallbackButton(GetTranslation("Reset", Language), $"{GameId}|{TelegramId}|card|reset"));

            rows.Add(footer1.ToArray());
            rows.Add(footer2.ToArray());

            var m = new InlineKeyboardMarkup(rows.ToArray());

            MarkUp = m;
        }
Example #2
0
 public void SortHand()
 {
     BTCard[] sortedHand = Hand.Cards.Sort();
     Hand = new BTPlayerHand(sortedHand);
 }
Example #3
0
 public void UpdateHand(BTPlayerHand hand)
 {
     Hand = hand;
     UpdateMenu();
 }