public async Task <CreateGameResult> CreateGame(CreateGameRequest request) { try { DynamicParameters parameters = new DynamicParameters(); parameters.Add("@GameName", request.GameName); parameters.Add("@Gameplay", request.Gameplay); parameters.Add("@Conclusion", request.Conclusion); parameters.Add("@Image", request.Image); parameters.Add("@Price", request.Price); parameters.Add("@Graphics", request.Graphics); parameters.Add("@Levels", request.Levels); parameters.Add("@Dificulty", request.Dificulty); parameters.Add("@Testimonials", request.Testimonials); parameters.Add("@IdCategory", request.IdCategory); return(await SqlMapper.QueryFirstOrDefaultAsync <CreateGameResult>(cnn : connect, sql : "sp_CreateGames", param : parameters, commandType : CommandType.StoredProcedure)); } catch (Exception ex) { throw; } }
public async Task <Game> CreateGameAsync(GameConfig config, string token) { try { var request = new CreateGameRequest { Config = new Jinrou.Config { PlayerNum = config.PlayerNum, WerewolfNum = config.WerewolfNum } }; var response = await _client.CreateGameAsync(request, CreateHeader(token)); return(ConvertState(response.State)); } catch (RpcException ex) { throw JinrouExceptionMapper.Transform(ex); } catch { throw; } }
public CreateGameResponse CreateGame(CreateGameRequest createGameRequest, Operations.ErrorCode expectedResult) { var request = CreateOperationRequest(OperationCode.CreateGame); if (createGameRequest.GameId != null) { request.Parameters[ParameterCode.RoomName] = createGameRequest.GameId; } if (createGameRequest.LobbyName != null) { request.Parameters[(byte)Operations.ParameterCode.LobbyName] = createGameRequest.LobbyName; } if (createGameRequest.LobbyType != 0) { request.Parameters[(byte)Operations.ParameterCode.LobbyType] = createGameRequest.LobbyType; } if (createGameRequest.GameProperties != null) { request.Parameters[(byte)Operations.ParameterCode.GameProperties] = createGameRequest.GameProperties; } var response = this.SendRequestAndWaitForResponse(request, (short)expectedResult); return(GetCreateGameResponse(response)); }
public override async Task <CreateGameReply> CreateGame(CreateGameRequest request, ServerCallContext context) { _logger.LogInformation("Create new game {Name}", request.Name); var newId = await _repo.Create(new Game { GameId = new Guid(request.GameId), Name = request.Name, Title = request.Title, Publisher = request.Publisher, Developer = request.Developer, Genre = request.Genre, Modes = request.Modes, Series = request.Series, Year = request.Year, Release = new Release { Aes = new DateTime(request.Relase.Aes), Mvs = new DateTime(request.Relase.Mvs), Cd = new DateTime(request.Relase.Cd) } }); return(new CreateGameReply { NewId = newId.ToString() }); }
public OperationResponse HandleCreateGame(OperationRequest operationRequest, SendParameters sendParameters) { var createGameRequest = new CreateGameRequest(this.Protocol, operationRequest); OperationResponse response; if (OperationHelper.ValidateOperation(createGameRequest, log, out response) == false) { return(response); } if (createGameRequest.LobbyType > 3) { return(new OperationResponse { OperationCode = operationRequest.OperationCode, ReturnCode = (short)ErrorCode.OperationInvalid, DebugMessage = "Invalid lobby type " + createGameRequest.LobbyType }); } AppLobby lobby; response = this.TryGetLobby(createGameRequest.LobbyName, createGameRequest.LobbyType, operationRequest.OperationCode, out lobby); if (response != null) { return(response); } lobby.EnqueueOperation(this, operationRequest, sendParameters); return(null); }
public Task CreateGame(CreateGameRequest createGameRequest) { createGameRequest.SelectedTeams = createGameRequest.Teams.Select(_ => _teamRepository.GetTeam(new Guid(_))).ToArray(); _gameRepository.CreateGame(createGameRequest); return(Task.CompletedTask); }
public async Task <ActionResult> CreateGame(CreateGameRequest request) { if (!await this.IsAPITokenValid(request.ApiToken)) { return(new BadRequestObjectResult("UnAuthorized")); } string leagueId = await this.GetLeagueId(request.LeagueKey); if (leagueId == null) { return(new BadRequestObjectResult("League Not Found")); } if (await this.TeamRepository.GetAsync(request.HomeTeamId) == null) { return(new BadRequestObjectResult("Home Team Not Found")); } if (await this.TeamRepository.GetAsync(request.AwayTeamId) == null) { return(new BadRequestObjectResult("Away Team Not Found")); } var newGame = await this.GameRepository.CreateAsync(request.HomeTeamId, request.AwayTeamId, request.SeasonId); return(new OkObjectResult(newGame)); }
public async Task <ActionResult <Game> > PostGame( [FromBody] CreateGameRequest request) { if (await appsService.IsRequestValidOnThisLicense( request.AppId, request.License, request.RequestorId)) { var result = await gamesService.CreateGame(request); if (result.Success) { result.Message = ControllerMessages.StatusCode201(result.Message); return(StatusCode((int)HttpStatusCode.Created, result)); } else { result.Message = ControllerMessages.StatusCode404(result.Message); return(NotFound(result)); } } else { return(BadRequest(ControllerMessages.InvalidLicenseRequestMessage)); } }
public async Task <IActionResult> StartNewGame([FromBody] CreateGameRequest createGameRequest) { if (string.IsNullOrEmpty(createGameRequest?.Name)) { return(BadRequest("Naam mag niet leeg zijn.")); } if (string.IsNullOrEmpty(createGameRequest?.Location)) { return(BadRequest("Locatie mag niet leeg zijn.")); } //if (createGameRequest?.MaximumParticipants == 0) //{ // return BadRequest("Vul een minimaal aantal deelnemers toe."); //} //if (string.IsNullOrEmpty(createGameRequest?.StartDate.ToString("yy-MM-dd"))) //{ // return BadRequest("Startdatum mag niet leeg zijn."); //} if (createGameRequest.Teams == null || createGameRequest?.Teams.Length < 2) { return(BadRequest("Er moeten minimaal 2 teams mee doen.")); } if (string.IsNullOrEmpty(createGameRequest?.Manager)) { return(BadRequest("Er moet een beheerder van de game zijn.")); } await _gameService.CreateGame(createGameRequest); return(Ok()); }
public CreateGameResponse CreateGame(string gameId, bool isVisible, bool isOpen, byte maxPlayer, Hashtable gameProperties, string[] lobbyProperties, Hashtable playerProperties, short expectedResult = ErrorCode.Ok) { if (gameProperties == null) { gameProperties = new Hashtable(); } var createGameRequest = new CreateGameRequest { GameId = gameId, GameProperties = gameProperties, ActorProperties = playerProperties }; createGameRequest.GameProperties[GameParameter.IsVisible] = isVisible; createGameRequest.GameProperties[GameParameter.IsOpen] = isOpen; createGameRequest.GameProperties[GameParameter.MaxPlayers] = maxPlayer; if (lobbyProperties != null) { createGameRequest.GameProperties[GameParameter.LobbyProperties] = lobbyProperties; } return(this.CreateGame(createGameRequest, expectedResult)); }
public async Task CreateGame(CreateGameRequest request) { var connectionId = Context.ConnectionId; async Task InvokeOnCreateGameResponse(CreateGameResponse resp) { if (resp.IsSuccess) { await _gameService.EventManager.AddConnection(resp.Game.GameId, request.Player.PlayerId, connectionId); } _logger.LogInformation("Sending Response: {}", resp); await Clients.Caller.SendAsync("OnCreateGameResponse", resp); } try { await _gameService.CreateGameAsync(request, InvokeOnCreateGameResponse); } catch (Exception ex) { _logger.LogError(ex, nameof(CreateGame)); await InvokeOnCreateGameResponse(new CreateGameResponse() { ErrorMessage = $"{ex.GetType()}: {ex.Message}" }); } }
public IActionResult CreateGame([FromBody] CreateGameRequest request) { _logger.Debug("Creating Game"); _gameState = new GameState(request.player1Name, request.player2Name); return(Ok()); }
public async Task Setup() { context = await TestDatabase.GetDatabaseContext(); mockGamesService = new MockGamesService(context); mockAppsService = new MockAppsService(context); baseRequest = new BaseRequest(); createGameRequest = new CreateGameRequest(); getMyGameRequest = new GamesRequest() { UserId = 1, License = TestObjects.GetLicense(), RequestorId = 1, Paginator = new Paginator() }; updateGameRequest = TestObjects.GetUpdateGameRequest(); sutSuccess = new GamesController( mockGamesService.GamesServiceSuccessfulRequest.Object, mockAppsService.AppsServiceSuccessfulRequest.Object); sutFailure = new GamesController( mockGamesService.GamesServiceFailedRequest.Object, mockAppsService.AppsServiceSuccessfulRequest.Object); }
private static async Task <CreateGameResponse> CreateGameAsync(string gameVariantId, string gameMasterUserId, string organizationId) { try { var request = new CreateGameRequest() { GameVariantId = gameVariantId, GameMasterUserId = gameMasterUserId, OrganizationId = organizationId }; HttpResponseMessage response = await client.PostAsync("Game", new StringContent(JsonConvert.SerializeObject(request), Encoding.UTF8, "application/json")); response.EnsureSuccessStatusCode(); var responseObj = await response.Content.ReadAsAsync <CreateGameResponse>(); return(responseObj); } catch (HttpRequestException e) { Console.WriteLine("\nException Caught!"); Console.WriteLine("Message :{0} ", e.Message); } return(null); }
public PendingGame(CreateGameRequest request) : this() { Format = request.Format; Name = request.Name; PlayerCount = request.PlayerCount; BaseHitpoints = request.BaseHitpoints; }
void Client_CreateRomme() { CreateGameRequest model_create_room = new CreateGameRequest(); model_create_room.UserName = "******"; NetHelp.Send <CreateGameRequest>(Op.Client.CreateRoom, model_create_room, Connection.Client.socket); }
public IActionResult Post([FromBody] CreateGameRequest newGame) { Player player = (Player)HttpContext.Items["Player"]; // Verify that everything is OK. int nrOfOngoingGames = player.races.Count; int nrofAllowedGames = 0; IConfiguration config = Config.GetConfiguration(player); int nrOfAllowedGames = config.GetMaxNrOfParalellGames(); if (player.races.Count > nrofAllowedGames) { return(new OkResult());// TODO:400 not allowed operation } // Add to repository. Race newRace = new Race(newGame.minNrOfPlayers, newGame.maxNrOfPlayers, player); bool opOk = raceRepo.Add(newRace); // Map to Race resource and send back to client. RaceResource race = new RaceResource { Id = newRace.Id }; //race.Relations.Add(Link.CreateLink("/v1/players")) return(new OkObjectResult(race)); }
public void TestInitialize() { InitializeFakes(); MappingProfileInitilizer.ConfigureMappings(); request = new CreateGameRequest(FakeRepository, FakeRepositoryAggregate); createGame = () => FakeRepository.Create(A <Game> .Ignored); }
public OperationResponse HandleCreateGame(OperationRequest operationRequest, SendParameters sendParameters) { var createGameRequest = new CreateGameRequest(this.Protocol, operationRequest); OperationResponse response; if (OperationHelper.ValidateOperation(createGameRequest, log, out response) == false) { return(response); } if (string.IsNullOrEmpty(createGameRequest.LobbyName) && this.AppLobby != null) { this.AppLobby.EnqueueOperation(this, operationRequest, sendParameters); return(null); } AppLobby lobby; if (!this.Application.LobbyFactory.GetOrCreateAppLobby(createGameRequest.LobbyName, (AppLobbyType)createGameRequest.LobbyType, out lobby)) { return(new OperationResponse { OperationCode = operationRequest.OperationCode, ReturnCode = (short)ErrorCode.OperationDenied, DebugMessage = "Lobby does not exists" }); } lobby.EnqueueOperation(this, operationRequest, sendParameters); return(null); }
public IActionResult Create([FromBody] CreateGameRequest request) { var game = Mapper.Map <Game>(request); int gameId = _gameService.Create(game, request.Players); return(Created(new Uri($""), gameId)); }
public CreateGameResponse CreateGame(string gameId, short expectedResult = ErrorCode.Ok) { var createGameRequest = new CreateGameRequest { GameId = gameId }; return(this.CreateGame(createGameRequest, expectedResult)); }
public CreateGameResponse CreateGame(string gameId, Operations.ErrorCode expectedResult) { var createGameRequest = new CreateGameRequest { GameId = gameId }; return(this.CreateGame(createGameRequest, expectedResult)); }
public CreateGameResponse CreateGame(CreateGameRequest request) { CreateGameResponse response = new CreateGameResponse { IsSuccess = true }; return(response); }
public void Inheritence() { var request = new CreateGameRequest(FakeRepository, FakeRepositoryAggregate); request.Should().NotBeNull(); request.Should().BeAssignableTo <ICreateGameRequest>(); request.Should().BeAssignableTo <BaseServiceRequest <Game> >(); request.Should().BeOfType <CreateGameRequest>(); }
public IActionResult Post(CreateGameRequest request) { var newGame = _mapper.Map <CreateGameDto>(request); var gameId = _service.CreateGame(newGame); var response = _mapper.Map <CreateGameResponse>(gameId); return(Ok(response)); }
void Awake() { _instance = this; joinGameRequest = GetComponent <JoinGameRequest>(); createGameRequest = GetComponent <CreateGameRequest>(); teamChooseRequest = GetComponent <TeamChooseRequest>(); sendDamageRequest = GetComponent <SendDamageRequest>(); syncDropWeaponRequest = GetComponent <SyncDropWeaponRequest>(); deleteDropWeaponRequest = GetComponent <DeleteDropWeaponRequest>(); }
public static void Execute(MyJoby joby, Entity entity, int index, ref CreateGameRequest rpc, ref ReceiveRpcCommandRequestComponent req) { var e = joby.Buffer.Instantiate(index, joby.Prefab); joby.Buffer.SetComponent(index, e, new GameInfoComponent { Id = joby.GameIds[index], Name = rpc.Name, SizeX = rpc.Size.x, SizeY = rpc.Size.y }); joby.Buffer.DestroyEntity(index, entity); }
public void Create(CreateGameRequest request) { gameRepository.Create(new GameEntity() { GenreId = request.GenreId, Name = request.Name, PublisherId = request.PublisherId, ReleaseDate = request.ReleaseDate }); }
public async Task Post([FromBody] CreateGameRequest request) { await _createGameCommandHandler.Execute( new CreateGameCommand { GameId = request.GameId, FirstTeamId = request.FirstTeamId, SecondTeamId = request.SecondTeamId }); }
protected virtual OperationResponse HandleCreateGame(MasterClientPeer peer, OperationRequest operationRequest) { // validate the operation request OperationResponse response; var operation = new CreateGameRequest(peer.Protocol, operationRequest); if (OperationHelper.ValidateOperation(operation, log, out response) == false) { return(response); } // special handling for game properties send by AS3/Flash (Amf3 protocol) or JSON clients var protocol = peer.Protocol.ProtocolType; if (protocol == ProtocolType.Amf3V151 || protocol == ProtocolType.Amf3V152 || protocol == ProtocolType.Json) { Utilities.ConvertAs3WellKnownPropertyKeys(operation.GameProperties, null); // special treatment for game properties sent by AS3/Flash } // if no gameId is specified by the client generate a unique id if (string.IsNullOrEmpty(operation.GameId)) { operation.GameId = Guid.NewGuid().ToString(); } else { // check if a game with the specified id already exists if (this.GameList.ContainsGameId(operation.GameId)) { return(new OperationResponse(operationRequest.OperationCode) { ReturnCode = (int)ErrorCode.GameIdAlreadyExists, DebugMessage = "A game with the specified id already exist." }); } } // try to create game GameState gameState; if (!this.TryCreateGame(operation, operation.GameId, operation.GameProperties, out gameState, out response)) { return(response); } // add peer to game gameState.AddPeer(peer); this.ScheduleCheckJoinTimeOuts(); // publish operation response object createGameResponse = this.GetCreateGameResponse(peer, gameState); return(new OperationResponse(operationRequest.OperationCode, createGameResponse)); }
public CreateGameReply OnCreateGameRequest(ServerClient client, CreateGameRequest request, out ServerGame game) { Map map = GetMap(request.GameConfiguration.Map); if (map == null) throw new ServerClientException("No such map"); ValidateGameConfiguration(request.GameConfiguration); if (request.IsPrivate) { string privateKey = GeneratePrivateKey(); game = new ServerGame(this, client, true, privateKey, request.GameConfiguration, map); PrivateGames[privateKey] = game; return new CreateGameReply(privateKey); } else { game = new ServerGame(this, client, false, null, request.GameConfiguration, map); PublicGames[client.Name] = game; return new CreateGameReply(); } }
public OperationResponse HandleCreateGame(OperationRequest operationRequest, SendParameters sendParameters) { var createGameRequest = new CreateGameRequest(this.Protocol, operationRequest); OperationResponse response; if (OperationHelper.ValidateOperation(createGameRequest, log, out response) == false) { return response; } if (createGameRequest.LobbyType > 3) { return new OperationResponse { OperationCode = operationRequest.OperationCode, ReturnCode = (short)ErrorCode.OperationInvalid, DebugMessage = "Invalid lobby type " + createGameRequest.LobbyType }; } AppLobby lobby; response = this.TryGetLobby(createGameRequest.LobbyName, createGameRequest.LobbyType, operationRequest.OperationCode, out lobby); if (response != null) { return response; } lobby.EnqueueOperation(this, operationRequest, sendParameters); return null; }
public CreateGameResponse Post(CreateGameRequest request) { return UseCase.Execute(request); }
private void CreateGameOnGameServer() { if (log.IsDebugEnabled) { log.DebugFormat("GAME: Create game {0}", this.gameId); } var operation = new CreateGameRequest { GameId = this.gameId }; var request = new OperationRequest((byte)OperationCode.CreateGame, operation); this.gameServerClient.SendOperationRequest(request, new SendParameters()); }