public JsonResult UpdateState([FromBody] UserMoveModel userMove) { _gameApplication.UpdateState(userMove); var modelComponents = _gameApplication.GetViewComponents(); return(Json(new TicTacViewModel(modelComponents.CurrentState, modelComponents.GameStatus, null))); }
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(); }
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)); }
public Task <IResultModel> Move(UserMoveModel model) { return(_service.Move(model)); }
public void UpdateState(UserMoveModel userMove) => _gameEngine.UpdateState(userMove);