/// <summary>
        /// Adds an Ability to the wrapper list - Does not commit the addition - Run save() to do this
        /// </summary>
        /// <param name="tmpNewAbility"></param>
        public void addAbilityToTempCache(Ability tmpNewAbility)
        {
            int index = -1;
            foreach (Ability tmpAbility in _listOfAbilities)
            {
                if (tmpAbility.AbilityID == tmpNewAbility.AbilityID)
                {
                    index = _listOfAbilities.IndexOf(tmpAbility);
                }
            }

            if (index != -1)
            {
                _listOfAbilities[index] = tmpNewAbility;
            }
            else
            {
                _listOfAbilities.Add(tmpNewAbility);
            }
        }
Exemplo n.º 2
0
        public Ability Clone(int tmpId)
        {
            Ability newAbility = new Ability(tmpId, name, effects);

            return newAbility;
        }
 /// <summary>
 /// Removes specified Ability & ID from cache of used IDs
 /// </summary>
 /// <param name="tmpToRemoveAbility"></param>
 public void removeAbilityFromTempCache(Ability tmpToRemoveAbility)
 {
     if (this._listOfAbilities.Contains(tmpToRemoveAbility))
     {
         _listOfAbilities.Remove(tmpToRemoveAbility);
         _usedIDs.Remove(tmpToRemoveAbility.AbilityID);
     }
 }
 /// <summary>
 /// Removes specified Ability
 /// </summary>
 /// <param name="tmpToRemoveAbility"></param>
 public void removeAbility(Ability tmpToRemoveAbility)
 {
     if (this._listOfAbilities.Contains(tmpToRemoveAbility))
     {
         _listOfAbilities.Remove(tmpToRemoveAbility);
     }
 }
 private void btnSave_Click(object sender, EventArgs e)
 {
     string tmpAbilityName = txtName.Text;
     int tmpAbilityID;
     if (selectedAbility.AbilityID == -1)
     {
         tmpAbilityID = _abilityWrapper.NextID();
     }
     else
     {
         tmpAbilityID = selectedAbility.AbilityID;
     }
     selectedAbility = new Ability(tmpAbilityID, tmpAbilityName, effectsBox1.getList().ToList());
     _abilityWrapper.addAbilityToTempCache(selectedAbility);
     loadPreExsistingAbilities();
     selectedAbility = newAbility.Clone(-1);
     cmbCurrent.SelectedIndex = 0;
     changesSaved = false;
     configureGui();
 }
        private void cmbCurrent_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cmbCurrent.SelectedIndex == 0)
            {
                selectedAbility = newAbility.Clone(-1);
            }
            else
            {
                selectedAbility = _abilityWrapper.getAbilityList()[cmbCurrent.SelectedIndex - 1];
            }

            updateSelectedItemsInfo();
        }
        /// <summary>
        /// Loads all Abilities into the ability drop down list
        /// </summary>
        private void updateAbilityOptions()
        {
            abilityBindingSource.Clear();
            foreach (Ability tmpAbility in _abilityWrapper.getAbilityList())
            {
                abilityBindingSource.Add(tmpAbility);
            }

            if (abilityBindingSource.List.Count > 0)
            {
                selectedAbility = (Ability)abilityBindingSource.List[0];
            }
        }
 private void lstAbilities_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (!updating)
     {
         if (lstAbilities.SelectedValue != null)
         {
             updating = true;
             selectedAbility = abilityFromDataSourceValueMember((int)lstAbilities.SelectedValue);
             updateSelectedAbilityInfo();
             updating = false;
         }
     }
 }