Ejemplo n.º 1
0
        public async Task<IHttpActionResult> CreateGame(Guid gameId)
        {
            var existingGame = await _games.GetGameAsync(gameId);

            if (existingGame.Status != GameStatus.None)
            {
                return NotFound();
            }

            var userId = Guid.Parse(User.Identity.GetUserId());
            var game = new Game().Initialize(gameId, 2)
                                 .AddUser(userId);

            foreach (var e in game.Events)
            {
                await _games.InsertGameEvent(e);
            }

            return RedirectToRoute("GetGame", new {gameId});
        }
Ejemplo n.º 2
0
        public static Game Replay(params GameEvent[] events)
        {
            var game = new Game();

            foreach (var @event in events.OrderBy(e => e.Version))
            {
                game.RaiseEvent(@event);
            }

            return game;
        }