public Testing() { Logic m = new Logic(); TicTacToeViewModel vm = new TicTacToeViewModel(m); vm.RunTests(); }
public ViewResult Index() { TicTacToeBoard board = new TicTacToeBoard(); List <Cell> cells = board.GetCells(); foreach (Cell cell in cells) { cell.Mark = TempData[cell.Id]?.ToString(); } board.CheckForWinner(); TicTacToeViewModel model = new TicTacToeViewModel { Cells = cells, Selected = new Cell { Mark = TempData["nextTurn"]?.ToString() ?? "X" }, IsGameOver = board.HasWinner || board.HasAllCellsSelected }; if (model.IsGameOver) { TempData["nextTurn"] = "X"; TempData["message"] = board.HasWinner ? $"{board.WinningMark} wins!" : "It's a tie!"; } else { TempData.Keep(); } return(View(model)); }
public ResetAction(TicTacToeViewModel owner) : base(owner) { this._GameState = new bool?[9]; for (int i = 0; i < 9; i++) { this._GameState[i] = Owner.Board[i].Checked; } }
public TicTacToeForm() { InitializeComponent(); this.viewModel = new TicTacToeViewModel(); this.WireViewModel(); this.BindToViewModel(); this.ticTacToeBoard.ViewModel = this.viewModel; this.playerXInformationPanel.ViewModel = this.viewModel.PlayerXViewModel; this.playerOInformationPanel.ViewModel = this.viewModel.PlayerOViewModel; }
/// <summary> /// Alkalmazás indulásának eseménykezelője. /// </summary> private void App_Startup(object sender, StartupEventArgs e) { _dataAccess = new TicTacToeFileDataAccess(); _model = new BasicTicTacToeModel(_dataAccess); _model.GameWon += new EventHandler <GameWonEventArgs>(Model_GameWon); _model.GameOver += new EventHandler(Model_GameOver); _model.NewGame(); _viewModel = new TicTacToeViewModel(_model); _viewModel.LoadGame += new EventHandler(ViewModel_LoadGame); // kezeljük a nézetmodell eseményeit _viewModel.SaveGame += new EventHandler(ViewModel_SaveGame); _viewModel.GameExit += new EventHandler(ViewModel_GameExit); _window = new TicTacToeWindow(); _window.DataContext = _viewModel; _window.Show(); }
public ActionResult Input(TicTacToeViewModel model) { SetPlayerUi(model.Selected); if (CheckWinner()) { return(View("Index", GetViewModel())); } if (_selectedDropDownList.Count == 0) { _submitEnable = false; _result = "Tie"; return(View("Index", GetViewModel())); } SetAIUi(); CheckWinner(); return(View("Index", GetViewModel())); }
public GamesViewModel() { LoginViewModel = new LoginViewModel(); ScoreboardViewModel = new ScoreboardViewModel(); TicTacToeViewModel = new TicTacToeViewModel(); PairGameViewModel = new PairGameViewModel(); RatingViewModel = new RatingViewModel(); SnakeViewModel = new SnakeViewModel(); DoorsGameViewModel = new DoorsGameViewModel(); MoneyViewModel = new MoneyViewModel(); _playerManager = new PlayerManager(); NewGameCommand = new RelayCommand(param => StartGame((string)param)); ShopCommand = new RelayCommand(param => { ShopWindow shopWindow = new ShopWindow(); shopWindow.ShowDialog(); }); ScoreboardCommand = new RelayCommand(param => { ScoreboardViewModel.Refresh(); ScoreboardView scoreboardView = new ScoreboardView(); scoreboardView.ShowDialog(); }); RatingCommand = new RelayCommand(param => { RatingView ratingView = new RatingView(); ratingView.ShowDialog(); }); PlayerEditCommand = new RelayCommand(param => { EditView editView = new EditView(); editView.ShowDialog(); }); AddMoneyCommand = new RelayCommand(param => { MoneyView moneyView = new MoneyView(); moneyView.ShowDialog(); }); StartGameTestingCommand = new RelayCommand(param => { StartGameTesting((string)param); }); BuyItemCommand = new RelayCommand(param => { if (int.Parse(param.ToString()) > Money) { MessageBox.Show("You do not have enough to buy this game.\n Consider adding money to your balance.", "Message", MessageBoxButton.OK); } else { _playerManager.AddMoney(LoginViewModel.Player.Id, -int.Parse(param.ToString())); Money = Money; } }); }
public RedirectToActionResult Index(TicTacToeViewModel viewModel) { TempData[viewModel.Selected.Id] = viewModel.Selected.Mark; TempData["nextTurn"] = viewModel.Selected.Mark == "X" ? "O" : "X"; return(RedirectToAction("Index")); }
public UserControl GetVisualisationUserControl(IConfigurable configuration) { _configuration = configuration; TicTacToeViewModel = new TicTacToeViewModel(); return(new TicTacToeUserControl(TicTacToeViewModel)); }
public TicTacToeUserControl(TicTacToeViewModel viewModel) { InitializeComponent(); DataContext = viewModel; }
public TicTacToeUpdateCommand(TicTacToeViewModel Tac) { this._tac = Tac; }