예제 #1
0
        private void newToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Start a Template Draft using the currently loaded deck, \"" + SkillDatabase.TemplateDeckName + "\"?" + Environment.NewLine + Environment.NewLine + "This draft will always use this deck, even if you change it later. Decks can be selected in Settings tab. It will also override the current draft, if one is ongoing. Make sure to save it first if you wish to continue it later!", "Start Draft?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                // Start a new actual draft:


                Draft = TemplateDraft.Create();

                // Clear the contents of the old draft:
                __PoolContainer.Controls.Clear();
                PoolTemplates.Clear();
                PoolButtons.Clear();
                __DraftHandContainer.Controls.Clear();
                DraftHandButtons.Clear();
                DraftHandTemplates.Clear();

                // Reset draft control values:
                DraftHandCount     = 0;
                SavedFromPoolFirst = SavedFromPoolSecond = -1;

                // Re-enable some controls if in the middle of a draft round (where they get turned off):
                startDraftRoundToolStripMenuItem.Enabled = setPartySizeToolStripMenuItem.Enabled = __PartySize4.Enabled = __PartySize6.Enabled = __PartySize8.Enabled = true;

                // Note: Not touching party size here, as that's connected to an entirely separate thing!
            }
        }
예제 #2
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));
        }
예제 #3
0
        static public TemplateDraft Read(BinaryReader input)
        {
            TemplateDraft td = new TemplateDraft();

            td._DeckName = input.ReadString();

            // Templates:
            int count = input.ReadInt32();

            for (int i = 0; i < count; ++i)
            {
                td._Templates.Add(input.ReadString());
            }

            // Just like above, we need to read in all of these lists:

            // The deck:
            count = input.ReadInt32();
            for (int i = 0; i < count; ++i)
            {
                td._Deck.Add(input.ReadInt32());
            }

            // Trashed:
            count = input.ReadInt32();
            for (int i = 0; i < count; ++i)
            {
                td._Trashed.Add(input.ReadInt32());
            }

            // Pool:
            count = input.ReadInt32();
            for (int i = 0; i < count; ++i)
            {
                td._Pool.Add(input.ReadInt32());
            }

            // Rejecteds:
            count = input.ReadInt32();
            for (int i = 0; i < count; ++i)
            {
                td._Rejecteds.Add(input.ReadInt32());
            }

            // Draft Hand:
            count = input.ReadInt32();
            for (int i = 0; i < count; ++i)
            {
                td._DraftHand.Add(input.ReadInt32());
            }

            // Now that we've loaded everything into it, we can return it:
            return(td);
        }
예제 #4
0
        static public TemplateDraft Create()
        {
            TemplateDraft td = new TemplateDraft();

            // Create the new Template Draft using the templates and name of the currently loaded deck:
            td._DeckName  = SkillDatabase.TemplateDeckName;
            td._Templates = new List <string>(SkillDatabase.TemplateDeck); // Make a copy of the deck for the draft, however!

            // Now set everything up:
            td.Reset();

            // Hand it over:
            return(td);
        }
예제 #5
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);
        }