static void Main(string[] args) { IGameValidationService gamePresentationLayer = new GameValidationService(); IGenreValidationService genrePresentationLayer = new GenreValidationService(); IPublisherValidationService publisherPresentationLayer = new PublisherValidationService(); var genre1Id = genrePresentationLayer.Create(new CreateGenreViewModel() { Description = "Genre 1" }); var publisher1Id = publisherPresentationLayer.Create(new CreatePublisherViewModel() { Name = "Publisher 1", LicenceNumber = 1 }); gamePresentationLayer.Create(new CreateGameViewModel() { Name = "Game 1", ReleaseDate = new DateTime(2010, 1, 1), GenreId = genre1Id, PublisherId = publisher1Id }); }
public MoveCommand MakeMove(GameModel game, Move move, string promotionType = null) { if (game.GameStatusModel != null) { return(null); } var validatedMoveCommand = GameValidationService.ValidateMove(game, move); if (validatedMoveCommand == null) { return(null); } if (validatedMoveCommand is PawnPromotionCommand) { if (promotionType == null) { // we return without updating anything because we wait // the client to tell us which piece it wants to promote to return(validatedMoveCommand); } ((PawnPromotionCommand)validatedMoveCommand).PromotionType = promotionType; } var validatedMoveCommandClientCopy = validatedMoveCommand.Clone(); PiecesManagerService.UpdatePieces(game, validatedMoveCommand); SetGameStatus(game); UpdateGameMovesHistory(game, validatedMoveCommand); game.SwitchTurns(); return(validatedMoveCommandClientCopy); }
public GameController(GameService gameService, GameValidationService validationService) { this.gameService = gameService; this.validationService = validationService; }