예제 #1
0
        public JsonResult UpdateState([FromBody] UserMoveModel userMove)
        {
            _gameApplication.UpdateState(userMove);

            var modelComponents = _gameApplication.GetViewComponents();

            return(Json(new TicTacViewModel(modelComponents.CurrentState, modelComponents.GameStatus, null)));
        }
예제 #2
0
        public void UpdateState(UserMoveModel userMove)
        {
            _gameRepository.UpdateGameMode(new GameModeModel()
            {
                GameMode = userMove.GameMode
            });

            int row    = userMove.MovePositions[0];
            int column = userMove.MovePositions[1];

            _gameState[row, column] = 'X';
            if (GetGameStatus() == "Still playing...")
            {
                PcMove(_gameRepository.GetGameMode());
            }
            UpdateDbState();
        }
예제 #3
0
        public async Task <IResultModel> Move(UserMoveModel model)
        {
            var entity = await _userRepository.FirstAsync(model.UserId);

            if (entity == null)
            {
                return(ResultModel.NotExists);
            }

            if (model.SourceId == model.TargetId)
            {
                return(ResultModel.Failed("不能移动至原位置"));
            }

            entity.OrganizeId = model.TargetId;

            var result = await _userRepository.UpdateAsync(entity);

            return(ResultModel.Result(result));
        }
예제 #4
0
 public Task <IResultModel> Move(UserMoveModel model)
 {
     return(_service.Move(model));
 }
 public void UpdateState(UserMoveModel userMove) => _gameEngine.UpdateState(userMove);