Letní akce Python týden
Pouze tento týden sleva až 80 % na kurzy Python. Lze kombinovat s akcí Letní slevy na prémiový obsah!
Brno? Vypsali jsme pro vás nové termíny školení Základů programování a OOP v Brně!

Diskuze: prototyp karetní hříčky Black Jack - design a optimalizace

Aktivity (4)
Avatar
David Vlček
Člen
Avatar
David Vlček:14. února 16:40

Přemýšlím jak strukturovat a zpřehlednit zdroják. Nemám za sebou tolik aplikací a zkušeností a přemýšlím jak dál.

Zkusil jsem: Mám napsaný prototyp konzolové hříčky Black Jack. Funguje, i když má pár chyb, ale o to nejde.
Program jen nastaví parametry konzole a vytvoří instanci hry, kde je smyčka, List instancí karet, které se skutečně promíchávají, odebírají z balíku a rozdávají hráči a bankéři. Hráč ani bankéř instance nejsou. Reprezentuje je jen několik proměnných a jejich Listy rozdaných karet. Uživatel musí psát přesně definovaný příkazy aby pokračoval ve hře.

namespace BlackJack
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.BackgroundColor = ConsoleColor.DarkGreen;
            Console.ForegroundColor = ConsoleColor.Black;
            Console.BufferHeight = 50;
            Console.WindowHeight = 50;
            Console.BufferWidth = 120;
            Console.WindowWidth = 120;
            Console.Title = "THE BLACKJACK JACK";

            Game game = new Game();

            while (!game.End)
            {
                game.Table();
            }

            Console.ReadKey();
        }
    }
}
namespace BlackJack
{
    class Card
    {
        public enum CardFamily { Hearts, Tiles, Clovers, Pikes};

        public readonly string BackSide = " _____ " +
                                          "|WW~WW|" +
                                          "|}}:{{|" +
                                          "|}}:{{|" +
                                          "|}}:{{|" +
                                          "|MM~MM|";

        public CardFamily Family { get; private set; }
        public int Value { get; private set; }
        public string TextOutput { get; private set; }
        public bool Hidden { get; set; }

        public Card(CardFamily family, int value, string textOutput)
        {
            Family = family;
            Value = value;
            TextOutput = textOutput;
            Hidden = true;
        }

        public override string ToString()
        {
            if (!Hidden)
                return TextOutput;
            else
                return BackSide;
        }

    }
}
namespace BlackJack
{
    class Game
    {
        /// <summary>
        /// Card graphics source
        /// </summary>
        public string[,] CardTexts = new string[4, 13];
        private string[] PlayerOrders = { "double", "stand", "hit", "insure", "continue", "end", "even" };
        private string playerInput;

        private int xBanker = 0;    // Initial Position = X 35 | Y 8 - +10 is step
        private int yBanker = 0;
        private int xPlayer = 0;    // Initial Position = X 35 | Y 33 - +10 is step
        private int yPlayer = 0;

        /// <summary>
        /// List of the playing cards
        /// </summary>
        private List<Card> cards = new List<Card>();
        private List<Card> bankerCards = new List<Card>();
        private List<Card> playerCards = new List<Card>();

        /// <summary>
        /// player cash
        /// </summary>
        private int cash;
        private int bank;
        private int insurance;

        private int playerValue;
        private int bankerValue;

        private bool FirstCards { get; set; }
        private bool succes;
        private bool betGived;
        private bool bankerTurn;
        private bool playerTurn;
        private bool roundEnd;
        private bool insured;
        private bool doubled;
        public bool End { get; private set; }

        public Game()
        {
            CreateCards();
            InitializeCards();
            cards = ShuffleCards(cards);
            playerInput = "";
            FirstCards = true;
            betGived = false;
            bankerTurn = false;
            playerTurn = false;
            roundEnd = false;
            insured = false;
            doubled = false;
            cash = 2000;
            bank = 0;
        }

        private void NextGame()
        {
            cards.Clear();
            InitializeCards();
            cards = ShuffleCards(cards);
            playerInput = "";
            FirstCards = true;
            betGived = false;
            bankerTurn = false;
            playerTurn = false;
            roundEnd = false;
            insured = false;
            doubled = false;
            bank = 0;
        }

        private void PlayerBet()
        {
            int bet = 0;
            Console.CursorLeft = 26;
            Console.CursorTop = 27;
            Console.Write("Available bets: 10, 25, 50, 100, 250, 500, 1000");

            Console.CursorLeft = 26;
            Console.CursorTop = 26;
            Console.Write("Place your bet: ");

            succes = false;
            succes = int.TryParse(Console.ReadLine(), out bet);
            if (succes)
            {
                if (bet == 10 || bet == 25 || bet == 50 || bet == 100 || bet == 250 || bet == 500 || bet == 1000)
                {
                    cash -= bet;
                    bank += bet;
                }
                else
                {
                    Console.Write("INCORRECT INPUT ! ");
                    Console.Beep(100, 1000);
                    Thread.Sleep(1500);
                }
            }
            else
            {
                Console.Write("INCORRECT INPUT ! ");
                Console.Beep(100, 1000);
                Thread.Sleep(1500);
            }
        }

        private void BankerTurn()
        {
            if (bankerCards[1].Hidden)
            {
                bankerCards[1].Hidden = false;
            }
            else if (bankerValue < 17)
            {
                bankerCards.Add(cards[0]);
                bankerCards[bankerCards.Count - 1].Hidden = false;
                cards.RemoveAt(0);
                DrawCard(bankerCards[bankerCards.Count - 1], xBanker, yBanker);
                Console.Beep(300, 30);
                xBanker += 10;
                Thread.Sleep(100);
            }
            else if (bankerValue >= 17)
            {
                bankerTurn = false;
            }
        }

        private void PlayerTurn()
        {
            if (doubled)
            {
                playerCards.Add(cards[0]);
                playerCards[playerCards.Count - 1].Hidden = false;
                cards.RemoveAt(0);
                DrawCard(playerCards[playerCards.Count - 1], xPlayer, yPlayer);
                Console.Beep(300, 30);
                xPlayer += 10;
                Thread.Sleep(100);
                playerTurn = false;
            }
            else
            {
                playerCards.Add(cards[0]);
                playerCards[playerCards.Count - 1].Hidden = false;
                cards.RemoveAt(0);
                DrawCard(playerCards[playerCards.Count - 1], xPlayer, yPlayer);
                Console.Beep(300, 30);
                xPlayer += 10;
                Thread.Sleep(100);
                playerTurn = false;
            }
        }

        private void PlayerInput()
        {
            playerInput = "";
            if (playerValue <= 21)
            {
                if (playerValue == 21)
                {
                    if (playerCards.Count == 2 && bankerCards[0].Value != 1 || playerCards.Count == 2 && bankerCards[0].Value == 1 && bankerCards[1].Hidden == false && bankerValue != 21)
                    {
                        Console.CursorLeft = 26;
                        Console.CursorTop = 27;
                        Console.Write("Available orders: {0}, {1}", PlayerOrders[4], PlayerOrders[5]);

                        Console.CursorLeft = 26;
                        Console.CursorTop = 26;
                        Console.Write("BLACKJACK! Next step: ");

                        playerInput = Console.ReadLine();
                        playerInput = playerInput.ToLower();
                        playerInput = playerInput.Trim();

                        if (playerInput == PlayerOrders[4] || playerInput == PlayerOrders[5])
                        {
                            if (playerInput == PlayerOrders[5])
                            {
                                End = true;
                            }
                            else
                            {
                                cash += bank * 3;
                                bank = 0;
                                roundEnd = true;
                            }
                        }
                        else
                        {
                            Console.Write("INCORRECT INPUT ! ");
                            Console.Beep(100, 1000);
                            Thread.Sleep(1500);
                        }
                    }
                    else if (playerCards.Count == 2 && bankerCards[0].Value == 1 && bankerCards[1].Hidden == true)
                    {
                        Console.CursorLeft = 26;
                        Console.CursorTop = 27;
                        Console.Write("Available orders: {0}, {1}, {2}", PlayerOrders[4], PlayerOrders[5], PlayerOrders[6]);

                        Console.CursorLeft = 26;
                        Console.CursorTop = 26;
                        Console.Write("BLACKJACK! Next step: ");

                        playerInput = Console.ReadLine();
                        playerInput = playerInput.ToLower();
                        playerInput = playerInput.Trim();

                        if (playerInput == PlayerOrders[4] || playerInput == PlayerOrders[5] || playerInput == PlayerOrders[6])
                        {
                            if (playerInput == PlayerOrders[5])
                            {
                                End = true;
                            }
                            else if(playerInput == PlayerOrders[6])
                            {
                                cash += bank * 2;
                                bank = 0;
                                roundEnd = true;
                            }
                            else
                            {
                                bankerTurn = true;
                            }
                        }
                        else
                        {
                            Console.Write("INCORRECT INPUT ! ");
                            Console.Beep(100, 1000);
                            Thread.Sleep(1500);
                        }
                    }
                    else if (playerValue == bankerValue && bankerCards[1].Hidden == false)
                    {
                        Console.CursorLeft = 26;
                        Console.CursorTop = 27;
                        Console.Write("Available orders: {0}, {1}", PlayerOrders[4], PlayerOrders[5]);

                        Console.CursorLeft = 26;
                        Console.CursorTop = 26;
                        Console.Write("DRAW! Next step: ");

                        playerInput = Console.ReadLine();
                        playerInput = playerInput.ToLower();
                        playerInput = playerInput.Trim();

                        if (playerInput == PlayerOrders[4] || playerInput == PlayerOrders[5])
                        {
                            if (playerInput == PlayerOrders[5])
                            {
                                End = true;
                            }
                            else
                            {
                                cash += bank;
                                bank = 0;
                                roundEnd = true;
                            }
                        }
                        else
                        {
                            Console.Write("INCORRECT INPUT ! ");
                            Console.Beep(100, 1000);
                            Thread.Sleep(1500);
                        }
                    }
                }
                else
                {
                    if (bankerCards[0].Value == 1 && bankerCards[1].Hidden == true && insured == false && playerCards.Count == 2)
                    {
                        Console.CursorLeft = 26;
                        Console.CursorTop = 27;
                        Console.Write("Available orders: {0}, {1}, {2}", PlayerOrders[3], PlayerOrders[4], PlayerOrders[5]);

                        Console.CursorLeft = 26;
                        Console.CursorTop = 26;
                        Console.Write("INSURE? Next step: ");

                        playerInput = Console.ReadLine();
                        playerInput = playerInput.ToLower();
                        playerInput = playerInput.Trim();

                        if (playerInput == PlayerOrders[3] || playerInput == PlayerOrders[4] || playerInput == PlayerOrders[5])
                        {
                            if (playerInput == PlayerOrders[5])
                            {
                                End = true;
                            }
                            else if (playerInput == PlayerOrders[3])
                            {
                                insured = true;
                                insurance = bank / 2;
                                cash -= bank / 2;
                            }
                        }
                        else
                        {
                            Console.Write("INCORRECT INPUT ! ");
                            Console.Beep(100, 1000);
                            Thread.Sleep(1500);
                        }
                    }
                    if (bankerCards[1].Hidden == true && playerValue < 21)
                    {
                        Console.CursorLeft = 26;
                        Console.CursorTop = 27;
                        Console.Write("Available orders: {0}, {1}, {2}, {3}", PlayerOrders[0], PlayerOrders[1], PlayerOrders[2], PlayerOrders[5]);

                        Console.CursorLeft = 26;
                        Console.CursorTop = 26;
                        Console.Write("Next step: ");

                        playerInput = Console.ReadLine();
                        playerInput = playerInput.ToLower();
                        playerInput = playerInput.Trim();

                        if (playerInput == PlayerOrders[0] || playerInput == PlayerOrders[1] || playerInput == PlayerOrders[2] || playerInput == PlayerOrders[5])
                        {
                            if (playerInput == PlayerOrders[5])
                                End = true;
                            else if (playerInput == PlayerOrders[0])
                            {
                                cash -= bank;
                                bank += bank;
                                doubled = true;
                                playerTurn = true;
                                bankerTurn = true;
                            }
                            else if (playerInput == PlayerOrders[1])
                            {
                                bankerTurn = true;
                            }
                            else
                                playerTurn = true;
                        }
                        else
                        {
                            Console.Write("INCORRECT INPUT ! ");
                            Console.Beep(100, 1000);
                            Thread.Sleep(1500);
                        }
                    }
                    else
                    {
                        if (playerValue < bankerValue && bankerValue <= 21)
                        {
                            if (insured && bankerValue == 21 && bankerCards.Count == 2)
                            {
                                cash = insurance * 2;
                            }
                            Console.CursorLeft = 26;
                            Console.CursorTop = 27;
                            Console.Write("Available orders: {0}, {1}", PlayerOrders[4], PlayerOrders[5]);

                            Console.CursorLeft = 26;
                            Console.CursorTop = 26;
                            Console.Write("LOOSER! Next step: ");

                            playerInput = Console.ReadLine();
                            playerInput = playerInput.ToLower();
                            playerInput = playerInput.Trim();

                            if (playerInput == PlayerOrders[4] || playerInput == PlayerOrders[5])
                            {
                                if (playerInput == PlayerOrders[5])
                                    End = true;
                                else
                                    roundEnd = true;
                            }
                            else
                            {
                                Console.Write("INCORRECT INPUT ! ");
                                Console.Beep(100, 1000);
                                Thread.Sleep(1500);
                            }
                        }
                        else if (playerValue == bankerValue)
                        {
                            Console.CursorLeft = 26;
                            Console.CursorTop = 27;
                            Console.Write("Available orders: {0}, {1}", PlayerOrders[4], PlayerOrders[5]);

                            Console.CursorLeft = 26;
                            Console.CursorTop = 26;
                            Console.Write("DRAW! Next step: ");

                            playerInput = Console.ReadLine();
                            playerInput = playerInput.ToLower();
                            playerInput = playerInput.Trim();

                            if (playerInput == PlayerOrders[4] || playerInput == PlayerOrders[5])
                            {
                                if (playerInput == PlayerOrders[5])
                                {
                                    End = true;
                                }
                                else
                                {
                                    cash += bank;
                                    bank = 0;
                                    roundEnd = true;
                                }
                            }
                            else
                            {
                                Console.Write("INCORRECT INPUT ! ");
                                Console.Beep(100, 1000);
                                Thread.Sleep(1500);
                            }
                        }
                        else
                        {
                            Console.CursorLeft = 26;
                            Console.CursorTop = 27;
                            Console.Write("Available orders: {0}, {1}", PlayerOrders[4], PlayerOrders[5]);

                            Console.CursorLeft = 26;
                            Console.CursorTop = 26;
                            Console.Write("WINNER! Next step: ");

                            playerInput = Console.ReadLine();
                            playerInput = playerInput.ToLower();
                            playerInput = playerInput.Trim();

                            if (playerInput == PlayerOrders[4] || playerInput == PlayerOrders[5])
                            {
                                if (playerInput == PlayerOrders[5])
                                    End = true;
                                else
                                    cash += bank * 2;
                                    bank = 0;
                                    roundEnd = true;
                            }
                            else
                            {
                                Console.Write("INCORRECT INPUT ! ");
                                Console.Beep(100, 1000);
                                Thread.Sleep(1500);
                            }
                        }
                    }
                }
            }
            else
            {
                Console.CursorLeft = 26;
                Console.CursorTop = 27;
                Console.Write("Available orders: {0}, {1}", PlayerOrders[4], PlayerOrders[5]);

                Console.CursorLeft = 26;
                Console.CursorTop = 26;
                Console.Write("BUSTED! Next step: ");

                playerInput = Console.ReadLine();
                playerInput = playerInput.ToLower();
                playerInput = playerInput.Trim();

                if (playerInput == PlayerOrders[4] || playerInput == PlayerOrders[5])
                {
                    if (playerInput == PlayerOrders[5])
                        End = true;
                    else
                        roundEnd = true;
                }
                else
                {
                    Console.Write("INCORRECT INPUT ! ");
                    Console.Beep(100, 1000);
                    Thread.Sleep(1500);
                }
            }
        }

        private void GiveFirstCards()
        {
            xBanker = 35;
            yBanker = 8;
            xPlayer = 35;
            yPlayer = 33;
            playerCards.Clear();
            bankerCards.Clear();

            playerCards.Add(cards[0]);
            playerCards[playerCards.Count - 1].Hidden = false;
            cards.RemoveAt(0);
            DrawCard(playerCards[playerCards.Count - 1], xPlayer, yPlayer);
            Console.Beep(300, 30);
            xPlayer += 10;
            Thread.Sleep(100);

            bankerCards.Add(cards[0]);
            bankerCards[bankerCards.Count - 1].Hidden = false;
            cards.RemoveAt(0);
            DrawCard(bankerCards[bankerCards.Count - 1], xBanker, yBanker);
            Console.Beep(300, 30);
            xBanker += 10;
            Thread.Sleep(100);

            playerCards.Add(cards[0]);
            playerCards[playerCards.Count - 1].Hidden = false;
            cards.RemoveAt(0);
            DrawCard(playerCards[playerCards.Count - 1], xPlayer, yPlayer);
            Console.Beep(300, 30);
            xPlayer += 10;
            Thread.Sleep(100);

            bankerCards.Add(cards[0]);
            cards.RemoveAt(0);
            DrawCard(bankerCards[bankerCards.Count - 1], xBanker, yBanker);
            Console.Beep(300, 30);
            xBanker += 10;
            Thread.Sleep(100);

            FirstCards = false;
        }

        private void CountValues()
        {
            bankerValue = 0;
            playerValue = 0;
            bool ace = false;

            foreach (Card card in bankerCards)
            {
                bankerValue += card.Value;
                if (card.Value == 1 && ace != true)
                {
                    bankerValue += 10;
                    ace = true;
                }
            }
            if (ace == true && bankerValue > 21)
            {
                bankerValue -= 10;
            }

            ace = false;
            foreach (Card card in playerCards)
            {
                playerValue += card.Value;
                if (card.Value == 1 && ace != true)
                {
                    playerValue += 10;
                    ace = true;
                }
            }
            if (ace == true && playerValue > 21)
            {
                playerValue -= 10;
            }
        }

        public void Table()
        {
            if (roundEnd)
                NextGame();

            UpdateTable();
            CountValues();

            if (betGived && !bankerTurn)
                PlayerInput();
            if (playerTurn)
                PlayerTurn();
            else if (bankerTurn)
                BankerTurn();
        }

        private void UpdateTable()
        {
            Console.Clear();

            xBanker = 35;
            yBanker = 8;
            xPlayer = 35;
            yPlayer = 33;

            DrawBorders();
            DrawInfo();

            if (!FirstCards)
            {
                foreach (Card card in bankerCards)
                {
                    DrawCard(card, xBanker, yBanker);
                    xBanker += 10;
                }
                foreach (Card card in playerCards)
                {
                    DrawCard(card, xPlayer, yPlayer);
                    xPlayer += 10;
                }
            }
            else
            {
                PlayerBet();
                if (succes)
                {
                    GiveFirstCards();
                }
                betGived = true;
            }
        }

        private void DrawInfo()
        {
            Console.CursorLeft = 6;
            Console.CursorTop = 26;
            Console.Write("Player cash: {0}", cash);

            Console.CursorLeft = 6;
            Console.CursorTop = 22;
            Console.Write("Cash in game: {0}", bank);

            if (insured)
            {
                Console.CursorLeft = 6;
                Console.CursorTop = 22;
                Console.Write("INSURED");
            }
        }

        private void DrawBorders()
        {
            for (int i = 0; i < Console.WindowHeight - 2; i++)
            {
                Console.CursorTop = (Console.WindowHeight + 1 + i) - Console.WindowHeight;
                Console.CursorLeft = 0;
                Console.Write("||");
                Console.CursorLeft = Console.WindowWidth - 2;
                Console.Write("||");
            }
            Console.CursorTop = 1;
            Console.CursorLeft = 0;
            for (int i = 0; i < Console.WindowWidth; i++)
            {
                Console.Write("*");
            }
            Console.CursorTop = Console.WindowHeight - (Console.WindowHeight / 2);
            Console.CursorLeft = 0;
            for (int i = 0; i < Console.WindowWidth; i++)
            {
                Console.Write("*");
            }
            Console.CursorTop = Console.WindowHeight - 1;
            Console.CursorLeft = 0;
            for (int i = 0; i < Console.WindowWidth; i++)
            {
                Console.Write("*");
            }

            Console.CursorTop = Console.WindowHeight - 2;
            Console.CursorLeft = 3;
            Console.Write("ASCII art inspired by artists on www.asciiart.eu");
        }

        private void DrawCard(Card card, int x, int y)
        {
            int index = 0;
            string cardGraphic = card.ToString();


            for (int i = 0; i < 6; i++)
            {
                Console.CursorLeft = x;
                Console.CursorTop = y + i;
                Console.WriteLine(cardGraphic.Substring(index, 7));
                index += 7;
            }
            //Console.Beep(300, 30);
        }

        private void InitializeCards()
        {
            int value;
            Card.CardFamily family;
            for (int i = 0; i < 4; i++)
            {
                family = Card.CardFamily.Hearts;
                for (int j = 0; j < 13; j++)
                {
                    if (j + 1 > 10)
                        value = 10;
                    else
                        value = j + 1;
                    cards.Add(new Card(family, value, CardTexts[i, j]));
                }

            }
        }

        private List<Card> ShuffleCards(List<Card> list)
        {
            List<Card> tempList = new List<Card>();
            List<int> positions = new List<int>();
            Random random = new Random();
            int position = 0;

            while (positions.Count < list.Count)
            {
                position = random.Next(0, list.Count);
                if (!positions.Contains(position))
                {
                    tempList.Add(list[position]);
                    positions.Add(position);
                }
            }
            return tempList;
        }

        private void CreateCards()
        {
            CardTexts[0, 0] = " _____ " +
                              "|A    |" +
                              "| ♥ ♥ |" +
                              "| ♥ ♥ |" +
                              "|  ♥  |" +
                              "|____V|";

            CardTexts[1, 0] = " _____ " +
                              "|A    |" +
                              "|  ♦  |" +
                              "| ♦ ♦ |" +
                              "|  ♦  |" +
                              "|____V|";

            CardTexts[2, 0] = " _____ " +
                              "|A    |" +
                              "|  ♣  |" +
                              "|(♣♣♣)|" +
                              "|  ♣  |" +
                              "|____V|";

            CardTexts[3, 0] = " _____ " +
                              "|A ♠  |" +
                              "| ♠♠♠ |" +
                              "|♠ ♠ ♠|" +
                              "|  ♠  |" +
                              "|____V|";

            CardTexts[0, 1] = " _____ " +
                              "|2    |" +
                              "|  ♥  |" +
                              "|     |" +
                              "|  ♥  |" +
                              "|____Z|";

            CardTexts[1, 1] = " _____ " +
                              "|2    |" +
                              "|  ♦  |" +
                              "|     |" +
                              "|  ♦  |" +
                              "|____Z|";

            CardTexts[2, 1] = " _____ " +
                              "|2    |" +
                              "|  ♣  |" +
                              "|     |" +
                              "|  ♣  |" +
                              "|____Z|";

            CardTexts[3, 1] = " _____ " +
                              "|2    |" +
                              "|  ♠  |" +
                              "|     |" +
                              "|  ♠  |" +
                              "|____Z|";

            CardTexts[0, 2] = " _____ " +
                              "|3    |" +
                              "| ♥ ♥ |" +
                              "|     |" +
                              "|  ♥  |" +
                              "|____E|";

            CardTexts[1, 2] = " _____ " +
                              "|3    |" +
                              "| ♦ ♦ |" +
                              "|     |" +
                              "|  ♦  |" +
                              "|____E|";

            CardTexts[2, 2] = " _____ " +
                              "|3    |" +
                              "| ♣ ♣ |" +
                              "|     |" +
                              "|  ♣  |" +
                              "|____E|";

            CardTexts[3, 2] = " _____ " +
                              "|3    |" +
                              "| ♠ ♠ |" +
                              "|     |" +
                              "|  ♠  |" +
                              "|____E|";

            CardTexts[0, 3] = " _____ " +
                              "|4    |" +
                              "| ♥ ♥ |" +
                              "|     |" +
                              "| ♥ ♥ |" +
                              "|____h|";

            CardTexts[1, 3] = " _____ " +
                              "|4    |" +
                              "| ♦ ♦ |" +
                              "|     |" +
                              "| ♦ ♦ |" +
                              "|____h|";

            CardTexts[2, 3] = " _____ " +
                              "|4    |" +
                              "| ♣ ♣ |" +
                              "|     |" +
                              "| ♣ ♣ |" +
                              "|____h|";

            CardTexts[3, 3] = " _____ " +
                              "|4    |" +
                              "| ♠ ♠ |" +
                              "|     |" +
                              "| ♠ ♠ |" +
                              "|____h|";

            CardTexts[0, 4] = " _____ " +
                              "|5    |" +
                              "| ♥ ♥ |" +
                              "|  ♥  |" +
                              "| ♥ ♥ |" +
                              "|____S|";

            CardTexts[1, 4] = " _____ " +
                              "|5    |" +
                              "| ♦ ♦ |" +
                              "|  ♦  |" +
                              "| ♦ ♦ |" +
                              "|____S|";

            CardTexts[2, 4] = " _____ " +
                              "|5    |" +
                              "| ♣ ♣ |" +
                              "|  ♣  |" +
                              "| ♣ ♣ |" +
                              "|____S|";

            CardTexts[3, 4] = " _____ " +
                              "|5    |" +
                              "| ♠ ♠ |" +
                              "|  ♠  |" +
                              "| ♠ ♠ |" +
                              "|____S|";

            CardTexts[0, 5] = " _____ " +
                              "|6    |" +
                              "| ♥ ♥ |" +
                              "| ♥ ♥ |" +
                              "| ♥ ♥ |" +
                              "|____9|";

            CardTexts[1, 5] = " _____ " +
                              "|6    |" +
                              "| ♦ ♦ |" +
                              "| ♦ ♦ |" +
                              "| ♦ ♦ |" +
                              "|____9|";

            CardTexts[2, 5] = " _____ " +
                              "|6    |" +
                              "| ♣ ♣ |" +
                              "| ♣ ♣ |" +
                              "| ♣ ♣ |" +
                              "|____9|";

            CardTexts[3, 5] = " _____ " +
                              "|6    |" +
                              "| ♠ ♠ |" +
                              "| ♠ ♠ |" +
                              "| ♠ ♠ |" +
                              "|____9|";

            CardTexts[0, 6] = " _____ " +
                              "|7    |" +
                              "| ♥ ♥ |" +
                              "|♥ ♥ ♥|" +
                              "| ♥ ♥ |" +
                              "|____L|";

            CardTexts[1, 6] = " _____ " +
                              "|7    |" +
                              "| ♦ ♦ |" +
                              "|♦ ♦ ♦|" +
                              "| ♦ ♦ |" +
                              "|____L|";

            CardTexts[2, 6] = " _____ " +
                              "|7    |" +
                              "| ♣ ♣ |" +
                              "|♣ ♣ ♣|" +
                              "| ♣ ♣ |" +
                              "|____L|";

            CardTexts[3, 6] = " _____ " +
                              "|7    |" +
                              "| ♠ ♠ |" +
                              "|♠ ♠ ♠|" +
                              "| ♠ ♠ |" +
                              "|____L|";

            CardTexts[0, 7] = " _____ " +
                              "|8    |" +
                              "|♥ ♥ ♥|" +
                              "| ♥ ♥ |" +
                              "|♥ ♥ ♥|" +
                              "|____8|";

            CardTexts[1, 7] = " _____ " +
                              "|8    |" +
                              "|♦ ♦ ♦|" +
                              "| ♦ ♦ |" +
                              "|♦ ♦ ♦|" +
                              "|____8|";

            CardTexts[2, 7] = " _____ " +
                              "|8    |" +
                              "|♣ ♣ ♣|" +
                              "| ♣ ♣ |" +
                              "|♣ ♣ ♣|" +
                              "|____8|";

            CardTexts[3, 7] = " _____ " +
                              "|8    |" +
                              "|♠ ♠ ♠|" +
                              "| ♠ ♠ |" +
                              "|♠ ♠ ♠|" +
                              "|____8|";

            CardTexts[0, 8] = " _____ " +
                              "|9    |" +
                              "|♥ ♥ ♥|" +
                              "|♥ ♥ ♥|" +
                              "|♥ ♥ ♥|" +
                              "|____6|";

            CardTexts[1, 8] = " _____ " +
                              "|9    |" +
                              "|♦ ♦ ♦|" +
                              "|♦ ♦ ♦|" +
                              "|♦ ♦ ♦|" +
                              "|____6|";

            CardTexts[2, 8] = " _____ " +
                              "|9    |" +
                              "|♣ ♣ ♣|" +
                              "|♣ ♣ ♣|" +
                              "|♣ ♣ ♣|" +
                              "|____6|";

            CardTexts[3, 8] = " _____ " +
                              "|9    |" +
                              "|♠ ♠ ♠|" +
                              "|♠ ♠ ♠|" +
                              "|♠ ♠ ♠|" +
                              "|____6|";

            CardTexts[0, 9] = " _____ " +
                              "|10 ♥ |" +
                              "|♥ ♥ ♥|" +
                              "|♥ ♥ ♥|" +
                              "|♥ ♥ ♥|" +
                              "|___0I|";

            CardTexts[1, 9] = " _____ " +
                              "|10 ♦ |" +
                              "|♦ ♦ ♦|" +
                              "|♦ ♦ ♦|" +
                              "|♦ ♦ ♦|" +
                              "|___0I|";

            CardTexts[2, 9] = " _____ " +
                              "|10 ♣ |" +
                              "|♣ ♣ ♣|" +
                              "|♣ ♣ ♣|" +
                              "|♣ ♣ ♣|" +
                              "|___0I|";

            CardTexts[3, 9] = " _____ " +
                              "|10 ♠ |" +
                              "|♠ ♠ ♠|" +
                              "|♠ ♠ ♠|" +
                              "|♠ ♠ ♠|" +
                              "|___0I|";

            CardTexts[0, 10] = " _____ " +
                               "|J  WW|" +
                               "|   {)|" +
                               "|(♥)% |" +
                               "|   % |" +
                               "|__%%[|";

            CardTexts[1, 10] = " _____ " +
                               "|J  WW|" +
                               "|   {)|" +
                               "|(♦)% |" +
                               "|   % |" +
                               "|__%%[|";

            CardTexts[2, 10] = " _____ " +
                               "|J  WW|" +
                               "|   {)|" +
                               "|(♣)% |" +
                               "|   % |" +
                               "|__%%[|";

            CardTexts[3, 10] = " _____ " +
                               "|J  WW|" +
                               "|   {)|" +
                               "|(♠)% |" +
                               "|   % |" +
                               "|__%%[|";

            CardTexts[0, 11] = " _____ " +
                               "|Q  WW|" +
                               "|   {(|" +
                               "|(♥)%%|" +
                               "| ♥%%%|" +
                               "|_%%%O|";

            CardTexts[1, 11] = " _____ " +
                               "|Q  WW|" +
                               "|   {(|" +
                               "|(♦)%%|" +
                               "| ♦%%%|" +
                               "|_%%%O|";

            CardTexts[2, 11] = " _____ " +
                               "|Q  WW|" +
                               "|   {(|" +
                               "|(♣)%%|" +
                               "| ♣%%%|" +
                               "|_%%%O|";

            CardTexts[3, 11] = " _____ " +
                               "|Q  WW|" +
                               "|   {(|" +
                               "|(♠)%%|" +
                               "| ♠%%%|" +
                               "|_%%%O|";

            CardTexts[0, 12] = " _____ " +
                               "|K  WW|" +
                               "| ♥ {)|" +
                               "|(♥)%%|" +
                               "| ♥%%%|" +
                               "|_%%%>|";

            CardTexts[1, 12] = " _____ " +
                               "|K  WW|" +
                               "| ♦ {)|" +
                               "|(♦)%%|" +
                               "| ♦%%%|" +
                               "|_%%%>|";

            CardTexts[2, 12] = " _____ " +
                               "|K  WW|" +
                               "| ♣ {)|" +
                               "|(♣)%%|" +
                               "| ♣%%%|" +
                               "|_%%%>|";

            CardTexts[3, 12] = " _____ " +
                               "|K  WW|" +
                               "| ♠ {)|" +
                               "|(♠)%%|" +
                               "| ♠%%%|" +
                               "|_%%%>|";
        }
    }
}

Chci docílit: Jak jsem psal, nemám zkušenosti s projekty jako celky. Experimentoval jsem s C# a Java scripty v Unity3D, mám základní představu jak funguje C++. Ale teď se věnuju čistě C# a projektům v něm ve VS. A baví mě to. Uplně mě to pohltilo, udělat něco vlastního z ničeho.

Zajímá mě jak to vylepšit? Je mi jasný že to má hodně much, je to nepřehledný a pomalu se ve třídě Game ztrácím. Musím začít používat komentáře.
Jak to strukturovat? Jak by jste to udělali vy, zkušení?

Je to jen prototyp, nekoukám na úplnou funkčnost programu. Později to chci přepsat na celý Casino, kde si hráč zvolí co chce hrát (BlackJack, Poker, možná automaty nebo ruleta).
Možná to překopu z konzole do něčeho jiného. Ještě nevím jestli WPF, nebo XNA. Co by jste zvolili vy?

Konzole má přece jen svoje kouzlo.

Odpovědět 14. února 16:40
Nevěřím, že každý dokáže všechno co chce. Věřím ale, že by to měl zkusit.
Avatar
Odpovídá na David Vlček
Erik Šťastný:15. února 9:39

Konzole má své kouzlo výlučně pouze pro programátora, typický laik uživatel chce jednoduché GUI klikátko a ne nějakou škaredou konzoli jako z devadesátých let.

 
Nahoru Odpovědět  +1 15. února 9:39
Děláme co je v našich silách, aby byly zdejší diskuze co nejkvalitnější. Proto do nich také mohou přispívat pouze registrovaní členové. Pro zapojení do diskuze se přihlas. Pokud ještě nemáš účet, zaregistruj se, je to zdarma.

Zobrazeno 2 zpráv z 2.