Пример #1
0
        public void Dahai(int index, bool isRiichi)
        {
            if (index != 13)
            {
                index = Hand.Tehai.IndexOf(Hand.SortedTehai[index]);
            }
            if (isRiichi)
            {
                //if (Shanten.CalculateShanten(Hand.AllTiles) != 0) return;
                RiichiMode      = true;
                isDaburuRiichi_ = Discards.Count == 0;
            }

            Discards.Add(Hand.Dahai(index).Value);
            if (wall_.RemainCount == 0)
            {
                IsRyukyoku = true;
            }
            else
            {
                Tsumo(new HandConfig(options: rules_,
                                     isTsumo: true,
                                     isRiichi: RiichiMode,
                                     isIppatsu: isRiichi,
                                     isDaburuRiichi: RiichiMode && isDaburuRiichi_,
                                     playerWind: Constants.EAST,
                                     roundWind: Constants.EAST));
            }
        }
Пример #2
0
        private async void Deal()
        {
            ComputerThoughts = "You dare challenge I? I can calculate more moves in a second than you can possibly imagine!";

            if (dealFinishied)
            {
                dealFinishied = false;
                var deck = Cards.Shuffle(Cards.FullDeck);

                foreach (var card in deck)
                {
                    RemainingDeck.Add(card);
                    await Task.Delay(1);
                }

                for (int i = 0; i < 10; i++)
                {
                    ComputerCards.Add(DrawTopCardFromDeck());
                    await Task.Delay(30);

                    HumanCards.Add(DrawTopCardFromDeck());
                    await Task.Delay(30);
                }

                Discards.Add(DrawTopCardFromDeck());
                dealFinishied = true;
            }
        }
Пример #3
0
        private async void Deal()
        {
            var deck = Cards.Shuffle(Cards.FullDeck);

            foreach (var card in deck)
            {
                PossibleDeck.Add(card); // Possible list of card
                RemainingDeck.Add(card);
                await Task.Delay(1);
            }

            for (int i = 0; i < 10; i++)
            {
                Cards.Card computerCard = DrawTopCardFromDeck();
                ComputerCards.Add(computerCard);
                // Remove the list of card on computer hand, as it is seen
                removePossibleCard(computerCard);
                await Task.Delay(30);

                HumanCards.Add(DrawTopCardFromDeck());
                await Task.Delay(30);
            }

            Discards.Add(DrawTopCardFromDeck());
            // Remove the discard from possible deck
            removePossibleCard(Discards[Discards.Count - 1]);
            ScoreToWin = "Score To Win : " + winingScore.ToString();
            scoreLabel(firstWinnerScore, secondWinnerScore);
        }
Пример #4
0
 private void DiscardCardFromHand(Cards.Card p)
 {
     if (!humanDiscard && humanDraw)
     {
         HumanCards.Remove(p);
         Discards.Add(p);
         removePossibleCard(p);
         humanDiscard = true;
         startGame    = true;
         playerTurn   = false;
     }
     else
     {
         if (!startGame)
         {
             RaiseNotification("You must draw a card first", "Invalid Action");
         }
         else
         {
             if (!playerTurn)
             {
                 RaiseNotification("You already discard a card", "Invalid Action");
             }
             else
             {
                 RaiseNotification("You must draw a card first", "Invalid Action");
             }
         }
     }
 }
Пример #5
0
 private void DiscardCardFromHand(Cards.Card p)
 {
     if (HumanCards.Count > 10 && humanTurn)
     {
         HumanCards.Remove(p);
         Discards.Add(p);
         humanTurn = false;
     }
 }
Пример #6
0
        private void ComputerPlayerTurn()
        {
            Cards.Card card = DrawTopCardFromDeck();
            ComputerCards.Add(card);
            ComputerCards.Remove(card);

            Discards.Add(card);
            computerStage = false;
            pickUpStage   = true;
        }
Пример #7
0
        async private void ArtificialPlayer()
        {
            if (takenFromDeckOrDiscardPile)
            {
                while (true)
                {
                    ComputerThoughts = "Calculating your impending doom ...";


                    foreach (var card in ComputerCards)
                    {
                        computerSeen.Remove(card);
                    }

                    GinRummy.sortByRankAndSuit(ComputerCards);

                    var x = ComputerPlayer.averageAllOfThePossibleDeadwoods(computerSeen, ComputerCards);


                    var pickupFromDeckOrDiscard = await Task.Run(() => ComputerPlayer.ComputerPickupDiscard(ComputerCards, Discards.First(), computerSeen));


                    if (pickupFromDeckOrDiscard) // picking up from the deck
                    {
                        ComputerThoughts = "You can not comprehend how much I know the top of the deck will benefit me, fool!";
                        ComputerCards.Add(DrawTopCardFromDeck());
                        await Task.Delay(5000);

                        var cardToAddToDiscard = ComputerPlayer.ComputerMove(ComputerCards);
                        ComputerCards.Remove(cardToAddToDiscard.Item2.Value);
                        Discards.Add(cardToAddToDiscard.Item2.Value);
                    }
                    else     // picking up from the discard
                    {
                        ComputerThoughts = "Ahh this card will do very nicely, my thanks for allowing me to have it, fool!";

                        await Task.Delay(2000);

                        var topOfDiscard = Discards[Discards.Count - 1];
                        ComputerCards.Add(topOfDiscard);
                        Discards.Remove(topOfDiscard);
                        await Task.Delay(5000);

                        var cardToAddToDiscard = ComputerPlayer.ComputerMove(ComputerCards);
                        ComputerCards.Remove(cardToAddToDiscard.Item2.Value);
                        Discards.Add(cardToAddToDiscard.Item2.Value);
                    }
                    ComputerThoughts = "I now end my turn. Your move, human." + GinRummy.Deadwood(ComputerCards);

                    break;
                }
                canNowDiscard = false;
                takenFromDeckOrDiscardPile = false;
            }
        }
Пример #8
0
        private void ComputerTurn()
        {
            var takeDiscard = ComputerPlayer.ComputerPickupDiscard(ComputerCards, Discards[Discards.Count - 1], RemainingDeck);

            if (takeDiscard)
            {
                var discardCard = Discards[Discards.Count - 1];
                Discards.Remove(discardCard);
                ComputerCards.Add(discardCard);
            }
            else
            {
                Cards.Card remainingDeckCards = RemainingDeck[RemainingDeck.Count - 1];
                RemainingDeck.Remove(remainingDeckCards);
                ComputerCards.Add(remainingDeckCards);
            }

            var compMove = ComputerPlayer.ComputerMove(ComputerCards);

            ComputerCards.Remove(compMove.Item2.Value);
            Discards.Add(compMove.Item2.Value);

            var scores = GinRummy.Score(ComputerCards, HumanCards);

            if (compMove.Item1.IsGin)
            {
                compScore += scores;
                if (humanScore < 100 && compScore < 100)
                {
                    RaiseNotification("Human Score: " + humanScore + ". Computer Score: " + compScore, "Scores So Far");
                    CleanUpCards();
                }
            }
            else if (compMove.Item1.IsKnock)
            {
                if (scores > 0)
                {
                    compScore += scores;
                    if (humanScore < 100 && compScore < 100)
                    {
                        RaiseNotification("Human Score: " + humanScore + ". Computer Score: " + compScore, "Scores So Far");
                        CleanUpCards();
                    }
                }
                else
                {
                    humanScore += Math.Abs(scores);
                    if (humanScore < 100 && compScore < 100)
                    {
                        RaiseNotification("Human Score: " + humanScore + ". Computer Score: " + compScore, "Scores So Far");
                        CleanUpCards();
                    }
                }
            }
        }
Пример #9
0
        private void DiscardCardFromHand(Cards.Card p)
        {
            if (canNowDiscard)
            {
                HumanCards.Remove(p);
                Discards.Add(p);

                canNowDiscard = false;
                computerSeen.Remove(p);
                ArtificialPlayer();
            }
        }
Пример #10
0
 private void DiscardCardFromHand(Cards.Card p)
 {
     if (discardStage)
     {
         HumanCards.Remove(p);
         Discards.Add(p);
         discardStage  = false;
         computerStage = true;
         ComputerPlayerTurn();
     }
     else
     {
         RaiseNotification("Not in Discard Stage", "Title");
     }
 }
Пример #11
0
        private async void Deal()
        {
            var deck = Cards.Shuffle(Cards.FullDeck);

            foreach (var card in deck)
            {
                RemainingDeck.Add(card);
                await Task.Delay(1);
            }

            for (int i = 0; i < 10; i++)
            {
                ComputerCards.Add(DrawTopCardFromDeck());
                await Task.Delay(30);

                HumanCards.Add(DrawTopCardFromDeck());
                await Task.Delay(30);
            }

            Discards.Add(DrawTopCardFromDeck());
        }
Пример #12
0
        private void ComputerDiscardCardFromHand()
        {
            if (humanDiscard)
            {
                ComputerPlayer.Move move    = ComputerPlayer.ComputerMove(ComputerCards).Item1;
                Cards.Card          discard = ComputerPlayer.ComputerMove(ComputerCards).Item2.Value;
                Discards.Add(discard);
                ComputerCards.Remove(discard);
                humanDiscard = false;
                playerTurn   = true;

                if (move == ComputerPlayer.Move.Gin)
                {
                    endGame();
                }
                else if (move == ComputerPlayer.Move.Knock)
                {
                    endGame();
                }
            }
        }
Пример #13
0
 public void Discard(T card)
 {
     HandCards.Remove(card);
     Discards.Add(card);
 }
Пример #14
0
 private void DiscardCardFromHand(Cards.Card p)
 {
     HumanCards.Remove(p);
     Discards.Add(p);
 }