/// <summary>
        /// gets a list of spells for the choice of a given eldritch invocation
        /// </summary>
        /// <param name="invocation">selected eldritch invocation</param>
        public List <Spell> getInvocationSpellOptions(EldritchInvocation invocation)
        {
            List <Spell> spellList = new List <Spell>();

            if (invocation.Name == "Book of Ancient Secrets")
            {
                using (SQLiteConnection connection = new SQLiteConnection(ConnectionString))
                    using (SQLiteCommand command = new SQLiteCommand(connection))
                    {
                        connection.Open();
                        command.CommandText = "SELECT name, ritual, level, school, castTime, range, duration, components, materials, description FROM spells " +
                                              "INNER JOIN books ON books.bookid=spells.book " +
                                              "WHERE level = 1 AND ritual = 1 " +
                                              "AND books.title IN (@UsedBooks)";
                        SQLiteCommandExtensions.AddParametersWithValues(command, "@UsedBooks", UsedBooks);

                        using (SQLiteDataReader dbReader = command.ExecuteReader())
                        {
                            while (dbReader.Read())
                            {
                                if (!dbReader.IsDBNull(0))
                                {
                                    spellList.Add(new Spell(dbReader.GetString(0), dbReader.GetBoolean(1), dbReader.GetInt32(2), dbReader.GetString(3), dbReader.GetString(4), dbReader.GetString(5), dbReader.GetString(6), dbReader.GetString(6), dbReader.GetString(8), dbReader.GetString(9), false));
                                }
                            }
                        }
                    }
            }

            return(spellList);
        }
        /// <summary>
        /// gets a list of skills the invocation gains
        /// </summary>
        /// <param name="invocation">chosen invocation</param>
        public List <string> getInvocationGainedSkills(EldritchInvocation invocation)
        {
            List <string> gainedSkills = new List <string>();

            using (SQLiteConnection connection = new SQLiteConnection(ConnectionString))
                using (SQLiteCommand command = new SQLiteCommand(connection))
                {
                    connection.Open();
                    command.CommandText = "SELECT skills.name FROM eldritchInvocations " +
                                          "INNER JOIN eldritchInvocationsGainedSkills ON eldritchInvocationsGainedSkills.invocationId = eldritchInvocations.invocationId " +
                                          "INNER JOIN skills ON skills.skillId = eldritchInvocationsGainedSkills.skillId " +
                                          "WHERE eldritchInvocations.name = @Invocation";
                    command.Parameters.AddWithValue("@Invocation", invocation.Name);

                    using (SQLiteDataReader dbReader = command.ExecuteReader())
                    {
                        while (dbReader.Read())
                        {
                            if (!dbReader.IsDBNull(0))
                            {
                                gainedSkills.Add(dbReader.GetString(0));
                            }
                        }
                    }
                }

            return(gainedSkills);
        }
Ejemplo n.º 3
0
        private void invocationListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            syncInvocationSelectionOrder();
            if (invocationListBox.SelectedItems.Count > 0)
            {
                if (invocationListBox.SelectedIndices.Count <= invocationsKnown)
                {
                    int lastSelectedIndex = invocationOrderedSelection.ElementAt(invocationOrderedSelection.Count - 1);
                    EldritchInvocation currentInvocation = (EldritchInvocation)invocationListBox.Items[lastSelectedIndex];
                    if (currentInvocation != null)
                    {
                        invocationDescriptionLabel.Text = currentInvocation.Description;

                        toggleInvocationSpellSelection();
                    }
                }
                else
                {
                    int lastSelectedIndex = invocationOrderedSelection.ElementAt(invocationOrderedSelection.Count - 1);
                    invocationListBox.SelectedIndices.Remove(lastSelectedIndex);
                }

                OnInvocationChosen(null);
            }
        }
        /// <summary>
        /// gets the number of invocation spells a given invocation grants
        /// </summary>
        /// <param name="invocation">selected invocation</param>
        public int invocationSpellChoiceAmount(EldritchInvocation invocation)
        {
            if (invocation.Name == "Book of Ancient Secrets")
            {
                return(2);
            }

            return(0);
        }
Ejemplo n.º 5
0
        private void toggleInvocationSpellSelection()
        {
            bool activateSpellSelection = false;

            int spellChoiceInvocationIndex = 0;

            foreach (EldritchInvocation invocation in invocationListBox.SelectedItems)
            {
                if (invocation != null)
                {
                    if (invocation.HasSpellChoice)
                    {
                        activateSpellSelection     = true;
                        spellChoiceInvocationIndex = invocationListBox.Items.IndexOf(invocation);
                        break;
                    }
                }
            }

            if (activateSpellSelection)
            {
                EldritchInvocation spellChoiceInvocation = (EldritchInvocation)invocationListBox.Items[spellChoiceInvocationIndex];
                invocationSpellsKnown = wm.DBManager.ExtraClassChoiceData.WarlockChoiceData.invocationSpellChoiceAmount(spellChoiceInvocation);

                invocationLayout.Size         = new Size(425, invocationLayout.Size.Height);
                invocationSpellLayout.Visible = true;

                invocationSpellIntroLabel.Text = $"Choose {invocationSpellsKnown} spell(s):";
                if (invocationSpellsKnown > 1)
                {
                    invocationSpellListBox.SelectionMode = SelectionMode.MultiSimple;
                }
                else
                {
                    invocationSpellListBox.SelectionMode = SelectionMode.One;
                }

                refreshInvocationSpellList(spellChoiceInvocation);
            }
            else
            {
                invocationLayout.Size         = new Size(843, invocationLayout.Size.Height);
                invocationSpellLayout.Visible = false;
            }
        }
Ejemplo n.º 6
0
        private void refreshInvocationSpellList(EldritchInvocation selectedInvocation)
        {
            invocationSpellSource = wm.DBManager.ExtraClassChoiceData.WarlockChoiceData.getInvocationSpellOptions(selectedInvocation);

            //remove already chosen spells
            foreach (Spell spell in wm.Choices.Spells)
            {
                invocationSpellSource.Remove(spell);
            }

            foreach (Spell spell in wm.Choices.RaceSpells)
            {
                if (!string.IsNullOrEmpty(spell.Name))
                {
                    invocationSpellSource.Remove(spell);
                }
            }

            invocationSpellListBox.BeginUpdate();
            invocationSpellListBox.DataSource    = null;
            invocationSpellListBox.DataSource    = invocationSpellSource;
            invocationSpellListBox.DisplayMember = "Name";
            invocationSpellListBox.EndUpdate();
        }
 /// <summary>
 /// checks, if a given eldritch invocation includes a spell choice
 /// </summary>
 /// <param name="invocation">selected eldritch invocation</param>
 public bool hasInvocationSpellChoice(EldritchInvocation invocation)
 {
     return(invocation.Name == "Book of Ancient Secrets");
 }