Ejemplo n.º 1
0
        public MainWindowViewModel()
        {
            _client  = new HttpClient();
            _baseURL = "https://localhost:44351/api/MasterMind";
            _gameId  = -1;
            Attempts = new ObservableCollection <Attempt>();


            GetValidCharacters();
            CreateGameCommand  = new GeneralNoParameterCommand(CreateGame);
            AttemptGameCommand = new GeneralNoParameterCommand(() =>
            {
                ValueOne   = string.IsNullOrWhiteSpace(ValueOne) ? "A" : ValueOne.ToUpper();
                ValueTwo   = string.IsNullOrWhiteSpace(ValueTwo) ? "A" : ValueTwo.ToUpper();
                ValueThree = string.IsNullOrWhiteSpace(ValueThree) ? "A" : ValueThree.ToUpper();
                ValueFour  = string.IsNullOrWhiteSpace(ValueFour) ? "A" : ValueFour.ToUpper();
                OnPropertyChanged("ValueOne");
                OnPropertyChanged("ValueTwo");
                OnPropertyChanged("ValueThree");
                OnPropertyChanged("ValueFour");

                string completeAttempt = $"{_gameId}_{ValueOne}{ValueTwo}{ValueThree}{ValueFour}";
                AttemptGame(completeAttempt);
            });
        }