Пример #1
0
        private void startDraftRoundToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // In case someone tries to do a draft without creating a new one... (Note: Need to do it here because of loading order among controls!)
            if (Draft == null)
            {
                Draft = TemplateDraft.Create();
            }

            // Turn off the ability to change the party size while the draft round is going on:
            startDraftRoundToolStripMenuItem.Enabled = setPartySizeToolStripMenuItem.Enabled = __PartySize4.Enabled = __PartySize6.Enabled = __PartySize8.Enabled = false;
            Draft.StartDraftRound(SavedFromPoolFirst, SavedFromPoolSecond);

            // Add code to re-add the saved items...
            List <string> savedTemplates = Draft.GetPool();

            __PoolContainer.Controls.Clear();
            PoolButtons.Clear();
            PoolTemplates.Clear();
            SavedFromPoolFirst  = -1;
            SavedFromPoolSecond = -1;
            DraftHandCount      = 0;
            for (int i = 0; i < savedTemplates.Count; ++i)
            {
                AddTemplateToPool(savedTemplates[i], i);
            }

            // Now, let's draft a hand, shall we?
            DisplayDraftHand(Draft.DealDraftHand(DraftHandSize));
        }
Пример #2
0
        void LoadDraft(string filename)
        {
            BinaryReader input    = new BinaryReader(File.OpenRead(filename));
            int          version  = input.ReadInt32(); // Needed for if a new version needs to happen. ALWAYS include a version number! It'll save headaches in the future if needed!
            int          handsize = input.ReadInt32(); // Don't care about this right now...here for ease of backwards compatibility in a theoretical future.

            // OK, let's clear some stuff out:
            __PoolContainer.Controls.Clear();
            PoolTemplates.Clear();
            PoolButtons.Clear();
            __DraftHandContainer.Controls.Clear();
            DraftHandButtons.Clear();
            DraftHandTemplates.Clear();
            startDraftRoundToolStripMenuItem.Enabled = setPartySizeToolStripMenuItem.Enabled = __PartySize4.Enabled = __PartySize6.Enabled = __PartySize8.Enabled = true;

            // Now, let's load the draft:
            Draft = TemplateDraft.Read(input);

            // Now, load in these values:
            bool MidDraft = input.ReadBoolean();

            // And load in the tracking values:
            PartySize           = input.ReadInt32();
            DraftHandCount      = input.ReadInt32();
            SavedFromPoolFirst  = input.ReadInt32();
            SavedFromPoolSecond = input.ReadInt32();

            // OK, we've loaded everything, so we can close the stream:
            input.Close();

            // Now we need to set up the UI according to how things were when it was saved!

            // First, let's set the party size on the UI:
            __PartySize4.Checked = PartySize == 4;
            __PartySize6.Checked = PartySize == 6;
            __PartySize8.Checked = PartySize == 8;

            // Next, let's load in the pool:
            List <string> pool = Draft.GetPool();

            for (int i = 0; i < pool.Count; ++i)
            {
                AddTemplateToPool(pool[i], i);
            }

            // Let's set up "save" values:
            if (SavedFromPoolFirst >= 0)
            {
                PoolButtons[SavedFromPoolFirst].Text      = "Saved";
                PoolButtons[SavedFromPoolFirst].BackColor = SystemColors.Highlight;
            }
            if (SavedFromPoolSecond >= 0)
            {
                PoolButtons[SavedFromPoolSecond].Text      = "Saved";
                PoolButtons[SavedFromPoolSecond].BackColor = SystemColors.Highlight;
            }

            // If both slots are full, disable the non-saving buttons:
            if (SavedFromPoolFirst >= 0 && SavedFromPoolSecond >= 0)
            {
                foreach (Control c in PoolButtons)
                {
                    // Enable the highlighted ones and disable the rest:
                    c.Enabled = c.BackColor == SystemColors.Highlight;
                }
            }
            else
            {
                foreach (Control c in PoolButtons)
                {
                    c.Enabled = true;
                }
            }

            // Now, let's set up the draft if we're in the middle of it!
            if (MidDraft)
            {
                startDraftRoundToolStripMenuItem.Enabled = setPartySizeToolStripMenuItem.Enabled = __PartySize4.Enabled = __PartySize6.Enabled = __PartySize8.Enabled = false;
                DisplayDraftHand(Draft.GetDraftHand());
            }
            else // Not drafting? Gotta show those save buttons!
            {
                foreach (Control c in PoolButtons)
                {
                    c.Visible = true;
                }
            }

            MessageBox.Show("Finished loading Template Draft using deck \"" + Draft.GetDeckName() + "\".", "Operation Complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }