コード例 #1
0
 public Game(ref CardDesk cardDesk, Dictionary <Card.names, int> points)
 {
     this.Points   = points;
     this.cardDesk = cardDesk;
 }
コード例 #2
0
 public void SetNewDesc(ref CardDesk desk)
 {
     cardDesk = desk;
 }
コード例 #3
0
ファイル: Program.cs プロジェクト: Dmiri/BlackJack
        /// <summary>
        /// globally Created instances of classes:
        /// CardDesk cardDesk - for managing a playing deck
        ///Dictionary<Card.names, int> Points - pairs connecting the card and its cost.
        ///Game game - for storing players and managing the game process
        ///We offer the user the choice to download the game or start a new one.
        ///If we start a new one, we initialize the instance of the class of the game,
        ///creating new players and transferring the game deck.In the end of the game cycle,
        ///it is suggested to start a new round:
        ///All players return to the table and hand out cards from the new deck.
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            Console.Title = "Black Jeck";
            Console.WriteLine("Do you wan't to load the game? (Yes - \"y/Y\", No - \"n/N\").");
            for (bool flag = false; !flag;)
            {
                switch (Console.ReadLine().ToUpper())
                {
                case "Y":
                    Console.WriteLine("Enter the file name");
                    string fileName = Console.ReadLine();
                    try
                    {
                        game     = game.readOfFile(fileName);
                        cardDesk = game.Desk;
                        cardDesk.MixDesk();
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("Entered incorrect name. Repeat please: ");
                        continue;
                    }
                    flag = true;
                    break;

                case "N":
                    InitGame();
                    cardDesk.MixDesk();
                    game.StartPut(2);     //put two cards
                    flag = true;
                    break;

                default:
                    Console.WriteLine("Entered incorrect value. Repeat please: ");
                    break;
                }
            }

            while (true) //Gaming loop
            {
                ProcessGame();

                if (IsContonue())
                {
                    game.RemoveHands();
                    game.RemovePoints();
                    game.ActivGamers();
                    cardDesk = new CardDesk(CardDesk.Basic.basic);
                    cardDesk.MixDesk();
                    game.SetNewDesc(ref cardDesk);
                    game.StartPut(2); //put two cards
                }
                else
                {
                    Console.WriteLine();
                    Console.WriteLine("Name - Win");
                    Console.WriteLine(game.WinnersList());
                    Console.WriteLine();
                    Console.WriteLine("Click \"Enter\" to exit");
                    Console.ReadLine();
                    Environment.Exit(0);
                }
            }
        }