コード例 #1
0
 public void AddPack(SkillBoosterPack pack)
 {
     foreach (int skillId in pack.Contents)
     {
         AddSkill(skillId);
     }
 }
コード例 #2
0
        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);
        }
コード例 #3
0
        private void __Button_AddBoosters_Click(object sender, EventArgs e)
        {
            // Add boosters to league:
            List <SkillBoosterPack> boosters = SkillBoosterPack.GenerateBoosterBox(__SelectedSet.SelectedIndex < 0 ? 0 : __SelectedSet.SelectedIndex, (int)__NumberOfBoostersToAdd.Value);
            // Temporary league to hold the added skills for display purposes...
            BoosterLeaguePool newBoosters = new BoosterLeaguePool();

            newBoosters.AddBox(boosters);
            newBoosters.SortByProfessionAttribute();
            newBoosters.SortByRarity();
            League.AddBox(boosters);
            // Redraw the pool...
            __LeaguePoolDisplay.Redraw();
            // Show a dialog containing the new skills:
            NewBoostersForLeagueDialog.ShowAddedBoostersDialog((int)__NumberOfBoostersToAdd.Value, newBoosters);
        }