Пример #1
0
        /// <summary>
        /// Clones the specified LST Defense.
        /// </summary>
        /// <param name="lstDefense">The LST Defense.</param>
        /// <returns>List<Defense></returns>
        static public List <CharacterDefense> Clone(List <CharacterDefense> lstDefense)
        {
            List <CharacterDefense> lstCDefense = new List <CharacterDefense>();

            foreach (CharacterDefense objDefense in lstDefense)
            {
                lstCDefense.Add(CharacterDefense.Clone(objDefense));
            }

            return(lstCDefense);
        }
Пример #2
0
        /// <summary>
        /// Returns the Will Defense of a Character
        /// </summary>
        /// <param name="objChar">The Character object.</param>
        /// <returns>CharacterDefense</returns>
        static public CharacterDefense GetWillDefense(Character objChar)
        {
            CharacterDefense objCDefense = new CharacterDefense();

            foreach (CharacterDefense objCharDef in objChar.lstDefenses)
            {
                if (objCharDef.DefenseTypeID == 3)
                {
                    objCDefense = objCharDef;
                }
            }

            return(objCDefense);
        }
Пример #3
0
        /// <summary>
        /// Saves a List of Defenses to a Character.
        /// </summary>
        /// <param name="lstCharDefense">A <List> of Defenses .</param>
        /// <param name="intCharacterID">The Character identifier.</param>
        /// <returns></returns>
        public void SaveCharacterDefenses(List <CharacterDefense> lstCharDefense, int intCharacterID)
        {
            //Different one here.  Currently Characters should have three defences (Will, Fort and Reflex) but they are
            //updated every time a level is added.  The Defense table has a Defense ID as a PK and not a DefenseTypeID and
            //CharacterID so we are going to delete the Defense records by Character and then readd them.
            CharacterDefense objDelDefense = new CharacterDefense();

            objDelDefense.DeleteDefenses(intCharacterID, 0);

            foreach (CharacterDefense objCharDefense in lstCharDefense)
            {
                objCharDefense.SaveDefense();
            }
        }
Пример #4
0
        /// <summary>
        /// Sets the reader to object.
        /// </summary>
        /// <param name="objDefense">The object defense.</param>
        /// <param name="result">The result.</param>
        private void SetReaderToObject(ref CharacterDefense objDefense, ref SqlDataReader result)
        {
            if (result.HasRows)
            {
                //objDefense.DefenseID = (int)result.GetValue(result.GetOrdinal("DefenseID"));
                objDefense.DefenseTypeID       = (int)result.GetValue(result.GetOrdinal("DefenseTypeID"));
                objDefense.CharacterLevelArmor = (int)result.GetValue(result.GetOrdinal("CharacterLevelArmor"));
                objDefense.AbilityMod          = (int)result.GetValue(result.GetOrdinal("AbilityMod"));
                objDefense.ClassMod            = (int)result.GetValue(result.GetOrdinal("ClassMod"));
                objDefense.RaceMod             = (int)result.GetValue(result.GetOrdinal("RaceMod"));
                objDefense.FeatTalentMod       = (int)result.GetValue(result.GetOrdinal("FeatTalentMod"));
                objDefense.MiscellaneousMod    = (int)result.GetValue(result.GetOrdinal("MiscellaneousMod"));

                DefenseType obDefenseType = new DefenseType();
                if (!(objDefense.DefenseTypeID == 0))
                {
                    obDefenseType.GetDefenseType(objDefense.DefenseTypeID);
                }
                objDefense.DefenseType = obDefenseType;
            }
        }
Пример #5
0
        /// <summary>
        /// Gets the defense list.
        /// </summary>
        /// <param name="strSprocName">Name of the string sproc.</param>
        /// <param name="strWhere">The string where.</param>
        /// <param name="strOrderBy">The string order by.</param>
        /// <returns>List of Defense Objects</returns>
        private List <CharacterDefense> GetDefenseList(string strSprocName, string strWhere, string strOrderBy)
        {
            List <CharacterDefense> defenses = new List <CharacterDefense>();

            SqlDataReader      result;
            DatabaseConnection dbconn     = new DatabaseConnection();
            SqlCommand         command    = new SqlCommand();
            SqlConnection      connection = new SqlConnection(dbconn.SQLSEVERConnString);

            try
            {
                connection.Open();
                command.Connection  = connection;
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = strSprocName;
                command.Parameters.Add(dbconn.GenerateParameterObj("@strWhere", SqlDbType.VarChar, strWhere, 1000));
                command.Parameters.Add(dbconn.GenerateParameterObj("@strOrderBy", SqlDbType.VarChar, strOrderBy, 1000));
                result = command.ExecuteReader();

                while (result.Read())
                {
                    CharacterDefense objDefense = new CharacterDefense();
                    SetReaderToObject(ref objDefense, ref result);
                    defenses.Add(objDefense);
                }
            }
            catch
            {
                Exception e = new Exception();
                throw e;
            }
            finally
            {
                command.Dispose();
                connection.Close();
            }
            return(defenses);
        }
Пример #6
0
        /// <summary>
        /// Clones the specified object Defense.
        /// </summary>
        /// <param name="objDefense">The object Defense.</param>
        /// <returns>Defense</returns>
        static public CharacterDefense Clone(CharacterDefense objDefense, bool blnFromDatabase = false)
        {
            //Get the data from the database(?) then match it with what is passed in, we want to clone what is passed in for Character Items, not List Items
            CharacterDefense objCDefense = new CharacterDefense();

            if (blnFromDatabase)
            {
                objCDefense.GetDefense(objDefense.CharacterID, objDefense.DefenseTypeID);
            }
            else
            {
                objCDefense.AbilityMod          = objDefense.AbilityMod;
                objCDefense.CharacterID         = objDefense.CharacterID;
                objCDefense.CharacterLevelArmor = objDefense.CharacterLevelArmor;
                objCDefense.ClassMod            = objDefense.ClassMod;
                objCDefense.DefenseType         = objDefense.DefenseType;
                objCDefense.DefenseTypeID       = objDefense.DefenseTypeID;
                objCDefense.FeatTalentMod       = objDefense.FeatTalentMod;
                objCDefense.MiscellaneousMod    = objDefense.MiscellaneousMod;
                objCDefense.RaceMod             = objDefense.RaceMod;
            }
            return(objCDefense);
        }