Exemplo n.º 1
0
        private void PlaceShipsOnBoard()
        {
            Console.WriteLine($"{MyGame.PlayerOne}, place your ships!");
            ConsoleView.WaitForUser();
            ConsoleView.PlacePlayerShipsOnBoard(MyGame);
            if (MyGame.Ai)
            {
                ShipPlacement.RandomPlacement(MyGame, true);
            }
            else
            {
                Console.Clear();
                Console.WriteLine($"{MyGame.PlayerTwo}, place your ships!");
                ConsoleView.WaitForUser();
                MyGame.PlayerOneTurn = false;
                ConsoleView.PlacePlayerShipsOnBoard(MyGame);
                MyGame.PlayerOneTurn = true;
            }
            var optionsBuilder = new DbContextOptionsBuilder();

            optionsBuilder.UseMySQL(
                "server=localhost;database=battleship;user=root;password=toor");
            Ctx = new AppDbContext(optionsBuilder.Options);
            Ctx.Add(MyGame);
            ActionMenu.BombingMenu(MyGame, Ctx);
        }
Exemplo n.º 2
0
        private void PlaceShipsRandomly()
        {
            InitBoard.InitializeBoard(MyGame);
            ShipPlacement.RandomPlacement(MyGame, false);
            var optionsBuilder = new DbContextOptionsBuilder();

            optionsBuilder.UseMySQL(
                "server=localhost;database=battleship;user=root;password=toor");
            Ctx = new AppDbContext(optionsBuilder.Options);
            Ctx.Add(MyGame);
            ActionMenu.BombingMenu(MyGame, Ctx);
        }