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

            foreach (CharacterWeapon objCharacterWeapon in lstCharacterWeapon)
            {
                lstCCharacterWeapon.Add(CharacterWeapon.Clone(objCharacterWeapon));
            }

            return(lstCCharacterWeapon);
        }
Пример #2
0
        /// <summary>
        /// Saves a List of Feats to a Character.
        /// </summary>
        /// <param name="lstCharFeat">A <List> of Feats .</param>
        /// <param name="intCharacterID">The Character identifier.</param>
        /// <returns></returns>
        public void SaveCharacterWeapons(List <CharacterWeapon> lstCharacterWeapon, int intCharacterID)
        {
            //Once a CharacterWeapon is added it can be removed or updated, so clear it out and start over
            CharacterWeapon objDelCharacterWeapon = new CharacterWeapon();

            objDelCharacterWeapon.DeleteCharacterWeapon(intCharacterID, 0);

            foreach (CharacterWeapon objCharWeapon in lstCharacterWeapon)
            {
                objCharWeapon.SaveCharacterWeapon();
            }
        }
Пример #3
0
        static public List <CharacterWeapon> RemoveCharacterWeaponFromList(CharacterWeapon objCharacterWeapon, List <CharacterWeapon> lstCharWeapons)
        {
            List <CharacterWeapon> retList = new List <CharacterWeapon>();

            foreach (CharacterWeapon objCharWeap in lstCharWeapons)
            {
                if (objCharacterWeapon.CharacterWeaponID != objCharWeap.CharacterWeaponID)
                {
                    retList.Add(objCharWeap);
                }
            }

            return(retList);
        }
Пример #4
0
        /// <summary>
        /// Determines whether [is skill in list] [the specified object skill].
        /// </summary>
        /// <param name="objCharacterWeapon">The object skill.</param>
        /// <param name="lstCharWeapons">The LST character skill.</param>
        /// <returns>Boolean</returns>
        static public bool IsCharacterWeaponInList(CharacterWeapon objCharacterWeapon, List <CharacterWeapon> lstCharWeapons)
        {
            bool blnCharacterWeaponFound = false;

            if (objCharacterWeapon.CharacterWeaponID == 0)
            {
                blnCharacterWeaponFound = true;
            }
            else
            {
                foreach (CharacterWeapon objCharWeap in lstCharWeapons)
                {
                    if (objCharacterWeapon.CharacterWeaponID == objCharWeap.CharacterWeaponID)
                    {
                        blnCharacterWeaponFound = true;
                    }
                }
            }
            return(blnCharacterWeaponFound);
        }
Пример #5
0
        /// <summary>
        /// Clones the specified object CharacterWeapon.
        /// </summary>
        /// <param name="objCharacterWeapon">The object CharacterWeapon.</param>
        /// <returns>CharacterWeapon</returns>
        static public CharacterWeapon Clone(CharacterWeapon objCharacterWeapon)
        {
            CharacterWeapon objCCharacterWeapon = new CharacterWeapon(objCharacterWeapon.CharacterID, objCharacterWeapon.WeaponID);


            objCCharacterWeapon.CharacterWeaponID = objCharacterWeapon.CharacterWeaponID;
            objCCharacterWeapon.CharacterID       = objCharacterWeapon.CharacterID;
            objCCharacterWeapon.WeaponID          = objCharacterWeapon.WeaponID;
            objCCharacterWeapon.RangeAttackBonus  = objCharacterWeapon.RangeAttackBonus;
            objCCharacterWeapon.RangeDamageBonus  = objCharacterWeapon.RangeDamageBonus;
            objCCharacterWeapon.MeleeAttackBonus  = objCharacterWeapon.MeleeAttackBonus;
            objCCharacterWeapon.MeleeDamageBonus  = objCharacterWeapon.MeleeDamageBonus;
            objCCharacterWeapon.Notes             = objCharacterWeapon.Notes;

            objCCharacterWeapon.objWeapon              = Weapon.Clone(objCharacterWeapon.objWeapon);
            objCCharacterWeapon.lstWeaponRanges        = Range.Clone(objCharacterWeapon.lstWeaponRanges);
            objCCharacterWeapon.lstWeaponModifications = Modification.Clone(objCharacterWeapon.lstWeaponModifications);

            return(objCCharacterWeapon);
        }
Пример #6
0
        /// <summary>
        /// Gets the character weapon 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 CharacterWeapons</returns>
        private List <CharacterWeapon> GetCharacterWeaponList(string strSprocName, string strWhere, string strOrderBy)
        {
            List <CharacterWeapon> characterWeapons = new List <CharacterWeapon>();

            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())
                {
                    CharacterWeapon objCharacterWeapon = new CharacterWeapon();
                    SetReaderToObject(ref objCharacterWeapon, ref result);
                    characterWeapons.Add(objCharacterWeapon);
                }
            }
            catch
            {
                Exception e = new Exception();
                throw e;
            }
            finally
            {
                command.Dispose();
                connection.Close();
            }
            return(characterWeapons);
        }
Пример #7
0
        /// <summary>
        /// Sets the reader to object.
        /// </summary>
        /// <param name="objCharacterWeapon">The object character weapon.</param>
        /// <param name="result">The result.</param>
        private void SetReaderToObject(ref CharacterWeapon objCharacterWeapon, ref SqlDataReader result)
        {
            if (result.HasRows)
            {
                objCharacterWeapon.CharacterWeaponID = (int)result.GetValue(result.GetOrdinal("CharacterWeaponID"));
                objCharacterWeapon.CharacterID       = (int)result.GetValue(result.GetOrdinal("CharacterID"));
                objCharacterWeapon.WeaponID          = (int)result.GetValue(result.GetOrdinal("WeaponID"));
                objCharacterWeapon.RangeAttackBonus  = (int)result.GetValue(result.GetOrdinal("RangeAttackBonus"));
                objCharacterWeapon.RangeDamageBonus  = (int)result.GetValue(result.GetOrdinal("RangeDamageBonus"));
                objCharacterWeapon.MeleeAttackBonus  = (int)result.GetValue(result.GetOrdinal("MeleeAttackBonus"));
                objCharacterWeapon.MeleeDamageBonus  = (int)result.GetValue(result.GetOrdinal("MeleeDamageBonus"));
                objCharacterWeapon.Notes             = result.GetValue(result.GetOrdinal("Notes")).ToString();

                Weapon objWeapon = new Weapon();
                objCharacterWeapon.objWeapon = objWeapon.GetWeapon(objCharacterWeapon.WeaponID);

                Range objRange = new Range();
                objCharacterWeapon.lstWeaponRanges = objRange.GetWeaponRanges("WeaponID=" + objCharacterWeapon.WeaponID.ToString(), "BeginSquare");

                Modification objModification = new Modification();
                objCharacterWeapon.lstWeaponModifications = objModification.GetCharacterWeaponModifications(objCharacterWeapon.CharacterWeaponID);
            }
        }