示例#1
0
        static void PropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            DependencyObjectDecl <T> typed = (DependencyObjectDecl <T>)d;

            if (typed.PropertyChanged != null)
            {
                typed.PropertyChanged(typed.parent, new PropertyChangedEventArgs("Value"));
            }
        }
        public StrategyDescription()
        {
            this.KingdomCards = new System.Collections.ObjectModel.ObservableCollection <DominionCard>();
            this.PurchaseOrderDescriptions = new System.Collections.ObjectModel.ObservableCollection <CardAcceptanceDescription>();
            this.TrashOrderDescriptions    = new System.Collections.ObjectModel.ObservableCollection <CardAcceptanceDescription>();
            this.StartingCardSplit         = new DependencyObjectDecl <Dominion.StartingCardSplit, DefaultSplit4>(this);
            this.EditingDescription        = new DependencyObjectDecl <PriorityDescription, DefaultPriorityDescription>(this);
            this.CurrentDescription        = new DependencyObjectDecl <System.Collections.ObjectModel.ObservableCollection <CardAcceptanceDescription>, DefaultObservableCollection>(this);

            this.EditingDescription.PropertyChanged          += EditingDescription_PropertyChanged;
            this.PurchaseOrderDescriptions.CollectionChanged += PurchaseOrderDescriptions_CollectionChanged;

            SetCurrentDescription();
        }
        public CardAcceptanceDescription()
        {
            this.Card                      = new DependencyObjectDecl <DominionCard>(this);
            this.Count                     = new DependencyObjectDecl <int>(this);
            this.TestCard                  = new DependencyObjectDecl <DominionCard>(this);
            this.CountSource               = new DependencyObjectDecl <Dominion.Strategy.Description.CountSource>(this);
            this.Comparison                = new DependencyObjectDecl <Dominion.Strategy.Description.Comparison>(this);
            this.Threshhold                = new DependencyObjectDecl <int>(this);
            this.SecondaryMatchVisible     = new DependencyObjectDecl <bool>(this);
            this.SecondaryMatchCardVisible = new DependencyObjectDecl <bool>(this);
            this.CountConditionVisible     = new DependencyObjectDecl <bool>(this);
            this.CanSimulateCard           = new DependencyObjectDecl <bool>(this);

            this.CountSource.PropertyChanged += CountSource_PropertyChanged;
            this.Card.PropertyChanged        += Card_PropertyChanged;
        }
示例#4
0
        public AppDataContext(MainPage mainPage)
        {
            this.mainPage = mainPage;

            this.allCards            = new SortableCardList();
            this.colonyPlatinumCards = new SortableCardList();
            this.shelterCards        = new SortableCardList();
            this.currentDeck         = new SortableCardList();
            this.commonCards         = new SortableCardList();
            this.baneCard            = new SortableCardList();
            this.eventCards          = new SortableCardList();
            this.availableCards      = new System.Collections.ObjectModel.ObservableCollection <DominionCard>();
            this.selectedCards       = new System.Collections.ObjectModel.ObservableCollection <DominionCard>();
            this.expansions          = new System.Collections.ObjectModel.ObservableCollection <Expansion>();

            this.DeckRating = new DependencyObjectDecl <int, DefaultIntZero>(this);
            this.WebRating  = new DependencyObjectDecl <int, DefaultIntZero>(this);

            this.Use3OrMoreFromExpansions = new DependencyObjectDeclWithSettings <bool, DefaultTrue>(this, "Use3OrMoreFromExpansions");
            this.RequireTrashing          = new DependencyObjectDeclWithSettings <bool, DefaultFalse>(this, "Require Trashing");
            this.RequirePlusCards         = new DependencyObjectDeclWithSettings <bool, DefaultFalse>(this, "Require Plus Card");
            this.RequirePlusBuy           = new DependencyObjectDeclWithSettings <bool, DefaultFalse>(this, "Require Plus Buy");
            this.RequirePlus2Actions      = new DependencyObjectDeclWithSettings <bool, DefaultFalse>(this, "Require Plus 2 Actions");
            this.RequireAttack            = new DependencyObjectDeclWithSettings <bool, DefaultFalse>(this, "Require Attack");
            this.AllowAttack = new DependencyObjectDeclWithSettings <bool, DefaultTrue>(this, "Allow Attack");

            this.player1Strategy          = new StrategyDescription();
            this.player2Strategy          = new StrategyDescription();
            this.currentStrategy          = new DependencyObjectDecl <StrategyDescription, DefaultEmptyStrategyDescription>(this);
            this.currentStrategy.Value    = this.player1Strategy;
            this.IsPlayer1StrategyChecked = new DependencyObjectDecl <bool, DefaultTrue>(this);
            this.IsPlayer2StrategyChecked = new DependencyObjectDecl <bool, DefaultFalse>(this);
            this.GetDecksFromWeb          = new DependencyObjectDeclWithSettings <bool, DefaultFalse>(this, "GetDecksFromWeb");

            this.CurrentPageConfig                         = new DependencyObjectDecl <PageConfig, DefaultCurrent>(this);
            this.SettingsButtonVisibility                  = new DependencyObjectDecl <SettingsButtonVisibility, DefaultSettingsButton>(this);
            this.UseSideBySideStrategy                     = new DependencyObjectDeclWithSettings <bool, DefaultFalse>(this, "View Strategy Side By Side");
            this.SideBySideVisibility                      = new DependencyObjectDecl <bool, DefaultFalse>(this);
            this.CompactStrategyVisibility                 = new DependencyObjectDecl <bool, DefaultFalse>(this);
            this.IsSelectionPresentOnCurrentDeck           = new DependencyObjectDecl <bool, DefaultFalse>(this);
            this.NextSimulationStep                        = new DependencyObjectDecl <SimulationStep, DefaultSimulationStep>(this);
            this.IsAddToPlayer1ButtonVisible               = new DependencyObjectDecl <bool, DefaultFalse>(this);
            this.IsAddToPlayer2ButtonVisible               = new DependencyObjectDecl <bool, DefaultFalse>(this);
            this.HintSelectedCardNotSimulatedButtonVisible = new DependencyObjectDecl <bool, DefaultFalse>(this);

            this.IsBaneCardVisible    = new DependencyObjectDecl <bool, DefaultFalse>(this);
            this.AreEventCardsVisible = new DependencyObjectDecl <bool, DefaultFalse>(this);

            this.StrategyResultsAvailable = new DependencyObjectDecl <bool, DefaultFalse>(this);
            this.StrategyReport           = new DependencyObjectDecl <string, DefaultEmptyString>(this);
            this.Player1Name       = new DependencyObjectDecl <string, DefaultEmptyString>(this);
            this.Player2Name       = new DependencyObjectDecl <string, DefaultEmptyString>(this);
            this.Player1WinPercent = new DependencyObjectDecl <double, DefaultDoubleZero>(this);
            this.Player2WinPercent = new DependencyObjectDecl <double, DefaultDoubleZero>(this);
            this.TiePercent        = new DependencyObjectDecl <double, DefaultDoubleZero>(this);

            this.UseShelters       = new DependencyObjectDecl <bool, DefaultFalse>(this);
            this.UseColonyPlatinum = new DependencyObjectDecl <bool, DefaultFalse>(this);

            this.expansions.Add(new Expansion("Adventures", ExpansionIndex.Adventures));
            this.expansions.Add(new Expansion("Alchemy", ExpansionIndex.Alchemy));
            this.expansions.Add(new Expansion("Base", ExpansionIndex.Base));
            this.expansions.Add(new Expansion("Cornucopia", ExpansionIndex.Cornucopia));
            this.expansions.Add(new Expansion("Dark Ages", ExpansionIndex.DarkAges));
            this.expansions.Add(new Expansion("Guilds", ExpansionIndex.Guilds));
            this.expansions.Add(new Expansion("Hinterlands", ExpansionIndex.Hinterlands));
            this.expansions.Add(new Expansion("Intrigue", ExpansionIndex.Intrigue));
            this.expansions.Add(new Expansion("Promo", ExpansionIndex.Promo));
            this.expansions.Add(new Expansion("Prosperity", ExpansionIndex.Prosperity));
            this.expansions.Add(new Expansion("Seaside", ExpansionIndex.Seaside));
            this.expansions.Add(new Expansion("Empires", ExpansionIndex.Empires));
            this.expansions.Add(new Expansion("Nocturne", ExpansionIndex.Nocturne));
            this.expansions.Add(new Expansion("Renaissance", ExpansionIndex.Renaissance));

            foreach (var expansion in expansions)
            {
                expansion.IsEnabled.PropertyChanged += ExpansionEnabledChangedEventHandler;
            }

            this.commonCards.PropertyChanged += AvailableCards_PropetyChanged;
            this.currentDeck.PropertyChanged += AvailableCards_PropetyChanged;
            this.currentDeck.PropertyChanged += UpdateBaneCard_PropetyChanged;
            this.eventCards.PropertyChanged  += UpdateEventCard_PropertyChanged;

            this.CurrentPageConfig.PropertyChanged               += CalculateCompactStrategyVisibility;
            this.CurrentPageConfig.PropertyChanged               += CalculateSideBySideViewVisibility;
            this.UseSideBySideStrategy.PropertyChanged           += CalculateSideBySideViewVisibility;
            this.IsSelectionPresentOnCurrentDeck.PropertyChanged += UpdateSimulationStepEvent;
            this.NextSimulationStep.PropertyChanged              += UpdatePlayerButtonVisibilitiesEvent;
            this.NextSimulationStep.PropertyChanged              += CalculateSideBySideViewVisibility;
            this.NextSimulationStep.PropertyChanged              += CalculateCompactStrategyVisibility;

            this.CalculateSideBySideViewVisibility(this, null);

            this.allCards.ApplyFilter(card => card != null && card.Expansion != ExpansionIndex._Unknown && this.expansions[(int)card.Expansion].IsEnabled.Value);
            this.currentDeck.ApplyFilter(card => card != null && card.Expansion != ExpansionIndex._Unknown && this.expansions[(int)card.Expansion].IsEnabled.Value);
            this.eventCards.ApplyFilter(card => card != null && card.Expansion != ExpansionIndex._Unknown && this.expansions[(int)card.Expansion].IsEnabled.Value);
        }