Пример #1
0
        private void Run_button_Click(object sender, RoutedEventArgs e)
        {
            var          cards     = con.getModel().cardsToDisplay;
            List <ICard> ICards    = new List <ICard>();
            List <ICard> ICardsNOT = new List <ICard>();

            foreach (var card in cardsToPresent)
            {
                card.card.simulated = false;
                if (card.SelectedOrNot)
                {
                    ICards.Add(card.card.card);
                }
                else
                {
                    ICardsNOT.Add(card.card.card);
                }
            }

            //Run new simulation with criteria

            SetupData setup = SetupData.GetDefault();

            setup.MaxDuplicates = 1;
            setup.DeckSize      = 5;
            setup.Cardpool      = ICards;
            setup.StartCards    = 2;
            //setup.GamesEachDeckMustPlayMultiplier = 2; //Designer should be able to set this value as they want.

            SimulationCriteria sim = new SimulationCriteria(Int32.Parse(textBox_Copy3.Text));

            if (checkBox.IsChecked ?? false)
            {
                setup.DeckFactory   = DeckFactoryType.Unique;
                sim.deckFactoryType = DeckFactoryType.Unique;
            }
            else
            {
                setup.AmountOfDecksToGenerate = Int32.Parse(textBox.Text);
                setup.DeckFactory             = DeckFactoryType.Random;

                sim.deckFactoryType = DeckFactoryType.Unique;
                sim.NumberOfDecks   = Int32.Parse(textBox.Text);
            }

            setup.GamesEachDeckMustPlayMultiplier = Int32.Parse(textBox_Copy3.Text);
            sim.numberOfFightsPrDeck = Int32.Parse(textBox_Copy3.Text);

            if (checkBox1.IsChecked ?? false)
            {
                setup.matchupStrategyType = MatchupStrategyType.All;
                sim.matchupStrategyType   = MatchupStrategyType.All;
            }
            else
            {
                setup.matchupStrategyType    = MatchupStrategyType.SpecifiedAmount;
                setup.specifiedMatchupAmount = Int32.Parse(textBox_Copy3.Text);

                sim.matchupStrategyType    = MatchupStrategyType.SpecifiedAmount;
                sim.specifiedMatchupAmount = Int32.Parse(textBox_Copy3.Text);
            }
            con.simulationCriteria       = sim;
            con.simulationCriteria.setup = setup;
            var res = runSimulation(con, setup);

            var rankCriteria = new RankCriteria();

            rankCriteria.ands[0] = AND_S.IsChecked ?? false;
            rankCriteria.ands[1] = AND_S_Copy.IsChecked ?? false;
            rankCriteria.ands[2] = AND_S_Copy1.IsChecked ?? false;
            rankCriteria.ands[3] = AND_S_Copy2.IsChecked ?? false;
            rankCriteria.ands[4] = AND_S_Copy3.IsChecked ?? false;

            rankCriteria.ors[0] = OR_S.IsChecked ?? false;
            rankCriteria.ors[1] = OR_S_Copy.IsChecked ?? false;
            rankCriteria.ors[2] = OR_S_Copy1.IsChecked ?? false;
            rankCriteria.ors[3] = OR_S_Copy2.IsChecked ?? false;
            rankCriteria.ors[4] = OR_S_Copy3.IsChecked ?? false;

            rankCriteria.winRatio_t[0] = Win_box_S.IsChecked ?? false;
            rankCriteria.winRatio_t[1] = Win_box_S_Copy.IsChecked ?? false;
            rankCriteria.winRatio_t[2] = Win_box_S_Copy1.IsChecked ?? false;
            rankCriteria.winRatio_t[3] = Win_box_S_Copy2.IsChecked ?? false;
            rankCriteria.winRatio_t[4] = Win_box_S_Copy3.IsChecked ?? false;

            rankCriteria.domminance_t[0] = Dom_box_S.IsChecked ?? false;
            rankCriteria.domminance_t[1] = Dom_box_S_Copy.IsChecked ?? false;
            rankCriteria.domminance_t[2] = Dom_box_S_Copy1.IsChecked ?? false;
            rankCriteria.domminance_t[3] = Dom_box_S_Copy2.IsChecked ?? false;
            rankCriteria.domminance_t[4] = Dom_box_S_Copy3.IsChecked ?? false;

            Win_S.Text       = Win_S.Text.Replace('%', ' ');
            Win_S_Copy.Text  = Win_S_Copy.Text.Replace('%', ' ');
            Win_S_Copy1.Text = Win_S_Copy1.Text.Replace('%', ' ');
            Win_S_Copy2.Text = Win_S_Copy2.Text.Replace('%', ' ');
            Win_S_Copy3.Text = Win_S_Copy3.Text.Replace('%', ' ');

            rankCriteria.winRatio[0] = Int32.Parse(Win_S.Text);
            rankCriteria.winRatio[1] = Int32.Parse(Win_S_Copy.Text);
            rankCriteria.winRatio[2] = Int32.Parse(Win_S_Copy1.Text);
            rankCriteria.winRatio[3] = Int32.Parse(Win_S_Copy2.Text);
            rankCriteria.winRatio[4] = Int32.Parse(Win_S_Copy3.Text);

            rankCriteria.domminance[0] = Double.Parse(Dom_S.Text);
            rankCriteria.domminance[1] = Double.Parse(Dom_S_Copy.Text);
            rankCriteria.domminance[2] = Double.Parse(Dom_S_Copy1.Text);
            rankCriteria.domminance[3] = Double.Parse(Dom_S_Copy2.Text);
            rankCriteria.domminance[4] = Double.Parse(Dom_S_Copy3.Text);

            con.rankCriteria = rankCriteria;

            this.Frame.Navigate((typeof(MainPage)), con);
        }