/*
         * Maybe consider adding finer controls, such as allowing the specification of certain attributes/professions, or even
         * listing a select set of skills included!
         */
        static public void LoadSets()
        {
            // Make the default set.
            SkillBoosterSet defaultset = new SkillBoosterSet();

            foreach (Skill skill in SkillDatabase.Data)
            {
                if (skill.Attribute != Skill.Attributes.PvE_Only)
                {
                    defaultset.SetSkills.Add(skill.ID);
                }
            }
            Sets.Add(defaultset);

            // Load any other sets:
            if (System.IO.Directory.Exists(Environment.CurrentDirectory + "\\GW Codex Skill Sets"))
            {
                string[] setFiles = System.IO.Directory.GetFiles(Environment.CurrentDirectory + "\\GW Codex Skill Sets", "*.gwset");
                foreach (string file in setFiles)
                {
                    SkillBoosterSet set = Read(file);
                    if (set != null)
                    {
                        Sets.Add(set);
                    }
                }
            }
        }
Exemple #2
0
        private void __AddCardsButton_Click(object sender, EventArgs e)
        {
            // Convert the set to a pool of skills:
            List <Skill>    pool = new List <Skill>();
            SkillBoosterSet set  = SkillBoosterSet.Sets[__SelectedSet.SelectedIndex < 0 ? 0 : __SelectedSet.SelectedIndex];

            foreach (int i in set.SetSkills)
            {
                pool.Add(SkillDatabase.Data[i]);
            }

            // Pool is now added to a grab bag:
            GrabBag bag = new GrabBag(pool);

            // Now I need to grab some number of skills and add 'em to the league!
            BoosterLeaguePool newBooster = new BoosterLeaguePool();

            foreach (Skill skill in bag.PullXFromBag((int)__NumberOfBoostersToAdd.Value))
            {
                League.AddSkill(skill);
                newBooster.AddSkill(skill);
            }

            // And redraw the league pool:
            __LeaguePoolDisplay.Redraw();

            // Let's show the player what they got!
            NewBoostersForLeagueDialog.ShowAddedBoostersDialog(1, newBooster);
        }
        static public SkillBoosterSet Read(string filename)
        {
            System.IO.StreamReader input = new System.IO.StreamReader(filename);
            SkillBoosterSet        set   = new SkillBoosterSet();

            input.ReadLine(); // Instruction line, undeeded.

            // Read name:
            set.Name = input.ReadLine();

            // Read rarity counts:
            string linecopy = input.ReadLine();

            string[]   raritycontents            = linecopy.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
            List <int> translated_raritycontents = new List <int>();

            foreach (string str in raritycontents)
            {
                try
                {
                    translated_raritycontents.Add(Convert.ToInt32(str));
                }
                catch (Exception e)
                {
                    System.Windows.Forms.MessageBox.Show("Warning: Malformed number \"" + str + "\" in line \"" + linecopy + "\" in Skill Set file: " + filename + Environment.NewLine + Environment.NewLine + "Error message: " + e.Message, "Malformed Line", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);
                }
            }

            set.PackRarityContents = translated_raritycontents.ToArray();

            // Read included skills:
            while (input.EndOfStream == false)
            {
                string line = input.ReadLine();
                int    id   = -1;
                try
                {
                    id = Convert.ToInt32(line);
                }
                catch (Exception e)
                {
                    System.Windows.Forms.MessageBox.Show("Warning: Malformed line \"" + line + "\" in Skill Set file: " + filename + Environment.NewLine + Environment.NewLine + "Error message: " + e.Message, "Malformed Line", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);
                }

                if (id < 0 || id >= SkillDatabase.Data.Count)
                {
                    System.Windows.Forms.MessageBox.Show("Warning: Internal skill ID \"" + id.ToString() + "\" is out of bounds in Skill Set file: " + filename);
                }
                else
                {
                    set.SetSkills.Add(id);
                }
            }

            input.Close();

            return(set);
        }
Exemple #4
0
 internal void SetFromSet(SkillBoosterSet set)
 {
     // I can't help but internally scream at how inefficient this is, but the only "better" idea I have is to
     //  sort all of the skills by ID, set them all to false (instead of the default on), turn them on by indexing in via the ID,
     //  then sort them by Standard method again. I can't even tell if that feels better or not than doing this...
     for (int i = 0; i < Skills.Count; ++i)
     {
         Skills[i].second = set.SetSkills.Contains(Skills[i].first.ID);
     }
     Redraw();
 }
        static private SkillBoosterPack GeneratePackFromSetPool(int setId, List <int>[] skills_per_rarity)
        {
            // figure out what the pool looks like...
            // First, I need to generate a copy of the pool so I can draw from it properly:
            List <int>[] clone_pool = new List <int> [skills_per_rarity.Length];
            for (int i = 0; i < clone_pool.Length; ++i)
            {
                clone_pool[i] = new List <int>(skills_per_rarity[i]);
            }

            // Let's set up the pack and retrieve the set:
            SkillBoosterPack pack = new SkillBoosterPack();
            SkillBoosterSet  set  = SkillBoosterSet.Sets[setId];

            // Iterate over each rarity, generating a number of cards equal to the required number. I meant skills, not cards, by the way.
            for (int rarity = 0; rarity < set.PackRarityContents.Length; ++rarity)
            {
                for (int i = 0; i < set.PackRarityContents[rarity]; ++i)
                {
                    // Do a safety check:
                    //  This check verifies there are still skills available at the given rarity. If not,
                    //  it'll check the lower rarities, then the higher ones. If no skills are found, it just returns the pack.
                    int pullRarity = rarity;
                    int searchDir  = -1;
                    while (clone_pool[pullRarity].Count <= 0)
                    {
                        // Search down...
                        pullRarity += searchDir;
                        // If we exhaust down, move up:
                        if (pullRarity < 0)
                        {
                            searchDir  = 1;
                            pullRarity = 0;
                        }
                        // If we move up beyond the end of available rarities, just return the pack as-is:
                        if (pullRarity >= set.PackRarityContents.Length)
                        {
                            return(pack);
                        }
                    }

                    // Grab a random item and add it to the pack, then remove it from the pool so I can't get duplicates:
                    int index = SkillDatabase.RNG.Next(clone_pool[pullRarity].Count);
                    pack.Contents.Add(clone_pool[pullRarity][index]);
                    clone_pool[pullRarity].RemoveAt(index);
                }
            }

            // Now that I've filled up the pack, I can turn it in!
            return(pack);
        }
        static private List <int>[] GenerateSkillsPerRarityFromSet(int set_index)
        {
            // Create the lists:
            List <int>[] skills_per_rarity = new List <int> [SkillDatabase.RarityLabels.Length];
            for (int i = 0; i < skills_per_rarity.Length; ++i)
            {
                skills_per_rarity[i] = new List <int>();
            }

            SkillBoosterSet set = SkillBoosterSet.Sets[set_index]; // Gotta grab this!

            // Do some stuff!
            foreach (int i in set.SetSkills)
            {
                // But, like, actually do the thing!
                // At this point, skills have been excluded based on what campaigns are allowed and whether or not PvE only skills are included.
                // That leaves the ratings filter.
                skills_per_rarity[SkillDatabase.Data[i].Rarity].Add(i);
            }

            return(skills_per_rarity);
        }
        internal SkillSetEditor(SkillBoosterSet set)
        {
            InitializeComponent();
            // Attributes
            __Deselect_AttributeList.SelectedIndex = 0;
            __Select_AttributeList.SelectedIndex   = 0;
            // Professions
            __Deselect_ProfessionList.SelectedIndex = 0;
            __Select_ProfessionList.SelectedIndex   = 0;
            // Ratings
            int maximum_rating = 5;

            for (int i = 1; i <= maximum_rating; ++i)
            {
                __Deselect_RatingList.Items.Add(i.ToString());
                __Select_RatingsList.Items.Add(i.ToString());
            }
            __Deselect_RatingList.SelectedIndex = 0;
            __Select_RatingsList.SelectedIndex  = 0;

            // Set up some functionalities!
            __SkillSetDisplay.DescriptionBox       = __SkillInfoDisplay;
            __SkillSetDisplay.UpdateSetDescription = UpdateSetDescription;

            // Set information for a set being edited, I guess? Seems like a good idea!
            if (set == null)
            {
                CurrentSet     = new SkillBoosterSet();
                __SetName.Text = set.Name;
            }
            else
            {
                CurrentSet = set;
                __SkillSetDisplay.SetFromSet(set);
                __SetName.Text = set.Name;
            }
            UpdateSetDescription();
            __RarityDistribution.RowCount = SkillDatabase.RarityLabels.Length;
            // Set the height to make sure this is compact!
            for (int i = 0; i < __RarityDistribution.RowStyles.Count; ++i)
            {
                __RarityDistribution.RowStyles[i].Height = 22; // Just hardcoding this here....
            }

            // Hardcoding some widths to try and make the horizontal scrollbar not show up...
            __RarityDistribution.ColumnStyles[0].SizeType = SizeType.Absolute;
            __RarityDistribution.ColumnStyles[1].SizeType = SizeType.Absolute;
            __RarityDistribution.ColumnStyles[0].Width    = 90;
            __RarityDistribution.ColumnStyles[1].Width    = 65;

            // Now, place the rarity distribution controls into the table:
            for (int i = 0; i < SkillDatabase.RarityLabels.Length; ++i)
            {
                // Label for the rarity:
                Label rarity_label = new Label();
                rarity_label.Size      = new Size(90, 20);
                rarity_label.TextAlign = ContentAlignment.MiddleRight;
                rarity_label.Text      = SkillDatabase.RarityLabels[i];
                __RarityDistribution.Controls.Add(rarity_label, 0, i);

                // Numeric update for the quantity:
                NumericUpDown nud = new NumericUpDown();
                nud.Width = 60;
                if (i < CurrentSet.PackRarityContents.Length)
                {
                    nud.Value = CurrentSet.PackRarityContents[i];
                }
                __RarityDistribution.Controls.Add(nud, 1, i);
                RarityDistributionControls.Add(nud);
            }
        }