Esempio n. 1
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);
        }
Esempio n. 2
0
        static internal void ShowAddedBoostersDialog(int boosters, BoosterLeaguePool pool)
        {
            NewBoostersForLeagueDialog dialog = new NewBoostersForLeagueDialog();

            dialog.Text = "Added skills from " + boosters.ToString() + " booster packs!";
            dialog.__Pool.SetPool(pool);
            dialog.ShowDialog();
        }
Esempio n. 3
0
        private void __OpenBoosterLeagueDialog_FileOk(object sender, CancelEventArgs e)
        {
            string            filename     = __OpenBoosterLeagueDialog.FileName;
            BoosterLeaguePool openedLeague = BoosterLeaguePool.ReadFromFile(filename);

            if (openedLeague != null)
            {
                __SaveBoosterLeagueDialog.FileName = filename;
                League = openedLeague;
                __LeaguePoolDisplay.SetPool(League);
            }
        }
Esempio n. 4
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);
        }
        public static BoosterLeaguePool ReadFromFile(string filename)
        {
            System.IO.StreamReader input = new System.IO.StreamReader(filename);

            input.ReadLine(); // Toss; instruction line.
            List <Pair <int, int> > pool = new List <Pair <int, int> >();

            // Read the pool using a now extremely familiar format:
            while (input.EndOfStream == false)
            {
                string   linecopy = input.ReadLine();
                string[] line     = linecopy.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                if (line.Length < 2)
                {
                    System.Windows.Forms.MessageBox.Show("Warning: Malformed line \"" + linecopy + "\".", "Malformed Line", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);
                }

                int id       = -1;
                int quantity = -1;
                try
                {
                    id       = Convert.ToInt32(line[0]);
                    quantity = Convert.ToInt32(line[1]);
                }
                catch (Exception e)
                {
                    System.Windows.Forms.MessageBox.Show("Warning: Malformed line \"" + linecopy + "\"" + Environment.NewLine + Environment.NewLine + "Error message: " + e.Message, "Malformed Line", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);
                    continue;
                }

                pool.Add(new Pair <int, int>(id, quantity));
            }

            input.Close();

            // Make a booster league and assign the pool!
            BoosterLeaguePool league = new BoosterLeaguePool();

            league.Pool = pool;
            return(league);
        }
 internal void SetPool(BoosterLeaguePool pool)
 {
     Skills = pool;
     Redraw();
 }