コード例 #1
0
        public async Task OnGetShowBoardsAsync(int id)
        {
            var battleShipsSave = await _appDbContext.BattleShipsSaves.FirstOrDefaultAsync(e => e.Id == id);

            BattleShips = new BattleShips(battleShipsSave);
            Id          = id;
            BattleShips.CheckIfGameHasFinished();
        }
コード例 #2
0
        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());
        }