Ejemplo n.º 1
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();
    }
Ejemplo n.º 2
0
    public void GameLoopEsp()
    {
        bool exit = false;
        int  nIsAbsent;

        do
        {
            do
            {
                ShowExitEsp();
                for (int i = 0; i < Players.Count - 1; i++)
                {
                    //1 Check user input
                    MovementsEsp();

                    // Payment of blinds
                    if (Players[i].bigBlind)
                    {
                        int big = 200;
                        Players[i].Chips -= big;
                        pot += big;
                    }

                    if (Players[i].smallBlind)
                    {
                        int small = 100;
                        Players[i].Chips -= small;
                        pot += small;
                    }

                    if (!isAbsent)
                    {
                        //2 Movements
                        if (Index < Players.Count - 1)
                        {
                            Index++;
                            // Sound to inform about the turn of another player
                            Console.Beep(600, 1000);
                            //Update Pot
                            DrawCard.DrawPot(pot);
                            DrawCard.UpdateChipsEsp(Players);
                        }
                        else
                        {
                            Index = 0;
                            Console.Beep(600, 1000);
                            //Update Pot
                            DrawCard.DrawPot(pot);
                            DrawCard.UpdateChipsEsp(Players);
                        }
                    }
                    else
                    {
                        nIsAbsent = Index;
                        if (Index < Players.Count - 1)
                        {
                            Index++;
                        }
                        else
                        {
                            Index = 0;
                        }
                    }
                    DrawCard.UpdateChipsEsp(Players);
                }

                // 3 firsts cards of the middle
                if (allIsPlay)
                {
                    Flop(Deck);
                    allIsPlay = false;
                    for (int i = 0; i < Players.Count; i++)
                    {
                        MovementsEsp();

                        if (!isAbsent)
                        {
                            //2 Movements
                            if (Index < Players.Count - 1)
                            {
                                Index++;
                                // Sound to inform about the turn of another player
                                Console.Beep(600, 1000);
                                //Update Pot
                                DrawCard.DrawPot(pot);
                                DrawCard.UpdateChipsEsp(Players);
                            }
                            else
                            {
                                Index = 0;
                                Console.Beep(600, 1000);
                                //Update Pot
                                DrawCard.DrawPot(pot);
                                DrawCard.UpdateChipsEsp(Players);
                            }
                        }
                        else
                        {
                            nIsAbsent = Index;
                            if (Index < Players.Count - 1)
                            {
                                Index++;
                            }
                            else
                            {
                                Index = 0;
                            }
                        }
                    }
                }
                else
                {
                    allIsPlay = false;
                }


                if (allIsPlay)
                {
                    Turn(Deck);
                    for (int i = 0; i < Players.Count; i++)
                    {
                        MovementsEsp();

                        if (Index < Players.Count - 1)
                        {
                            Index++;
                            Console.Beep(600, 1000);
                            DrawCard.DrawPot(pot);
                            DrawCard.UpdateChipsEsp(Players);
                        }
                        else
                        {
                            Index = 0;
                            Console.Beep(600, 1000);
                            //Update Pot
                            DrawCard.DrawPot(pot);
                            DrawCard.UpdateChipsEsp(Players);
                        }
                    }
                }
                else
                {
                    allIsPlay = false;
                }

                // The last card of the middle
                if (allIsPlay)
                {
                    River(Deck);
                    for (int i = 0; i < Players.Count; i++)
                    {
                        MovementsEsp();

                        if (Index < Players.Count - 1)
                        {
                            Index++;
                            Console.Beep(600, 1000);
                            DrawCard.DrawPot(pot);
                            DrawCard.UpdateChipsEsp(Players);
                        }
                        else
                        {
                            Index = 0;
                            Console.Beep(600, 1000);
                            //Update Pot
                            DrawCard.DrawPot(pot);
                            DrawCard.UpdateChipsEsp(Players);
                        }
                    }
                }
                else
                {
                    allIsPlay = false;
                }
            } while (!allIsPlay);

            for (int timesToShuffle = 0; timesToShuffle < 10; timesToShuffle++)
            {
                Deck.Shuffle();
            }

            // Update cards after the turn
            CheckCardsEsp(Players, Deck);
            DrawCard.UpdateChipsEsp(Players);
            DrawCard.DrawTableEsp(Deck);
            DrawCard.DrawEsp(Players, Deck);
            //DrawCard.DrawResult(Players);
            pot   = 0;
            Index = 0;
            Deck.Reset();
            round++;
        } while (!exit);
    }