示例#1
0
文件: Cpu.cs 项目: th1209/Memory
    private IEnumerator OpenTwoCards(Card[] cards)
    {
        yield return(new WaitForSeconds(_waitSeconds));

        cards[0].Open();

        yield return(new WaitForSeconds(_waitSeconds));

        cards[1].Open();
        // ココらへんで固まる

        yield return(new WaitForSeconds(_waitSeconds));

        if (cards[0].IsSame(cards[1]))
        {
            cards[0].Picked = true;
            cards[1].Picked = true;

            _hand.AddCard(cards[0]);
            _hand.AddCard(cards[1]);
        }
        else
        {
            cards[0].Close();
            cards[1].Close();
            TurnManager.Instance.SwitchTurn(PlayerType.Player);
        }

        _picking = false;
    }
        private void Hit()
        {
            bool endOfRound = false;

            PlayerHand.AddCard(MyDeck.pick());

            if (PlayerHand.handValue() > 21)
            {
                MessageBoard = "Busted! you lose.";
                DealerScore++;
                endOfRound = true;
            }
            if (PlayerHand.handValue() <= 21 && PlayerHand.CardsInHand.Count >= 5)
            {
                MessageBoard = "Player wins!";
                PlayerScore++;
                endOfRound = true;
            }
            if (endOfRound)
            {
                DealHandsButtonVisible   = true;
                HitButtonVisible         = false;
                StayButtonVisible        = false;
                ShuffleDeckButtonVisible = true;
            }
            CardsInDeck = MyDeck.CardsLeft();
        }
        private void DealHands()
        {
            if (CardsInDeck < 10)
            {
                DealHandsButtonVisible   = false;
                ShuffleDeckButtonVisible = true;
                MessageBoard             = "There are not enough cards\n" +
                                           "in the deck to play the hand.";
            }
            else
            {
                PlayerHand.clearHand();
                DealerHand.clearHand();
                PlayerHand.AddCard(MyDeck.pick());
                PlayerHand.AddCard(MyDeck.pick());
                DealerHand.AddCard(MyDeck.pick());
                DealerHand.AddCard(MyDeck.pick());

                HitButtonVisible         = true;
                StayButtonVisible        = true;
                ShuffleDeckButtonVisible = false;
                DealHandsButtonVisible   = false;

                CardsInDeck     = MyDeck.CardsLeft();
                DealerHandValue = 0;
                PlayerHandValue = 0;
                MessageBoard    = "";
            }
        }
示例#4
0
        //--------------------------------------------------------------------------------------------------------------

        public void Draw(IRuntimeCard card)
        {
            var uiCard = CardFactory.Instance.Get(card);

            uiCard.MonoBehavior.name  = "Card_" + Count;
            uiCard.transform.position = deckPosition.position;
            Count++;
            PlayerHand.AddCard(uiCard);
        }
示例#5
0
 public void DrawCard(PlayerHand drawZone)
 {
     if (_currentDeck.Count > 0)
     {
         CardManager drawnCard = _currentDeck[0];
         _currentDeck.RemoveAt(0);
         drawZone.AddCard(drawnCard);
         Debug.Log("[Dck] Drawing card: " + drawnCard.Card.name + ". Deck now has " + _currentDeck.Count + " cards.");
     }
     else if (AssociatedDiscard)
     {
         AssociatedDiscard.ShuffleIntoDeck(this);
         if (_currentDeck.Count > 0)
         {
             CardManager drawnCard = _currentDeck[0];
             _currentDeck.RemoveAt(0);
             drawZone.AddCard(drawnCard);
             Debug.Log("[Dck] Drawing card: " + drawnCard.Card.name + ". Deck now has " + _currentDeck.Count + " cards.");
         }
     }
 }
示例#6
0
        /// <summary>
        /// Imitates dealer hitting until they reach at least 17. Performs checks for blackjack win, bust, and equal to
        /// 17. If HandValue is less than 17, dealer will continue to draw until it evaluates to false.
        /// </summary>
        /// <param name="deck">The current deck/available cards being used</param>
        /// <returns>0 if dealer has blackjack. 1 if dealer has busted. 2 if dealer has 17 exactly.
        /// 3 if dealer has hit at least once.</returns>
        public override int Hit(Deck deck)
        {
            Card card;

            if (PlayerHand.HandValue == 21)
            {
                PlayerHand.BlackjackWin = true;
                Stand           = true;
                TurnComplete    = true;
                PlayerHand.Bust = false;
                return(0);
            }
            else if (PlayerHand.HandValue > 21)
            {
                Stand           = true;
                TurnComplete    = true;
                PlayerHand.Bust = true;
                return(1);
            }
            else if (PlayerHand.HandValue == 17)
            {
                Stand        = true;
                TurnComplete = true;
                return(2);
            }

            else
            {
                while (PlayerHand.HandValue < dealerStand)
                {
                    card = deck.Draw();
                    PlayerHand.AddCard(card);
                    PlayerHand.CheckAceAfterHit(card);
                    deck.UpdateDeck(card);
                }

                PlayerHand.CheckAcesInHand();

                if (PlayerHand.HandValue > 21)
                {
                    PlayerHand.Bust = true;
                }
                Stand        = true;
                TurnComplete = true;
                return(3);
            }
        }
示例#7
0
        //adds cards to the players hand
        public void AddCardsToPlayerHand(List <Card> cards)
        {
            foreach (Card card in cards)
            {
                card.OnCardClicked += new Delegates.CardClickedEventHandler(card_OnCardClicked);
                card.Clickable      = true;
            }

            // sort the cards
            cardsInPlayerHand = cards;
            cardsInPlayerHand.Sort();

            int x = 3;

            playerHand.ClearCards();
            foreach (Card card in cardsInPlayerHand)
            {
                playerHand.AddCard(card, x);
                x = x + 55;
            }
        }
示例#8
0
    private void DrawCard( )
    {
        // We wait between draws
        if (timeTillNextDraw > 0)
        {
            return;
        }
        timeTillNextDraw = delayAfterDraw;

        animator.SetTrigger("Draw");

        if (!SummoningManager.Instance.EnoughMana(drawCost + (incrementCostPerCard * hand.transform.childCount)))
        {
            return;
        }

        SummoningManager.Instance.RemoveMana(drawCost + (incrementCostPerCard * hand.transform.childCount));

        GameObject newCard = Instantiate
                             (
            GetCardFromDeck( ),
            transform.position + newCardPositionOffset,
            Quaternion.Euler(newCardRotationOffset.x, newCardRotationOffset.y, newCardRotationOffset.z)
                             );

        newCard.transform.SetParent(hand.transform, true);
        newCard.transform.SetSiblingIndex(0);

        cardCountLabel.text = $"{drawQueue.Count} / {PlayerCards.MaxCardsInDeck}";

        playerHand.AddCard(newCard.GetComponent <Card>( ));
        newCard.GetComponent <CardAudioVisuals>( ).DoCardReveal( );

        autoDrawTimer = autoDrawDelay;

        StartCoroutine(PlayDrawSound( ));
    }
示例#9
0
 public void AddCard(Card card)
 {
     Hand.AddCard(card);
 }
示例#10
0
        private void TestPlayerHand()
        {
            ACard c1 = new CoincheCard();
            ACard c2 = new CoincheCard();
            ACard c3 = new CoincheCard();
            ACard b1 = new CoincheCard();

            Console.WriteLine("Testing the player's hand");
            Console.WriteLine("Adding new cards in the hand");
            c1.Color = "club";
            c1.Value = 8;
            c2.Color = "club";
            c2.Value = 7;
            c3.Color = "club";
            c3.Value = 9;
            b1.Color = "spike";
            b1.Value = 12;
            c1.Dump();
            c2.Dump();
            c3.Dump();

            Console.WriteLine("Looking for card in your hand (invalid ones)");
            _hand.AddCard(c1);
            _hand.AddCard(c2);
            _hand.AddCard(c3);
            if (_hand.FindCard(19, "heart") != null)
            {
                Console.WriteLine("KO!");
            }
            else
            {
                Console.WriteLine("OK!");
            }
            if (_hand.FindCard(9, "spade") != null)
            {
                Console.WriteLine("KO!");
            }
            else
            {
                Console.WriteLine("OK!");
            }
            if (_hand.FindCard(8, "diamond") != null)
            {
                Console.WriteLine("KO!");
            }
            else
            {
                Console.WriteLine("OK!");
            }

            Console.WriteLine("Looking for card in your hand (good ones)");
            if (_hand.FindCard(8, "club") == null)
            {
                Console.WriteLine("KO!");
            }
            else
            {
                Console.WriteLine("OK!");
            }
            if (_hand.FindCard(9, "club") == null)
            {
                Console.WriteLine("KO!");
            }
            else
            {
                Console.WriteLine("OK!");
            }
            if (_hand.FindCard(7, "club") == null)
            {
                Console.WriteLine("KO!");
            }
            else
            {
                Console.WriteLine("OK!");
            }

            Console.WriteLine("Deleting cards in your hand (invalid ones)");
            if (_hand.DeleteCard(b1) != false)
            {
                Console.WriteLine("KO!");
            }
            else
            {
                Console.WriteLine("OK!");
            }

            Console.WriteLine("Deleting cards in your hand (valid ones)");
            Console.WriteLine("Dumping hand");
            _hand.Dump();
            if (_hand.DeleteCard(c1) == false)
            {
                Console.WriteLine("KO!");
            }
            else
            {
                Console.WriteLine("OK!");
            }
            if (_hand.DeleteCard(c2) == false)
            {
                Console.WriteLine("KO!");
            }
            else
            {
                Console.WriteLine("OK!");
            }
            if (_hand.DeleteCard(c3) == false)
            {
                Console.WriteLine("KO!");
            }
            else
            {
                Console.WriteLine("OK!");
            }
            Console.WriteLine("Re - dumping hand :");
            _hand.Dump();
            Console.WriteLine("{empty}");
        }