Exemplo n.º 1
0
        public void PlayerRound()
        {
            Discard = new bool[5] {
                false, false, false, false, false
            };
            string userChoice;
            int    DiscardMe = 0;

            for (int n = 0; n < 5; n++)
            {
                PlayerHand.Add(deckOfCards.Deal());
            }
            do
            {
                ShowPlayerHand();
                Console.WriteLine("Type the number of the card in your hand and hit enter to toggle between keep/descard. Type 'D' to finalize Discard.");
                userChoice = Console.ReadLine();
                if (userChoice.ToLower() == "exit")
                {
                    System.Environment.Exit(0);
                }
                while (userChoice != "D" && !int.TryParse(userChoice, out DiscardMe))
                {
                    Console.WriteLine("Invalid choice. Try Again: ");
                    userChoice = Console.ReadLine();
                }
                if (userChoice != "D" && DiscardMe > 0 && DiscardMe < 6)
                {
                    Discard[DiscardMe - 1] = Discard[DiscardMe - 1] == true ? false : true;
                }
            } while (userChoice != "D");
            FinalizeDiscard();
            ShowPlayerHand();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns a random card and places it in the player's hand
        /// </summary>
        public void PullPlayerCard()
        {
            Card   tempCard;
            int    randNum;
            Random random = new Random();

            if (_deck.Count == 0)
            {
                GameMode = Results.Shuffle;
                Shuffle();
            }
            else
            {
                randNum  = random.Next(0, _deck.Count());
                tempCard = _deck[randNum];
                _deck.Remove(_deck[randNum]);

                PlayerHand.Add(tempCard);

                //Update player score
                if (tempCard.Rank == 1)
                {
                    _playerAces++;
                    PlayerScore += 11;
                }
                else if (tempCard.Rank < 11)
                {
                    PlayerScore += tempCard.Rank;
                }
                else if (tempCard.Rank >= 11)
                {
                    PlayerScore += 10;
                }

                //Changes Aces from 11 to 1 if hand is over 21
                if (_playerAces > 0)
                {
                    int count = 0;

                    while (PlayerScore > 21 && count < _playerAces)
                    {
                        PlayerScore -= 10;
                        count++;
                        _playerAces--;
                    }
                }

                //If player busts
                if (PlayerScore > 21)
                {
                    Stand        = true;
                    GameMode     = Results.Bust;
                    PlayerChips -= Bet;
                }
                else if (PlayerScore == 21)
                {
                    PlayerStand();
                }
            }
        }
Exemplo n.º 3
0
 private void HitCards(object obj)
 {
     PlayerHand.Add(PullCard());
     UpdateScores();
     if (PlayerScore > 21)
     {
         DeclareWinner();
     }
 }
Exemplo n.º 4
0
        public void ShouldAddCardsToHand()
        {
            var expectedHand = new[] { CardType.Blue };
            var hand         = new PlayerHand();

            hand.Add(expectedHand);

            CollectionAssert.AreEqual(expectedHand, hand.Cards);
        }
Exemplo n.º 5
0
 public void NewGame()
 {
     EndVisible = false;
     _hold      = false;
     DealerHand.Clear();
     PlayerHand.Clear();
     DealerHand.Add(PullCard());
     PlayerHand.Add(PullCard());
     UpdateScores();
 }
Exemplo n.º 6
0
    // カードをクリックしたら、中央におく
    public void SelectCard(Card card)
    {
        if (selectCard != null)
        {
            hand.Add(selectCard);
        }

        selectCard = card; // 新しく選択カードを設定
        selectCardPosition.SetCard(card);
        hand.Remove(card);
    }
Exemplo n.º 7
0
 public IEnumerable <int> RefillHand()
 {
     foreach (int _ in Enumerable.Range(0, PlayerHand.PlayedCards))
     {
         if (deck.HasCards)
         {
             var newNumber = deck.TakeCard();
             PlayerHand.Add(newNumber);
             yield return(newNumber);
         }
     }
 }
Exemplo n.º 8
0
        private void DrawNewHand()
        {
            PlayerHand.Clear();

            Console.WriteLine("Drawing Cards...\n");

            //Draw 5 cards
            for (int i = 0; i < 5; i++)
            {
                PlayerHand.Add(deck.DrawCard());
            }
        }
Exemplo n.º 9
0
        public void DrawCard(Card card)
        {
            GameObject  cardObject = PlayerDeck.GetNewCard(card);
            LSAnimation move1      = AnimationFactory.Instance.CreatMove(cardObject, RightShowTrans);

            AnimationManager.Instance.AddAnimation(move1);

            LSAnimation delay = AnimationFactory.Instance.CreatDelay(0.2f);

            AnimationManager.Instance.AddAnimation(delay);

            cardObject.AddComponent <HandDrag>();
            PlayerHand.Add(cardObject.GetComponent <UICard>());
        }
Exemplo n.º 10
0
 /// <summary>
 /// Draw cards to replenish the player's hand until it's full
 /// </summary>
 public void DrawCards()
 {
     newCards = new List <ActionCard>();
     while (PlayerHand.Count < 5)
     {
         //Check if there are no futher cards
         if (CurrentActionDeck.Count == 0)
         {
             Debug.Log("No more action cards to draw!");
             break;
         }
         //Draw a card and add it to the player hand
         PlayerHand.Add(CurrentActionDeck[0]);
         newCards.Add(CurrentActionDeck[0]);
         CurrentActionDeck.RemoveAt(0);
     }
 }
Exemplo n.º 11
0
 public void Draw()
 {
     for (int i = 0; i < 5; i++)
     {
         if (Deck.Count != 0)
         {
             Card c = Deck.ElementAt(0);
             Deck.RemoveAt(0);
             PlayerHand.Add(c);
         }
         else
         {
             Deck.Shuffle();
             i--;
         }
     }
 }
Exemplo n.º 12
0
        /// <summary>
        /// Play a hand of 5 card draw.
        /// </summary>
        public void PlayRound()
        {
            Discard = new bool[5] {
                false, false, false, false, false
            };
            string userChoice;
            int    discardMe = 0;

            //deal five cards to player
            for (int n = 0; n < 5; n++)
            {
                PlayerHand.Add(deckOfCards.Deal());
            }

            //discard loop
            do
            {
                ShowPlayerHand();

                Console.WriteLine("Type the number of the card in your hand and hit Enter to toggle between Keep/Discard.");
                Console.Write("Type 'D' to finalize dicard or 'exit' to quit game? ");
                userChoice = Console.ReadLine();

                if (userChoice.ToLower() == "exit")
                {
                    System.Environment.Exit(0);
                }

                //input validation loop
                while (userChoice != "D" && !int.TryParse(userChoice, out discardMe))
                {
                    Console.WriteLine("Invalid choice. Try Again: ");
                    userChoice = Console.ReadLine();
                }

                //toggle element using ternary operator.
                if (userChoice != "D" && discardMe > 0 && discardMe < 6)
                {
                    Discard[discardMe - 1] = Discard[discardMe - 1] == true ? false : true;
                }
            } while (userChoice != "D");

            FinalizeDiscard();
            ShowPlayerHand();
        }//play Round
Exemplo n.º 13
0
        public void DrawNewHand(Texture2D enemyTex, Texture2D eventTex, Texture2D merchantTex,
                                Texture2D restingTex, Texture2D trapTex, Texture2D treasureTex, Texture2D bossTex, Texture2D cardBack, Dictionary <string, Button> buttons,
                                Dictionary <string, Die> combatDice, Dictionary <string, SoundEffect> dieSounds, Dictionary <string, Texture2D> dieTextures)
        {
            playerHand.Add(new Enemy("Enemy", enemyTex, cardBack, buttons, combatDice, dieSounds));

            playerHand.Add(new EventCard("EventCard", eventTex, cardBack, buttons, combatDice, dieSounds, dieTextures));

            playerHand.Add(new Merchant("Merchant", merchantTex, cardBack, buttons, dieTextures));

            playerHand.Add(new Resting("Resting", restingTex, cardBack, buttons));

            playerHand.Add(new Trap("Trap", trapTex, cardBack, buttons, dieTextures, dieSounds));

            playerHand.Add(new Treasure("Treasure", treasureTex, cardBack, buttons, dieTextures, dieSounds));

            ShuffleHand();

            PlayerHand.Add(new Boss("Boss", bossTex, cardBack, buttons, combatDice, dieTextures, dieSounds));

            Card1 = playerHand[0];
            Card2 = playerHand[1];
            Card3 = playerHand[2];
            Card4 = playerHand[3];
            Card5 = playerHand[4];
            Card6 = playerHand[5];
            Card7 = playerHand[6];

            Card1.LevelXpos = 191;
            Card1.LevelYPos = 260;
            Card2.LevelXpos = 416;
            Card2.LevelYPos = 100;
            Card3.LevelXpos = 416;
            Card3.LevelYPos = 410;
            Card4.LevelXpos = 641;
            Card4.LevelYPos = 260;
            Card5.LevelXpos = 866;
            Card5.LevelYPos = 100;
            Card6.LevelXpos = 866;
            Card6.LevelYPos = 410;
            Card7.LevelXpos = 1091;
            Card7.LevelYPos = 260;
        }
Exemplo n.º 14
0
    public void DrawCard()
    {
        if (PlayerHand.Count < PlayerHand.MaxSize)
        {
            //TODO

            Debug.Log("Player draw a card.");
            Card card = PlayerDeck.Pop();
            PlayerHand.Add(card);
            DrawEventData data = new DrawEventData();
            data.player = this;
            data.card   = card;

            //event
            EventDispatcher.TriggerEvent(EventEnum.DrawCard, data);
        }
        else
        {
            BurnCard();
        }
    }
Exemplo n.º 15
0
        public bool Deal()
        {
            if (LastDeal)
            {
                return(false);
            }

            PlayerHand.Clear();
            BankerHand.Clear();
            PlayerPoints = 0;
            BankerPoints = 0;

            IsBankerWin  = false;
            IsPlayerWin  = false;
            IsTie        = false;
            IsBankerPush = false;

            IsPanda  = false;
            IsDragon = false;

            IsNatural = false;

            PlayerHand.Add(this.DrawCard());
            // TODO: Check whether we need to declare last round when first drawn card is a cutcard.
            BankerHand.Add(this.DrawCard());
            PlayerHand.Add(this.DrawCard());
            BankerHand.Add(this.DrawCard());

            PlayerPoints += CardPointValues[(int)PlayerHand[0].Rank];
            PlayerPoints += CardPointValues[(int)PlayerHand[1].Rank];
            PlayerPoints %= 10;

            BankerPoints += CardPointValues[(int)BankerHand[0].Rank];
            BankerPoints += CardPointValues[(int)BankerHand[1].Rank];
            BankerPoints %= 10;

            if (PlayerPoints == 8 || PlayerPoints == 9 || BankerPoints == 8 || BankerPoints == 9)
            {
                IsNatural = true;
            }
            else
            {
                bool playerStands = false;
                if (PlayerPoints <= 5)
                {
                    PlayerHand.Add(this.DrawCard());
                    PlayerPoints += CardPointValues[(int)PlayerHand[2].Rank];
                    PlayerPoints %= 10;
                }
                else
                {
                    playerStands = true;
                }

                if (playerStands)
                {
                    if (BankerPoints <= 5)
                    {
                        BankerHand.Add(this.DrawCard());
                        BankerPoints += CardPointValues[(int)BankerHand[2].Rank];
                        BankerPoints %= 10;
                    }
                }
                else
                {
                    // Player drew a third card.
                    int  playersThirdCard = CardPointValues[(int)PlayerHand[2].Rank];
                    bool bankerDraws      = false;

                    if ((BankerPoints <= 2) || (BankerPoints == 3 && playersThirdCard != 8) ||
                        (BankerPoints == 4 && (playersThirdCard >= 2 && playersThirdCard <= 7)) ||
                        (BankerPoints == 5 && (playersThirdCard >= 4 && playersThirdCard <= 7)) ||
                        (BankerPoints == 6 && (playersThirdCard == 6 || playersThirdCard == 7)))
                    {
                        bankerDraws = true;
                    }

                    if (bankerDraws)
                    {
                        BankerHand.Add(this.DrawCard());
                        BankerPoints += CardPointValues[(int)BankerHand[2].Rank];
                        BankerPoints %= 10;
                    }
                }
            }

            if (BankerPoints > PlayerPoints)
            {
                IsBankerWin = true;
                if (BankerPoints == 7 && BankerHand.Count == 3)
                {
                    this.IsDragon = true;

                    this.IsBankerWin  = false;
                    this.IsBankerPush = true;
                }
            }
            else if (BankerPoints < PlayerPoints)
            {
                IsPlayerWin = true;
                if (PlayerPoints == 8 && PlayerHand.Count == 3)
                {
                    this.IsPanda = true;
                }
            }
            else
            {
                IsTie = true;
            }

            return(true);
        }
Exemplo n.º 16
0
        private void UpdatePlayerHand()
        {
            var newHand = (CardsAgainstHumility.IsCardCzar || CardsAgainstHumility.ReadyToSelectWinner || CardsAgainstHumility.ReadyForReview) ?
                          CardsAgainstHumility.PlayedCards : CardsAgainstHumility.PlayerHand;

            if (newHand == null)
            {
                newHand = new List <WhiteCard>();
            }

            #region New Data

            var oldHandIds    = PlayerHand.Select(c => c.Id).ToList();
            var newHandIds    = newHand.Select(c => c.Id).ToList();
            var idsToRemove   = oldHandIds.Where(c => !newHandIds.Contains(c)).ToList();
            var idsToAdd      = newHandIds.Where(c => !oldHandIds.Contains(c)).ToList();
            var cardsToRemove = PlayerHand.Where(c => idsToRemove.Contains(c.Id)).ToList();

            foreach (var card in cardsToRemove)
            {
                PlayerHand.Remove(card);
            }

            foreach (var card in newHand.Where(c => idsToAdd.Contains(c.Id)))
            {
                PlayerHand.Add(card);
            }

            #endregion

            if (CardsAgainstHumility.GameStarted && !CardsAgainstHumility.GameOver)
            {
                if (CardsAgainstHumility.IsCardCzar)
                {
                    if (CardsAgainstHumility.ReadyToSelectWinner && CardsAgainstHumility.WinningCard == null)
                    {
                        ShowPlayerHand   = true;
                        EnablePlayerHand = true;
                    }
                    else
                    {
                        ShowPlayerHand = false;
                    }
                }
                else
                {
                    if (!CardsAgainstHumility.ReadyToSelectWinner && !CardsAgainstHumility.ReadyForReview && CardsAgainstHumility.SelectedCard != null)
                    {
                        ShowPlayerHand = false;
                    }
                    else
                    {
                        ShowPlayerHand   = true;
                        EnablePlayerHand = true;
                    }
                }
            }
            else
            {
                ShowPlayerHand   = true;
                EnablePlayerHand = false;
            }
        }