示例#1
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            var con = e.Parameter as ContainerClass;

            cont = con;
            checkBox_Common_Copy.IsEnabled = false;
            if (cont.simulationCriteria != null)
            {
                Rerun_button.IsEnabled = true;
            }
            else
            {
                Rerun_button.IsEnabled = false;
            }
            if (!(con.getCard() == null))
            {
                cont = con;
                var cardStat = con.getCard() as CardStats;
                setCardData(cardStat);
            }
            else
            {
                CostBox_Copy.Visibility = Visibility.Visible;
                NameBlock.Visibility    = Visibility.Collapsed;
                thisCard = new CardStats(new Card_User_Defined());
                textBlock_Copy10.Text = "UNKNOWN"; textBlock_Copy10.FontSize = 50;
                textBlock_Copy8.Text  = "UNKNOWN"; textBlock_Copy8.FontSize = 50;
                textBlock_Copy6.Text  = "?"; //RANK
                thisCard.card.setName("NNNNNNNNNNNNAAAAAMMMMMMMME");
                comboBoxWithCards.ItemsSource = gennereateCollection(thisCard);
            }
        }
示例#2
0
 private void spreadOutCards(CardStats card, Button b)
 {
     if (!card.simulated)
     { //IF not simulated, place it in B-Rank
         addToList(BRank, BRank1, BRank2, BRank3, b);
     }
     else
     {
         if (card.rank.Equals("F"))
         {
             addToList(FRank, FRank1, FRank2, FRank3, b);
         }
         else if (card.rank.Equals("C"))
         {
             addToList(CRank, CRank1, CRank2, CRank3, b);
         }
         else if (card.rank.Equals("B"))
         {
             addToList(BRank, BRank1, BRank2, BRank3, b);
         }
         else if (card.rank.Equals("A"))
         {
             addToList(ARank, ARank1, ARank2, ARank3, b);
         }
         else if (card.rank.Equals("S"))
         {
             addToList(SRank, SRank1, SRank2, SRank3, b);
         }
     }
 }
示例#3
0
        private void setCardData(CardStats cardStat)
        {
            var data = cardStat.card;

            thisCard                       = cardStat; //Have a local variable
            NameBlock.Text                 = data.GetNameType();
            NameBlock_Copy.Text            = data.GetNameType();
            CostBox.Text                   = data.GetCost().ToString();
            AttackBox.Text                 = data.GetDamage().ToString();
            HealthBox.Text                 = data.GetCost().ToString();
            HealthBox.Text                 = data.GetMaxHp().ToString();
            checkBox_Common_Copy.IsChecked = data.HasTaunt();
            checkBox_Rare_Copy.IsChecked   = data.HasCharge();

            if (data.GetRarity().Equals("common"))
            {
                checkBox_Common.IsChecked = true;
            }
            else if (data.GetRarity().Equals("rare"))
            {
                checkBox_Rare.IsChecked = true;
            }
            else
            {
                checkBox_Rare.IsChecked = true;
            }
            NameBlock_Copy1.Text = "  %";

            if (cont.rankCriteria != null)
            {
                var rank = cont.rankCriteria.evaluateCard(cardStat);
                cardStat.rank = rank;
            }

            textBlock_Copy6.Text = cardStat.rank; //RANK
            if (cardStat.win_ratio == -1)
            {
                textBlock_Copy6.Text  = "?"; //RANK
                textBlock_Copy10.Text = "UNKNOWN"; textBlock_Copy10.FontSize = 50;
                textBlock_Copy8.Text  = "UNKNOWN"; textBlock_Copy8.FontSize = 50;
            }
            else
            {
                textBlock_Copy10.Text = cardStat.win_ratio + " %"; //WIN-RATIO
                textBlock_Copy8.Text  = "" + cardStat.domminance;  //DOMMINANCE
            }

            cardStat.card = data;
            comboBoxWithCards.ItemsSource = gennereateCollection(cardStat);
            examineAllCards();
            if (!thisCard.note.Equals(""))
            {
                textBox_Copy.Text = thisCard.note;
            }
        }
示例#4
0
 public ContainerClass(Model mod, CardStats ca)
 {
     model                = mod;
     card                 = ca;
     simulated            = false;
     resultDecks          = null;
     rankCriteria         = null;
     simulationCriteria   = null;
     rankCriteriaReview   = false;
     chardHaveBeenChanged = false;
 }
示例#5
0
        private ObservableCollection <string> gennereateCollection(CardStats card)
        {
            var cards = cont.getModel().cardsToDisplay;
            ObservableCollection <string> list = new ObservableCollection <string>();
            string name;

            foreach (CardStats c in cards)
            {
                name = c.card.GetNameType();
                if (name.Equals(card.card.GetNameType()))
                {
                }
                else
                {
                    list.Add(name);
                }
            }

            return(list);
        }
示例#6
0
        public static SimulationResults runSimulation(ContainerClass container, SetupData setup)
        {
            foreach (var card in setup.Cardpool)
            {
                (card as ITrackable).Reset();
            }

            var Res = Simulator.RunSimulation(setup);

            //Get results back

            List <CardStats> ListWithCards = new List <CardStats>();

            //var winRatios = con.model.calculateWinRatio(ICards, Res.Decks);

            foreach (var card in Res.Cardpool)
            {
                var cardStats = new CardStats(card);

                //var wins = ((winRatios[card.GetNameType()])[0] * 1.0);
                //var fights = ((winRatios[card.GetNameType()])[1] * 1.0);
                var win_ratio = (card as ITrackable).GetWinLossRate(); //(wins / fights) * 100;//(card as ITrackable).GetWinLossRate();

                var win_ratio_int = Convert.ToInt32(win_ratio);

                cardStats.win_ratio = win_ratio_int;

                //cardStats.win_ratio = r.Next(0,100); //Random
                var dom = (card as ITrackable).GetDominance(card);

                cardStats.domminance = dom;
                cardStats.simulated  = true;
                cardStats.changed    = false;
                ListWithCards.Add(cardStats);
            }
            List <ICard> ICardsNOT = new List <ICard>();

            foreach (var card in container.getModel().cardsToDisplay)
            {
                if (!Res.Cardpool.Contains(card.card))
                {
                    ICardsNOT.Add(card.card);
                }
            }

            foreach (var card in ICardsNOT)
            {
                var cardStats = new CardStats(card);

                cardStats.win_ratio  = -1;
                cardStats.domminance = -1;
                cardStats.simulated  = false;
                cardStats.changed    = false;
                ListWithCards.Add(cardStats);
            }

            container.getModel().cardsToDisplay = ListWithCards;
            container.simulated = true;
            container.simulationCriteria.setup = setup;

            return(Res);
        }
示例#7
0
 public void setcard(CardStats newCard)
 {
     card = newCard;
 }
示例#8
0
            public string evaluateCard(CardStats card)
            {
                //RANK S
                if (ands[0])
                {
                    if (
                        ((winRatio_t[0] && winRatio[0] <= card.win_ratio) || !winRatio_t[0])
                        &&
                        ((domminance_t[0] && domminance[0] >= card.domminance) || !domminance_t[0])
                        )
                    {
                        return("S");
                    }
                }
                else if (
                    ((winRatio_t[0] && winRatio[0] <= card.win_ratio) || !winRatio_t[0])
                    ||
                    ((domminance_t[0] && domminance[0] >= card.domminance) || !domminance_t[0])
                    )
                {
                    return("S");
                }

                //RANK A
                if (ands[1])
                {
                    if (
                        ((winRatio_t[1] && winRatio[1] <= card.win_ratio) || !winRatio_t[1])
                        &&
                        ((domminance_t[1] && domminance[1] >= card.domminance) || !domminance_t[1])
                        )
                    {
                        return("A");
                    }
                }
                else if (
                    ((winRatio_t[1] && winRatio[1] <= card.win_ratio) || !winRatio_t[1])
                    ||
                    ((domminance_t[1] && domminance[1] >= card.domminance) || !domminance_t[1])
                    )
                {
                    return("A");
                }

                //RANK B
                if (ands[2])
                {
                    if (
                        ((winRatio_t[2] && winRatio[2] <= card.win_ratio) || !winRatio_t[2])
                        &&
                        ((domminance_t[2] && domminance[2] >= card.domminance) || !domminance_t[2])
                        )
                    {
                        return("B");
                    }
                }
                else if (
                    ((winRatio_t[2] && winRatio[2] <= card.win_ratio) || !winRatio_t[2])
                    ||
                    ((domminance_t[2] && domminance[2] >= card.domminance) || !domminance_t[2])
                    )
                {
                    return("B");
                }

                //RANK C
                if (ands[3])
                {
                    if (
                        ((winRatio_t[3] && winRatio[3] <= card.win_ratio) || !winRatio_t[3])
                        &&
                        ((domminance_t[3] && domminance[3] >= card.domminance) || !domminance_t[3])
                        )
                    {
                        return("C");
                    }
                }
                else if (
                    ((winRatio_t[3] && winRatio[3] <= card.win_ratio) || !winRatio_t[3])
                    ||
                    ((domminance_t[3] && domminance[3] >= card.domminance) || !domminance_t[3])
                    )
                {
                    return("C");
                }

                //RANK F
                if (ands[4])
                {
                    if (
                        ((winRatio_t[4] && winRatio[4] <= card.win_ratio) || !winRatio_t[4])
                        &&
                        ((domminance_t[4] && domminance[4] >= card.domminance) || !domminance_t[4])
                        )
                    {
                        return("F");
                    }
                }
                else if (
                    ((winRatio_t[4] && winRatio[4] <= card.win_ratio) || !winRatio_t[4])
                    ||
                    ((domminance_t[4] && domminance[4] >= card.domminance) || !domminance_t[4])
                    )
                {
                    return("F");
                }

                return("F");
            }
示例#9
0
        private object[] calculateWinRatio(HashSet <Deck> decksToExamine, CardStats card)
        {
            int fights = 0;
            int wins   = 0;

            foreach (var deck in decksToExamine)
            {
                var re = deck.results;
                foreach (var res in re)
                {
                    if (res.winnerDeck == deck)
                    {
                        if (res.winner.Equals("P2"))
                        {
                            if (res.p2CardPlaySequence.Contains(card.card) && res.p2CardPlaySequence.Contains(thisCard.card))
                            {
                                wins++;
                                fights++;
                            }
                        }
                        else
                        {
                            if (res.p1CardPlaySequence.Contains(card.card) && res.p1CardPlaySequence.Contains(thisCard.card))
                            {
                                wins++;
                                fights++;
                            }
                        }
                    }
                    else
                    {
                        if (res.loser.Equals("P2"))
                        {
                            if (res.p2CardPlaySequence.Contains(card.card) && res.p2CardPlaySequence.Contains(thisCard.card))
                            {
                                //wins++;
                                fights++;
                            }
                        }
                        else
                        {
                            if (res.p1CardPlaySequence.Contains(card.card) && res.p1CardPlaySequence.Contains(thisCard.card))
                            {
                                //wins++;
                                fights++;
                            }
                        }
                    }
                }
            }

            var winRatioWithOtherCard = 1.0;

            if (wins == 0 && fights == 0)
            {
                //NameBlock_Copy1.Text = "Never got to play together";
                winRatioWithOtherCard = -1.0;
            }
            else if (wins == 0)
            {
                //NameBlock_Copy1.Text = "won " + 0 + " %" + Environment.NewLine + "Based on " + fights + " fights";
                winRatioWithOtherCard = 0.0;
            }
            else
            {
                winRatioWithOtherCard = Math.Round((1.0 * wins) / (1.0 * fights) * 100.0, 2);

                //NameBlock_Copy1.Text = "won " + winRatioWithOtherCard + " %" + Environment.NewLine + "Based on " + fights + " fights";
            }

            return(new object[] { fights, wins, winRatioWithOtherCard });
        }