Beispiel #1
0
        private void AddSpellToDataTable(DataTable data, RPGSpell s)
        {
            #region Build Row Data
            string realm = Enum.GetName(typeof(SpellRealm), s.Realm);
            string range = Enum.GetName(typeof(RPGEffect.EffectRange), s.Effect.Range);

            bool   bIsBuff = s.Effect.EffectIsABuff;
            string isBuff  = "Attack";
            string effect  = s.GetShortEffectDescription();
            string pwr     = "" + s.Effect.MinPower + " - " + s.Effect.MaxPower;
            string cost    = s.Cost.ToString();

            string duration = s.Effect.GetDurationAsString();
            if (s.Effect.DurationEffectType == RPGEffect.DurationType.Permanent)
            {
                duration = "Once";
            }

            #endregion

            #region Assign vars to new row
            DataRow newRow = data.NewRow();
            newRow["Realm"]    = realm;
            newRow["type"]     = isBuff;
            newRow["Range"]    = range;
            newRow["Effect"]   = effect;
            newRow["Power"]    = pwr;
            newRow["Cost"]     = cost;
            newRow["Duration"] = duration;
            #endregion

            data.Rows.Add(newRow);
        }
        private void LoadQuickSpell(int i, RPGSpell spell)
        {
            switch (i)
            {
            case (0):
            {
                btnSpell1.loadSpell(spell);
                break;
            }

            case (1):
            {
                btnSpell2.loadSpell(spell);
                break;
            }

            case (2):
            {
                btnSpell3.loadSpell(spell);
                break;
            }

            default:
            {
                break;
            }
            }
        }
Beispiel #3
0
        public static RPGSpell CreateRandomSpell()
        {
            RPGSpell spell = new RPGSpell();

            spell.Stage  = SpellStage.Dormant;
            spell.Effect = RPGEffect.CreateRandomSpellEffect();
            spell.Realm  = new RPGCalc().RandomSpellRealm();
            return(spell);
        }
Beispiel #4
0
        public void ClearSpell()
        {
            if (m_Spell != null)
            {
                m_Spell = null;
            }
            ButtonText = "-";
            this.BText = new SolidBrush(TEXT_COLOR);
            IsSelected = false;

            this.Refresh();
        }
Beispiel #5
0
 public void loadSpell(RPGSpell spell)
 {
     if (spell != null)
     {
         ButtonText = spell.GetShortEffectDescription();
         this.BText = new SolidBrush(spell.SpellColor);
         this.Refresh();
     }
     else
     {
         ClearSpell();
     }
 }
Beispiel #6
0
        public bool RemoveSpell(RPGSpell s)
        {
            int slot = FindSpell(s);

            if (slot > -1)
            {
                Spells[slot] = null;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #7
0
        public bool AddSpell(RPGSpell s)
        {
            int slot = GetOpenSpellSlot();

            if (slot > -1)
            {
                Spells[slot] = s;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #8
0
        public static RPGSpellBook CreateTestSpellbook()
        {
            RPGCalc      calc = new RPGCalc();
            int          size = DEFAULT_MAX_SPELL_COUNT * 2;
            RPGSpellBook book = new RPGSpellBook(size);

            int count = size;

            for (int i = 0; i < count; i++)
            {
                book.AddSpell(RPGSpell.CreateRandomSpell());
            }

            return(book);
        }
Beispiel #9
0
        private int FindSpell(RPGSpell s)
        {
            for (int i = 0; i < Spells.Length; i++)
            {
                if (Spells[i] == null)
                {
                    continue;
                }

                if (Spells[i].Realm == s.Realm &&
                    Spells[i].Effect.GetDescriptionFull() == s.Effect.GetDescriptionFull())
                {
                    return(i);
                }
            }

            return(-1);
        }
Beispiel #10
0
        private void AddSelectedSpellsToQuickSpellBook()
        {
            // if there are no spells selected, notify and return
            if (dataGridView1.SelectedRows.Count < 1)
            {
                string msg = "Select spells from your book to add them to the quick slots.";
                MessageBox.Show(msg, "No spells selected", MessageBoxButtons.OK);
                return;
            }

            // for each spell - add if selected
            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                // skip if not selected
                if (!dataGridView1.Rows[i].Selected)
                {
                    continue;
                }

                // skip if row is blank
                DataGridViewRow thisRow = dataGridView1.Rows[i];
                if (thisRow.Cells[0].Value.ToString().Length < 1)
                {
                    continue;
                }

                // use index to fing correct spell
                RPGSpell thisSpell = thisActor.SpellBook.GetSpellAtIndex(i);

                // find an open slot
                bool worked = thisActor.QuickSpellBook.AddSpell(thisSpell);

                if (!worked)
                {
                    // nofity and return
                    string msg2 = "Spell could not be added.";
                    MessageBox.Show(msg2, "Add failed", MessageBoxButtons.OK);
                }
            }

            // reload the quick spell book grid
            LoadSpellBookIntoGrid(this.dataGridView2, thisActor.QuickSpellBook);
        }
Beispiel #11
0
        private void LoadSpellBookIntoGrid(DataGridView grid, RPGSpellBook book)
        {
            DataTable data = SetupSpellDataTable();

            for (int i = 0; i < book.SpellCountMax; i++)
            {
                RPGSpell s = book.GetSpellAtIndex(i);

                // if we don't have a spell, just add a blank row
                if (s == null)
                {
                    data.Rows.Add(data.NewRow());
                    continue;
                }

                AddSpellToDataTable(data, s);
            }

            grid.DataSource = data;
        }
Beispiel #12
0
        private void RemoveSelectedQuickSpellsFromQuickBook()
        {
            // if there are no spells selected, notify and return
            if (dataGridView2.SelectedRows.Count < 1)
            {
                string msg = "Select spells from your quick slots to remove them.";
                MessageBox.Show(msg, "No spells selected", MessageBoxButtons.OK);
                return;
            }

            // for each selected quick spell
            for (int i = 0; i < dataGridView2.Rows.Count; i++)
            {
                // skip if not selected
                if (!dataGridView2.Rows[i].Selected)
                {
                    continue;
                }

                // skip if row is blank
                DataGridViewRow thisRow = dataGridView2.Rows[i];
                if (thisRow.Cells[0].Value.ToString().Length < 1)
                {
                    continue;
                }

                // use index to fing correct spell
                RPGSpell thisSpell = thisActor.QuickSpellBook.GetSpellAtIndex(i);

                // remove it from the actor's quick book
                thisActor.QuickSpellBook.RemoveSpell(thisSpell);
            } // end for loop

            // reload the quick spell book grid
            LoadSpellBookIntoGrid(this.dataGridView2, thisActor.QuickSpellBook);
        }