private bool ProcessMove() { var hit = GameBoard !.DropBomb((int)ClickY !, (int)ClickX !); var state = new BoardState(GameSession !, GameBoard.WhiteToMove); GameSession !.BoardStates.Add(state); List <BoardTile> boardTiles = new(); var s = GameBoard.BoardHistory.Last(); for (int y = 0; y < s.Board[0].GetLength(0); y++) { for (int x = 0; x < s.Board[0].GetLength(1); x++) { boardTiles.Add( new BoardTile(state, x, y, s.Board[(int)GameBoard.BoardType.WhiteShips][y, x], s.Board[(int)GameBoard.BoardType.BlackShips][y, x], s.Board[(int)GameBoard.BoardType.WhiteHits][y, x], s.Board[(int)GameBoard.BoardType.BlackHits][y, x])); } } _db.BoardTiles.AddRange(boardTiles); _db.SaveChanges(); return(hit != false); }
private void SaveState() { var state = new BoardState(GameSession !, GameBoard !.WhiteToMove); GameSession !.BoardStates.Add(state); List <BoardTile> boardTiles = new(); var s = GameBoard.BoardHistory.Last(); for (int y = 0; y < s.Board[0].GetLength(0); y++) { for (int x = 0; x < s.Board[0].GetLength(1); x++) { boardTiles.Add( new BoardTile(state, x, y, s.Board[(int)GameBoard.BoardType.WhiteShips][y, x], s.Board[(int)GameBoard.BoardType.BlackShips][y, x], s.Board[(int)GameBoard.BoardType.WhiteHits][y, x], s.Board[(int)GameBoard.BoardType.BlackHits][y, x])); } } _db.BoardTiles.AddRange(boardTiles); _db.SaveChanges(); }