Skip to content

Commit

Permalink
Add games
Browse files Browse the repository at this point in the history
  • Loading branch information
oneheed committed Aug 22, 2023
1 parent a1e5124 commit a55000a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace Gaas.GobbletGobblers.Application.UseCases
{
public class GameRequest
{
public List<GamePlayer> Players { get; set; }
}

public class GamePlayer
{
public string Id { get; set; }

public string Nickname { get; set; }
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,27 @@ public GameController(ILogger<GameController> logger, IRepository repository)
_repository = repository;
}

[HttpPost]
[Route("~/games")]
public async Task<dynamic> GamesAsync(GameRequest request)
{
var createGameRequest = new CreateGameRequest
{
PlayerName = request.Players[0].Nickname
};

var createGameResponse = await new CreateGameUseCase().ExecuteAsync(createGameRequest, _repository);

var joinGameRequest = new JoinGameRequest
{
Id = createGameResponse.Id,
PlayerName = request.Players[1].Nickname
};
_ = await new JoinGameUseCase().ExecuteAsync(joinGameRequest, _repository);

return new { url = $"https://oneheed.github.io/Gobblet-Gobblers/games/{createGameResponse.Id}" };
}

[HttpPost]
[Route("Create")]
public async Task<GameModel> CreateAsync(CreateGameRequest request)
Expand Down

0 comments on commit a55000a

Please sign in to comment.