/// <summary>
        /// Add CharacterClass to wrapper cache/list - Does not commit addition - Run saveCacheChanges() to do this
        /// </summary>
        /// <param name="tmpNewClass"></param>
        public void addClassToTempCache(CharacterClass tmpNewClass)
        {
            int index = -1;
            foreach (CharacterClass tmpClass in _listOfClasses)
            {
                if (tmpClass.ClassID == tmpNewClass.ClassID)
                {
                    index = _listOfClasses.IndexOf(tmpClass);
                }
            }

            if (index != -1)
            {
                _listOfClasses[index] = tmpNewClass;
            }
            else
            {
                _listOfClasses.Add(tmpNewClass);
            }
        }
示例#2
0
 public void setActiveClass(CharacterClass tmpClass)
 {
     this.activeClass = tmpClass;
 }
        /// <summary>
        /// Updates selected character class to whatever was selected in the character class drop down list
        /// </summary>
        private void updateCmbInfo()
        {
            if (cmbCurrent.SelectedValue != null)
            {
                if (((int)cmbCurrent.SelectedValue) == -1)
                {
                    selectedCharacterClass = newCharacterClass.Clone(-1);
                }
                else
                {
                    selectedCharacterClass = _classWrapper.getClass((int)cmbCurrent.SelectedValue);
                }

                updateSelectedClassInfo();
            }
        }
 /// <summary>
 /// Removeds specified Class and ID from cache of used IDs
 /// </summary>
 /// <param name="tmpClass"></param>
 public void removeClassFromTempCache(CharacterClass tmpClass)
 {
     if(_listOfClasses.Contains(tmpClass)){
         _listOfClasses.Remove(tmpClass);
         _usedIDs.Remove(tmpClass.ClassID);
     }
 }
 private void lstClassClassPreReq_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (!updating)
     {
         if (lstClassClassPreReq.SelectedValue != null)
         {
             updating = true;
             selectedPreReqClass = characterClassFromDataSourceValueMember((int)lstClassClassPreReq.SelectedValue);
             updateSelectedPreReqInfo();
             updating = false;
         }
     }
 }
        //Functional Methods
        /// <summary>
        /// Loads all Character Classes into the class drop down lists
        /// </summary>
        private void loadPreExsistingCharacterClasses()
        {
            updating = true;
            characterClassBindingSource.Clear();
            prereqCharacterClassBindingSource.Clear();
            characterClassBindingSource.Add(newCharacterClass);
            foreach (CharacterClass tmpClass in _classWrapper.getClassList())
            {
                characterClassBindingSource.Add(tmpClass);
                prereqCharacterClassBindingSource.Add(tmpClass);
            }

            if (prereqCharacterClassBindingSource.Count > 0)
            {
                selectedPreReqClass = (CharacterClass)prereqCharacterClassBindingSource[0];
            }

            updateAbilityOptions();
            updating = false;
        }
 //Events
 private void cmbPreReqClasses_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (!updating)
     {
         updating = true;
         selectedPreReqClass = characterClassFromDataSourceValueMember((int)cmbPreReqClasses.SelectedValue);
         updateSelectedPreReqInfo();
         updating = false;
     }
 }
        private void btnSave_Click(object sender, EventArgs e)
        {
            string tmpClassName = txtName.Text;
            if (tmpClassName != string.Empty)
            {
                int tmpID;
                if (selectedCharacterClass.ClassID == -1)
                {
                    tmpID = _classWrapper.NextID();
                }
                else
                {
                    tmpID = selectedCharacterClass.ClassID;
                }

                //I dont like this matching by Name when there is a perfectly good ID available but im not sure how to do it differently.....for now
                List<int> tmpSelectedMagiElements = new List<int>();
                foreach (string tmpString in clElements.CheckedItems)
                {
                    foreach (MagiElement tmpMagiElement in _elementWrapper.getElementList())
                    {
                        if (tmpMagiElement.ElementName == tmpString)
                        {
                            tmpSelectedMagiElements.Add(tmpMagiElement.ElementID);
                        }
                    }
                }

                Dictionary<int, int> selectedAbilities = new Dictionary<int, int>();
                foreach (ListedAbility tmpListed in listedAbilityBindingSource)
                {
                    selectedAbilities.Add(tmpListed.AbilityID, tmpListed.LevelLearned);
                }

                selectedCharacterClass = new CharacterClass(tmpID, tmpClassName, getStatsFromNuds(), tmpSelectedMagiElements, selectedAbilities, getPreReqStatsFromNuds(), getPreReqClassIDs());
                _classWrapper.addClassToTempCache(selectedCharacterClass);
                loadPreExsistingCharacterClasses();
                cmbCurrent.SelectedIndex = 0;
                selectedCharacterClass = newCharacterClass.Clone(-1);
                changesSaved = false;
                configureGui();
                updateSelectedClassInfo();
            }
            else
            {
                MessageBox.Show("Please Enter a Class Name");
            }
        }
        public CharacterClass Clone(int tmpID)
        {
            CharacterClass tmpNewClass = new CharacterClass(tmpID, this.name, statsToDictionary(), this.magiElementsCanUse, this.abilitiesLearnedByLevel, preReqStatsToDictionary(), preReqClasses);

            return tmpNewClass;
        }