コード例 #1
0
        private void UpdateGrid()
        {
            DobbyDBHelper dobby = new DobbyDBHelper();

            dobby.UpdateGridToDB(Grid.Values.ToList());
            dobby.FreeDobby();
        }
コード例 #2
0
        public void SwitchActivePlayer()
        {
            DobbyDBHelper dobby = new DobbyDBHelper();

            this.ActivePlayer = dobby.SwitchPlayer(this.Game, this.ActivePlayer);

            dobby.FreeDobby();
        }
コード例 #3
0
        public List <Game> GetActiveGames()
        {
            DobbyDBHelper dobby    = new DobbyDBHelper();
            List <Game>   gameList = dobby.GetActiveGames();

            dobby.FreeDobby();
            return(gameList);
        }
コード例 #4
0
        public IHttpActionResult InitiateGame(string player1, int rows, int columns)
        {
            GameBoard     gameBoard = GameBoard.StartGame(player1, rows, columns);
            DobbyDBHelper dobby     = new DobbyDBHelper();

            gameBoard.Grid = dobby.GetGridDictionary();
            dobby.FreeDobby();
            return(Ok(gameBoard));
        }
コード例 #5
0
        private Ship IsShipSunk(Grid thisGrid, DobbyDBHelper dobby)
        {
            List <Grid> shipGrid = dobby.GetShipCoords(thisGrid);

            foreach (Grid grid in shipGrid)
            {
                if (grid.IsHit == false)
                {
                    return(null);
                }
            }
            return(shipGrid[0].Ship);
        }
コード例 #6
0
        public Message DropBomb(string coordinate)
        {
            if (Grid[coordinate.ToUpper()].IsHit)
            {
                return(null);
            }
            else
            {
                Grid          thisGrid = Grid[coordinate.ToUpper()];
                DobbyDBHelper dobby    = new DobbyDBHelper();
                Message       message  = dobby.DropBomb(thisGrid);
                message.SunkenShip = IsShipSunk(thisGrid, dobby);
                message.GameOver   = dobby.IsGameOver(thisGrid.Player);

                dobby.FreeDobby();

                return(message);
            }
        }