public override MatchController Given()
            {
                var calculator = Substitute.For <ICombatCalculator>();

                repo.Get(gameId).Returns(state);
                return(new MatchController(repo, calculator));
            }
示例#2
0
        public ActionResult SendCommands(Guid gameId, string player, [DynamicJson] IEnumerable <dynamic> commands)
        {
            var game = repo.Get(gameId);

            if (game == null)
            {
                return(Json(new { status = false, error = "Game could not be found" }));
            }

            var processor = new CommandProcessor(calculator, game);

            var result = processor.Process(commands);

            // TODO: save game
            repo.Edit(game);
            repo.Save();
            // TODO: error message format isn't right - needs command and message

            return(Json(new { status = true, data = new { gameId, player, units = result.Units, errors = result.Errors, notifications = result.Notifications } }));
        }
示例#3
0
 public GameState Load(Guid id)
 {
     return(_repo.Get(id));
 }