public IActionResult Start(StartGameModel model)
 {
     try
     {
         var             generatorParams = new FieldGeneratorParams(SeedGenerator.GenerateSeed(), model.MinesCount);
         IFieldGenerator fieldGenerator  = FieldGeneratorFactory.Create(generatorParams);
         var             game            = new Game(fieldGenerator, model.Width, model.Height);
         Guid            gameKey         = Guid.NewGuid();
         GameStorage.AddGame(gameKey, game);
         return(Ok(new GameModelBase {
             GameKey = gameKey
         }));
     }
     catch (Exception ex)
     {
         Log.Error(ex, "Couldn't create the game with params {@Model}", model);
         return(Error("An error occured while creating the game"));
     }
 }
Esempio n. 2
0
 public FieldGenerator(FieldGeneratorParams parameters)
 {
     Parameters = parameters ?? throw new ArgumentNullException(nameof(parameters));
 }
 public IFieldGenerator Create(FieldGeneratorParams generatorParams)
 {
     return(new FieldGenerator(generatorParams));
 }