예제 #1
0
 public GameViewModel()
 {
     Game = new Game()
     {
         Board = new string[][] { new string[] { "", "", "" }, new string[] { "", "", "" }, new string[] { "", "", "" } }
     };
     ResetGameScore();
     NewGame   = new NewGameCommand(this);
     ResetGame = new ResetGameCommand(this);
     PlayMove  = new PlayMoveCommand(this);
 }
예제 #2
0
 /// <summary>
 /// The OnGameOfLifePropertyChanged method is called when a property in the GameOfLife model class changes.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnGameOfLifePropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     try
     {
         StartGameCommand.RaiseCanExecuteChanged();
         StopGameCommand.RaiseCanExecuteChanged();
         StepGameCommand.RaiseCanExecuteChanged();
         ResetGameCommand.RaiseCanExecuteChanged();
         ToggleCellStateCommand.RaiseCanExecuteChanged();
     }
     catch (Exception ex)
     {
         throw new Exception("ConwaysGameOfLifeViewModel.OnGameOfLifePropertyChanged(object sender, PropertyChangedEventArgs e): " + ex.ToString());
     }
 }
예제 #3
0
 public async Task <IActionResult> ResetGame(ResetGameCommand command)
 {
     return(Ok(await _mediator.Send(command)));
 }
 ///<summary>
 /// Initializes new instance of Game class
 ///</summary>
 public GameViewModel()
 {
     _game                    = new Game(127, 0, 0, 1, 3000);
     ResetCommand             = new ResetGameCommand(this);
     RockPaperScissorsCommand = new RockPaperScissorsCommand(this);
 }
예제 #5
0
        static int Main(string[] args)
        {
            var tw = new TextWriterTraceListener(Console.Out);

            tw.TraceOutputOptions |= TraceOptions.None;
            Trace.Listeners.Add(tw);
            Trace.AutoFlush = true;
            Trace.Indent();

            var app = new CommandLineApplication
            {
                Name        = "TW ING Coding Challenge",
                Description = "The TeamWildenberg console app for the different assignments in the ING Coding Challenge"
            };

            app.HelpOption("-?|-h|--help");
            var versionOption = app.Option("-v|--version", "Check which version we are running", CommandOptionType.NoValue);

            app.OnExecute(() =>
            {
                return(0);
            });
            app.Execute(args);

            if (versionOption.HasValue())
            {
                var assemblyVersion = Assembly.GetEntryAssembly().GetCustomAttribute <AssemblyInformationalVersionAttribute>().InformationalVersion;
                TraceExtensions.DoMessage($"Version: {assemblyVersion}");
                return(0);
            }
            else
            {
                try
                {
                    // initialize

                    const int REFRESH_TIME_MS = 500;
                    var       gameService     = new TwgeService();
                    var       game            = new ResetGameCommand(gameService, null);
                    game.Execute(char.MinValue);

                    Console.Clear();

                    var nextLoopTime = DateTime.UtcNow.AddMilliseconds(REFRESH_TIME_MS);
                    //Game loop
                    do
                    {
                        if (nextLoopTime < DateTime.UtcNow)
                        {
                            gameService.Draw();
                            nextLoopTime = DateTime.UtcNow.AddMilliseconds(REFRESH_TIME_MS);

                            var commandList = gameService.GetActionCommands();
                            gameService.DoAction(commandList);
                        }
                    }while (gameService.CanContinue);
                    return(0);
                }
                catch (Exception)
                {
                    TraceExtensions.DoError($"Something fishy happened, exiting.");
                    throw;
                }
            }
        }