public async Task OnGetShowBoardsAsync(int id) { var battleShipsSave = await _appDbContext.BattleShipsSaves.FirstOrDefaultAsync(e => e.Id == id); BattleShips = new BattleShips(battleShipsSave); Id = id; BattleShips.CheckIfGameHasFinished(); }
public async Task <IActionResult> OnGetAsync(int id) { var battleShipsSave = await _appDbContext.BattleShipsSaves.FirstOrDefaultAsync(e => e.Id == id); BattleShips = new BattleShips(battleShipsSave); BattleShips.CheckIfGameHasFinished(); if (battleShipsSave.GameType == GameType.HumanVsAi && !battleShipsSave.Player1Turn && !BattleShips.GameFinished) { return(await OnPostComputerMoveAsync(id)); } Id = id; if (battleShipsSave.GameType == GameType.HumanVsHuman) { HideBoards = true; } return(Page()); }