Пример #1
0
 private void GenerateFrenchDeck()
 {
     foreach (Suit suit in Enum.GetValues(typeof(Suit)))
          foreach (Rank rank in Enum.GetValues(typeof(Rank)))
          {
              PlayingCard FrenchCard = new PlayingCard(suit, rank);
              Add(FrenchCard);
          }
 }
Пример #2
0
 private static void CreateDeck()
 {
     for (int s = 1; s <= 4; s++)
     {
         for (int v = 1; v <= 13; v++)
         {
             PlayingCard playingCard = new PlayingCard(v, (Suit)s);
             _cards.Add(playingCard);
         }
     }
 }
Пример #3
0
 public void Shuffle()
 {  //swap cards form front to back in the deck
     for (int i = 0; i < cards.Count - 2; i++)
     {
         int pos = rnd.Next(i + 1, cards.Count);
         //return a random number form second front card to the last card.randdom.next(include,notinclude)
         PlayingCard tmp = cards[i];
         cards[i]   = cards[pos];//swap the random card and the front card
         cards[pos] = tmp;
     }
 }
Пример #4
0
 public PlayingCard DealTopCard()
 {
     if (isEmpty())
     {
         return(null);
     }
     else
     {
         PlayingCard theTopCard = cards[0];
         cards.RemoveAt(0);
         return(theTopCard);
     }
 }
Пример #5
0
 public PlayingCard DealTopCard()
 {
     if (this.IsEmpty() == true)
     {
         return(null);
     }
     else
     {
         PlayingCard topCard = cards[0];
         cards.RemoveAt(0);
         return(topCard);
     }
 }
Пример #6
0
        // Generates the deck of 52 cards
        static PlayingCard[] generateDeck()
        {
            PlayingCard[] deck    = new PlayingCard[52]; // Declares an array of PlayingCards with a size of 52
            int           counter = 0;                   // Tells us where to save the next value into the array

            // Nested for loop to generate all 52 cards - 4 possible suits with 13 possible values each
            for (int suit = 1; suit < 5; suit++)                  // Loop through the 4 possible suits
            {
                for (int value = 1; value < 14; value++)          // Loop through the 13 possible values
                {
                    deck[counter] = new PlayingCard(suit, value); // Generate new card and store it in the deck
                    counter++;                                    // Increment the counter
                }
            }

            return(deck); // Returns the completed deck
        }
Пример #7
0
        private static bool Object_placementAction_prefix(Object __instance, GameLocation location, int x, int y, Farmer who)
        {
            string  tileDeckString = null;
            int     X    = x / 64;
            int     Y    = y / 64;
            Vector2 tile = new Vector2(X, Y);

            if (!Config.EnableMod || location == null || who == null || (!SHelper.Input.IsDown(Config.DealDownModButton) && !SHelper.Input.IsDown(Config.DealUpModButton)) || !__instance.modData.TryGetValue(deckKey, out string deckString) || (location.objects.TryGetValue(tile, out Object tileObject) && !tileObject.modData.TryGetValue(deckKey, out tileDeckString)))
            {
                return(true);
            }

            CardDeck    deck = new CardDeck(deckString);
            PlayingCard card = deck.cards[0];

            card.facing = SHelper.Input.IsDown(Config.DealDownModButton) ? "down" : "up";

            if (tileDeckString != null)
            {
                CardDeck tileDeck = new CardDeck(tileDeckString);
                SMonitor.Log($"Placing {card.index}:{card.suit} in existing deck of {tileDeck.cards.Count}");
                tileDeck.cards.Insert(0, card);
                location.objects[tile].modData[deckKey] = tileDeck.GetDeckString();
            }
            else
            {
                SMonitor.Log($"Creating new deck at {X},{Y}");
                Object newDeck = new Object(tile, 0);
                newDeck.modData[deckKey] = card.GetString();
                location.objects.Add(tile, newDeck);
            }
            deck.cards.RemoveAt(0);
            if (deck.cards.Count == 0)
            {
                SMonitor.Log("removing empty deck in hand");
                who.reduceActiveItemByOne();
            }
            else
            {
                SMonitor.Log($"deck in hand has {deck.cards.Count} cards left");
                __instance.modData[deckKey] = deck.GetDeckString();
            }
            return(false);
        }
Пример #8
0
        static void drawCard(PlayingCard[] deck, ref Player player)
        {
            PlayingCard nextCard = deck[pointer];

            // Add the next card in the deck to the player's hand
            if (player.cardsInHand < 5)
            {
                player.hand[player.cardsInHand] = nextCard;

                // Increment the number of cards in the player's hand
                player.cardsInHand++;

                // Add the point value of the new card to the player's total
                player.points += nextCard.Points;

                // Output the details of the card
                //outputCard(nextCard);

                // Increment the pointer
                pointer++;
            }
        }
Пример #9
0
        private void BettingBoxDisplay()
        {
            string BettingBoxUserDisplay = "[ " + bjPlayer.Name + ", Wallet : $" + bjPlayer.Wallet + " ]";

            if (!bjTable.Box1.PopulatedBox)
            {
                Console.SetCursorPosition(_centerConsole - (BettingBoxUserDisplay.Length / 2), _bettingBoxConsoleRow);
                Console.Write(BettingBoxUserDisplay);
            }
            else
            {
                Console.SetCursorPosition(_centerConsole - (BettingBoxUserDisplay.Length / 2), _bettingBoxConsoleRow);
                Console.Write(BettingBoxUserDisplay);

                if (bjTable.Box1.Hand.DeckCount > 0)
                {
                    int MoveCursorUp = 2;

                    for (int incrementHand = 0; incrementHand < bjTable.Box1.Hand.DeckCount; incrementHand++)
                    {
                        Console.SetCursorPosition(_centerConsole, _bettingBoxConsoleRow - MoveCursorUp);
                        _tmpPlayingCard = (PlayingCard)bjTable.Box1.Hand[incrementHand];
                        Console.Write("{0}", _tmpPlayingCard.ToString());

                        MoveCursorUp++;
                    }
                }
            }
        }
Пример #10
0
        private int ReturnCardValue(PlayingCard EvaluateCard)
        {
            if (EvaluateCard.Value < 10)
            {
                 return EvaluateCard.Value;
            }

            if (EvaluateCard.Value > 9 && EvaluateCard.Value < 14)
            {
                return 10;
            }
            else
            {
                return PlayerPickValueAce();
            }
        }
Пример #11
0
        private void DealerInfoDisplay()
        {
            Console.SetCursorPosition(_centerConsole, 9);
            Console.Write("Dealer");

            if (bjDealer.Hand.DeckCount > 0)
            {
                for (int i = 0; i < bjDealer.Hand.DeckCount; i++)
                {
                    Console.SetCursorPosition(_centerConsole, 11 + i);

                    if (bjDealer.Hand[i].IsHidden)
                    {
                        Console.Write("****");
                    }
                    else
                    {
                        _tmpPlayingCard = (PlayingCard)bjDealer.Hand[i];
                        Console.Write("{0}", _tmpPlayingCard.ToString());
                    }
                }
            }
        }
Пример #12
0
        private int DealerCardValue(PlayingCard EvaluateCard)
        {
            if (EvaluateCard.Value < 10)
            {
                return EvaluateCard.Value;
            }

            if (EvaluateCard.Value > 9 && EvaluateCard.Value < 14)
            {
                return 10;
            }
            else
            {
                if (bjDealer.HandValue < 11)
                {
                    return 11;
                }
                else
                {
                    return 1;
                }
            }
        }
Пример #13
0
 private void DealCardToDealer()
 {
     _tmpPlayingCard = (PlayingCard)bjDealer.DealCard();
     bjDealer.HandValue = DealerCardValue(_tmpPlayingCard);
     bjDealer.Hand.Add(_tmpPlayingCard);
 }
Пример #14
0
 private void DealCardToBox(int Box)
 {
     _tmpPlayingCard = (PlayingCard)bjDealer.DealCard();
     bjTable.ListOFBoxs[Box].HandValue = ReturnCardValue(_tmpPlayingCard);
     bjTable.ListOFBoxs[Box].Hand.Add(_tmpPlayingCard);
 }
Пример #15
0
        private void DealerInfoDisplay()
        {
            Console.SetCursorPosition(CenterConsole, 9);
            Console.Write("Dealer");

            if (HeadDealer.Hand.DeckCount < 0)
                for (int i = 0; i < HeadDealer.Hand.DeckCount; i++)
                {
                    Console.SetCursorPosition(CenterConsole, 11 + i);

                    if (HeadDealer.Hand[i].IsHidden)
                        Console.Write("*");
                    else
                    {
                        TmpPlayingCard = (PlayingCard)HeadDealer.Hand[i];
                        Console.Write("{0}", TmpPlayingCard.ToString());
                    }
                }
        }
Пример #16
0
        private void BettingBoxDisplay()
        {
            int MoveLeft = 0;

            for (int incremental = 0; incremental < GameTable.ListOFBoxs.Count; incremental++)
            {
                if (!GameTable.ListOFBoxs[incremental].PopulatedBox)
                {
                    Console.ForegroundColor = ConsoleColor.DarkGray;
                    Console.SetCursorPosition(FarRightConsole - MoveLeft, BettingBoxConsoleRow);
                    Console.Write("[{0}]", GameTable.ListOFBoxs[incremental].BoxName);
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.SetCursorPosition(FarRightConsole - MoveLeft, BettingBoxConsoleRow);
                    Console.Write("[ {0} ]", GameTable.ListOFBoxs[incremental].FrontBidder);

                    if (GameTable.ListOFBoxs[incremental].Hand.DeckCount < 0)
                        for (int incrementHand = 0; incrementHand < GameTable.ListOFBoxs[incremental].Hand.DeckCount; incrementHand++)
                        {
                            int MoveCursorUp = 2;
                            Console.SetCursorPosition(FarRightConsole - MoveLeft, BettingBoxConsoleRow - MoveCursorUp);
                            Console.Write("{0}", TmpPlayingCard = (PlayingCard)GameTable.ListOFBoxs[incremental].Hand[incrementHand]);

                            MoveCursorUp++;
                        }
                    {
                        for (int handincrement = 0; GameTable.ListOFBoxs[incremental].Hand.DeckCount < handincrement; handincrement++)
                        {
                            int MoveWriteup = 2;

                            Console.SetCursorPosition(FarRightConsole - MoveLeft, BettingBoxConsoleRow - MoveWriteup);
                            TmpPlayingCard = (PlayingCard)GameTable.ListOFBoxs[incremental].Hand[handincrement];
                            Console.Write("{0}", TmpPlayingCard.ToString());

                            MoveWriteup++;
                        }
                    }
                }

                MoveLeft += 15;
            }
        }