protected FieldElementViewModel(int row, int column, Condition value, ITicTacToeService game)
 {
     Row    = row;
     Column = column;
     _game  = game;
     Value  = value;
 }
Ejemplo n.º 2
0
 public MainViewModel(ITicTacToeService game)
 {
     Winner = " ";
     Play   = Visibility.Hidden;
     _game  = game;
     Cells  = new BindableCollection <MainFieldElementViewModel>();
     for (var i = 0; i < 9; i++)
     {
         Cells.Add(new MainFieldElementViewModel(i / 3, i % 3, Condition.FREE, this, game));
     }
 }
Ejemplo n.º 3
0
 public void NewGame()
 {
     Play   = Visibility.Visible;
     Winner = " ";
     _game  = new TicTacToeGame();
     Cells  = new BindableCollection <MainFieldElementViewModel>();
     for (var i = 0; i < 9; i++)
     {
         Cells.Add(new MainFieldElementViewModel(i / 3, i % 3, Condition.FREE, this, _game));
     }
     NotifyOfPropertyChange(() => _game);
     NotifyOfPropertyChange(() => Cells);
     NotifyOfPropertyChange(() => Play);
     NotifyOfPropertyChange(() => Winner);
 }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            //Initialize Service Providers (Dependency Injection)
            var serviceProvider = new ServiceCollection()
                                  .AddSingleton <ITicTacToeService, TicTacToeService>()
                                  .AddSingleton <ITicTacToeRandomService, TicTacToeRandomService>()
                                  .BuildServiceProvider();

            //Get instance of TicTacToeService to be used throughout (injectable)
            _ticTacToeService       = serviceProvider.GetService <ITicTacToeService>();
            _ticTacToeRandomService = serviceProvider.GetService <ITicTacToeRandomService>();

            //Initialize Noughts and Crosses
            InitializeTicTacToe(3);

            //Indicate user the game has finished!
            Console.WriteLine();
            Console.WriteLine("Thank you for using Noughts and Crosses!!");
            Console.WriteLine();
        }
Ejemplo n.º 5
0
 public HomeController(ITicTacToeService ticTacToeService)
 {
     _ticTacToeService = ticTacToeService;
 }
 public MainFieldElementViewModel(int row, int column, Condition value, MainViewModel mainFild, ITicTacToeService game)
     : base(row, column, value, game)
 {
     _mainFild = mainFild;
     Cells     = new BindableCollection <SubFieldElementViewModel>();
     for (var i = 0; i < 9; i++)
     {
         Cells.Add(new SubFieldElementViewModel(i / 3, i % 3, this, Condition.FREE, game));
     }
     SizeText = 50;
 }
Ejemplo n.º 7
0
 public void Setup()
 {
     _ticTacToeService       = new TicTacToeService();
     _ticTacToeRandomService = new TicTacToeRandomService(_ticTacToeService);
 }
 public SubFieldElementViewModel(int row, int column, MainFieldElementViewModel mainField, Condition value, ITicTacToeService game)
     : base(row, column, value, game)
 {
     _mainFild = mainField;
     SizeText  = 10;
 }
Ejemplo n.º 9
0
 public TicTacToeRandomService(ITicTacToeService ticTacToeService)
 {
     _ticTacToeService = ticTacToeService;
 }
Ejemplo n.º 10
0
 public TicTacToeAppService(ITicTacToeService ticTacToeService, IMapper mapper)
 {
     _ticTacToeService = ticTacToeService;
     _mapper           = mapper;
 }