예제 #1
0
        /// <summary>
        /// Oyunu başlatır
        /// </summary>
        /// <param name="loginAccount"></param>
        /// <param name="rivalId"></param>
        public bool StartGame(Account loginAccount, int rivalId)
        {
            var rivalAccount = _accountService.GetAccountById(rivalId) ?? new Account {
                Id = 0, Name = "Yapay Zeka"
            };
            var cardList = _gameService.GetCardList();
            var game     = new Game
            {
                PlayerOneAccount  = loginAccount,
                PlayerTwoAccount  = rivalAccount,
                PlayerCardDeck    = cardList,
                StartingHp        = 30,
                StartingMana      = 0,
                StartingManaSlot  = 0,
                StartingCardCount = 3
            };

            game.SetPlayers();
            game.DrawFirstCards();

            do
            {
                if (game.Played.Account.Id == 0) // Yapay zeka
                {
                    game.AIPlayed();
                }
                else
                {
                    game.StartTurn();
                }
                game.Turn++;
            } while (game.PlayerOne.Hp > 0 && game.PlayerTwo.Hp > 0);

            Console.Clear();
            Finish(game);

            Console.Write("Tekrar lobiye dönmek için 1'e basınız: ");
            var selectedIdString = Console.ReadLine();

            Console.Clear();
            return(selectedIdString == "1");
        }