Example #1
0
    void Awake()
    {
        m_Instance = this;

        CreateCards();
        ShuffleCards();
    }
Example #2
0
    public void Burn(CardsDeck deck)
    {
        Random r = new Random();

        int number = r.Next(0, deck.Count);

        deck.Cards.RemoveAt(number);
    }
        public ActionResult <Response <string> > AddNewCard(int deckId, [FromBody] DeckIncome print)
        {
            var CardForDeck = new CardsDeck()
            {
                DeckId  = deckId,
                PrintId = print.PrintId
            };

            this.__context.Add(CardForDeck);
            this.__context.SaveChanges();

            return(Ok(new Response <string>()
            {
                Data = "Card is added to your deck",
                Success = true
            }));
        }
Example #4
0
    public void River(CardsDeck deck)
    {
        // Burn
        deck.Burn(deck);

        Random r = new Random();

        int  number = r.Next(0, deck.Count);
        Card card1  = deck.Cards[number];

        deck.Cards.RemoveAt(number);

        Console.SetCursorPosition(71, 15);
        Console.Write(card1.Rank);
        Console.SetCursorPosition(71, 16);
        Console.Write(card1.Suit);

        Cards[4] = card1;
    }
Example #5
0
    public void Flop(CardsDeck deck)
    {
        // Burn
        deck.Burn(deck);

        Random r = new Random();

        int  number = r.Next(0, deck.Count);
        Card card1  = deck.Cards[number];

        deck.Cards.RemoveAt(number);

        Console.SetCursorPosition(51, 15);
        Console.Write(card1.Rank);
        Console.SetCursorPosition(51, 16);
        Console.Write(card1.Suit);

        number = r.Next(0, deck.Count);
        Card card2 = deck.Cards[number];

        deck.Cards.RemoveAt(number);

        Console.SetCursorPosition(56, 15);
        Console.Write(card2.Rank);
        Console.SetCursorPosition(56, 16);
        Console.Write(card2.Suit);

        number = r.Next(0, deck.Count);
        Card card3 = deck.Cards[number];

        deck.Cards.RemoveAt(number);

        Console.SetCursorPosition(61, 15);
        Console.Write(card3.Rank);
        Console.SetCursorPosition(61, 16);
        Console.Write(card3.Suit);

        Cards[0] = card1;
        Cards[1] = card2;
        Cards[2] = card3;
    }
Example #6
0
    public static void DrawTableEsp(CardsDeck deck)
    {
        string[] table =
        {
            "  --------------------------------------------   ",
            " /                                            \\  ",
            "|    ---  ---  ---  ---  ---                   |",
            "|   |   ||   ||   ||   ||   |      BOTE:       |",
            "|   |   ||   ||   ||   ||   |                  |",
            "|   |   ||   ||   ||   ||   |                  |",
            "|    ---  ---  ---  ---  ---                   |",
            " \\                                            / ",
            "  --------------------------------------------   ",
        };

        for (int i = 0; i < table.Length; i++)
        {
            Console.SetCursorPosition(45, 12 + i);
            Console.WriteLine(table[i]);
        }
    }
Example #7
0
    public void RunEsp(string[] names)
    {
        Deck = new CardsDeck();

        Console.Clear();
        ShowMenuEsp();
        // Position for username #1 with name in game and chips
        Positions[] positions = new Positions[6];
        positions[0].X = 20;
        positions[0].Y = 8;
        positions[1].X = 60;
        positions[1].Y = 8;
        positions[2].X = 100;
        positions[2].Y = 8;
        positions[3].X = 20;
        positions[3].Y = 27;
        positions[4].X = 60;
        positions[4].Y = 27;
        positions[5].X = 100;
        positions[5].Y = 27;

        for (int i = 0; i < names.Length; i++)
        {
            Player player = new Player(names[i]);

            player.UserName = names[i];
            Players.Add(player);
        }

        // Draw Game table and cards
        DrawCard.DrawEsp(Players, Deck);
        DrawCard.UpdateChipsEsp(Players);
        DrawCard.DrawTableEsp(Deck);

        // Create logs of players
        CreateConfigEsp(Players);

        // Loop of game
        GameLoopEsp();
    }
Example #8
0
 public CurrentRound(GameObject[] p, GameObject c, GameObject d)
 {
     players = p;
     clicked = false;
     bets    = new int[players.Length];
     for (int i = 0; i < players.Length; i++)
     {
         bets[i] = 0;
     }
     currentRound = c;
     dealer       = d;
     deck         = new CardsDeck();
     for (int j = 0; j < players.Length; j++)
     {
         if (players[j] != null)
         {
             GameObject card = deck.getNextCard();
             players[j].SendMessage("addCard", card);
         }
     }
     dealCards(3);
 }
 public void SetupTest()
 {
     cardsDeck = new CardsDeck();
 }
Example #10
0
    public void CheckCardsEsp(List <Player> Players, CardsDeck deck)
    {
        List <Card> check = new List <Card>();

        for (int i = 0; i < Players.Count; i++)
        {
            check.Add(Players[i].cards[0]);
            check.Add(Players[i].cards[1]);
            check.Add(deck.Cards[0]);
            check.Add(deck.Cards[1]);
            check.Add(deck.Cards[2]);
            check.Add(deck.Cards[3]);
            check.Add(deck.Cards[4]);

            //1 Royal flush

            /*if (royalFlush())
             *  Players[i].HandValue = 1;
             * //2 Straight flush
             * else if (straightFlush())
             *  Players[i].HandValue = 2
             * //3 Four of a kind
             * else */
            if (fourOfAKind(check))
            {
                Players[i].HandValue = 3;
            }
            //4 Full House
            else if (fullHouse(check))
            {
                Players[i].HandValue = 4;
            }
            //5 Flush
            else if (flush(check))
            {
                Players[i].HandValue = 5;
            }
            //6 Straight

            /* else if (straight(check))
             *   Players[i].HandValue = 6;*/
            //7 Three of a kind
            else if (threeOfAKind(check))
            {
                Players[i].HandValue = 7;
            }
            //8 Two pair
            else if (twoPair(check))
            {
                Players[i].HandValue = 8;
            }
            //9 One pair
            else if (onePair(check))
            {
                Players[i].HandValue = 9;
            }
            //10 High card
            else
            {
                Players[i].HandValue = 10;
            }

            if (Players[0].HandValue < Players[1].HandValue)
            {
                Players[0].Chips += pot;
                Console.SetCursorPosition(110, 13);
                Console.WriteLine(Players[0].UserName + " gana!");
            }
            else if (Players[1].HandValue < Players[0].HandValue)
            {
                Players[1].Chips += pot;
                Console.SetCursorPosition(110, 13);
                Console.WriteLine(Players[1].UserName + " gana!");
            }
            else
            {
                int newPot = pot / 2;
                Players[0].Chips = pot;
                Players[1].Chips = newPot;
                Console.SetCursorPosition(110, 13);
                Console.WriteLine("Empate!");
            }
        }
    }
Example #11
0
    public static void Draw(List <Player> Players, CardsDeck deck)
    {
        Positions[] positions = new Positions[6];
        positions[0].X = 20;
        positions[0].Y = 5;
        positions[1].X = 60;
        positions[1].Y = 5;
        positions[2].X = 100;
        positions[2].Y = 5;
        positions[3].X = 20;
        positions[3].Y = 25;
        positions[4].X = 60;
        positions[4].Y = 25;
        positions[5].X = 100;
        positions[5].Y = 25;

        //Generator for random numbers
        Random r = new Random();

        // Positions for players, with username and chips, and cards
        for (int i = 0; i < Players.Count; i++)
        {
            int number = r.Next(0, deck.Count);
            Players[i].cards[0] = deck.Cards[number];
            deck.Cards.RemoveAt(number);

            number = r.Next(0, deck.Count);
            Players[i].cards[1] = deck.Cards[number];
            deck.Cards.RemoveAt(number);

            string[] cards = { " ---  --- ",
                               "| " + Players[i].cards[0].Rank + " || "
                               + Players[i].cards[1].Rank + " |",
                               "| " + Players[i].cards[0].Suit + " || "
                               + Players[i].cards[1].Suit + " |",
                               "|   ||   |",
                               " ---  --- " };

            for (int j = 0; j < cards.Length; j++)
            {
                Console.SetCursorPosition(positions[i].X, positions[i].Y + j);
                Console.WriteLine(cards[j]);
            }

            Console.SetCursorPosition(positions[i].X, positions[i].Y - 2);
            Console.WriteLine("Name: " + Players[i].UserName);

            /*Console.SetCursorPosition(positions[i].X, positions[i].Y - 1);
             * Console.WriteLine("Chips: " + Players[i].Chips);*/
        }

        // Big Blind
        Random rand     = new Random();
        int    bigBlind = rand.Next(0, Players.Count - 1);

        Console.SetCursorPosition(positions[bigBlind].X + 14,
                                  positions[bigBlind].Y + 2);
        Console.WriteLine("B");

        Players[bigBlind].bigBlind = true;

        // Small blind
        bigBlind = rand.Next(0, Players.Count - 1);
        Console.SetCursorPosition(positions[bigBlind + 1].X + 14,
                                  positions[bigBlind + 1].Y + 2);
        Console.WriteLine("S");
        Players[bigBlind + 1].smallBlind = true;
    }
Example #12
0
 private void Awake()
 {
     _instance = this;
     _cardDeck = new List <int>();
 }