Ejemplo n.º 1
0
        public Task ProcessArgsAsync(List <string> args)
        {
            if (args.Any())
            {
                var roundComponent  = _roundSystem.Components.Single();
                var playerComponent = _roundSystem.GetCurrentPlayer();

                if (int.TryParse(args[0], out int guess) && playerComponent != null && roundComponent != null)
                {
                    playerComponent.GuessCount += 1;

                    if (guess == roundComponent.Answer)
                    {
                        playerComponent.Score += 1;
                        roundComponent.State   = RoundComponent.RoundState.Finish;
                    }
                    else
                    {
                        _ioHandler.SendOutputAsync($"{guess} is too {(guess > roundComponent.Answer ? "high" : "low")}");
                        roundComponent.State = RoundComponent.RoundState.NewTurn;
                    }
                }
            }
            else
            {
                _ioHandler.SendOutputAsync("You forgot to guess a number");
            }

            return(Task.CompletedTask);
        }
Ejemplo n.º 2
0
        public void SetUp()
        {
            _ioHandler = Substitute.For <IIOHandler>();

            var tuple = ("test", new List <string>(), (IUniverseCommandSource) new TestCommandSource(0));

            _ioHandler.GetInputAsync().Returns(Task.FromResult(tuple));
            _ioHandler.SendOutputAsync(Arg.Any <string>()).Returns(Task.CompletedTask);
        }