Example #1
0
    public void DrawCard(int amount)
    {
        int cardsToDraw = Mathf.Min(Hand.CardSlotsFree, amount);

        if (cardsToDraw != amount)
        {
            Debug.Log("Adding To many cards to the hand, the maximum is: " + Hand.MaxCardCount);
        }


        Debug.Log("Adding " + cardsToDraw + " cards to the hand of client: " +
                  netIdentity.connectionToClient.connectionId);

        for (int i = 0; i < cardsToDraw; i++)
        {
            CardEntry e = Deck.DrawCard();
            //Hand.AddCard(c);//Add the Card to the server
            GameObject cardInstance = Instantiate(e.Prefab, Deck.DeckPosition, Quaternion.identity);
            NetworkServer.Spawn(cardInstance, GetComponent <NetworkIdentity>().connectionToClient);
            Card c = cardInstance.GetComponent <Card>();
            c.Statistics = e.Statistics;
            Tuple <int[], int[], string[]> networkData = e.StatisticsToNetworkableTypes();
            Debug.Log("Sending Stats");
            c.TargetSendStats(netIdentity.connectionToClient, networkData.Item1, networkData.Item2, networkData.Item3);

            Hand.AddToHand(c.GetComponent <NetworkIdentity>());
            Hand.TargetAddToHand(netIdentity.connectionToClient,
                                 c.GetComponent <NetworkIdentity>()); //Add Card to the client
        }
    }
Example #2
0
        public BlackjackManager()
        {
            CardWorth.Add(CardValue.ACES, (x, hand) => 11);
            CardWorth.Add(CardValue.TWOS, (x, hand) => 2);
            CardWorth.Add(CardValue.THREES, (x, hand) => 3);
            CardWorth.Add(CardValue.FOURS, (x, hand) => 4);
            CardWorth.Add(CardValue.FIVES, (x, hand) => 5);
            CardWorth.Add(CardValue.SIXES, (x, hand) => 6);
            CardWorth.Add(CardValue.SEVENS, (x, hand) => 7);
            CardWorth.Add(CardValue.EIGHTS, (x, hand) => 8);
            CardWorth.Add(CardValue.NINES, (x, hand) => 9);
            CardWorth.Add(CardValue.TENS, (x, hand) => 10);
            CardWorth.Add(CardValue.JACKS, (x, hand) => 10);
            CardWorth.Add(CardValue.QUEENS, (x, hand) => 10);
            CardWorth.Add(CardValue.KINGS, (x, hand) => 10);

            player.AddToHand(deck.DrawRandom());
            player.AddToHand(deck.DrawRandom());

            dealer.AddToHand(deck.DrawRandom());
            dealer.AddToHand(deck.DrawRandom(false));
        }
Example #3
0
 public void DealTo(CardHand hand)
 {
     hand.AddToHand(_deck.DrawRandom());
 }