Example #1
0
        public OffenseStatsTests()
        {
            character = CharacterTestTemplates.AverageBob();
            var abilities = character.Get <AbilityScores>();

            abilities.SetScore(AbilityScoreTypes.Strength, 16);
            abilities.SetScore(AbilityScoreTypes.Dexterity, 14);
            var size = character.Get <SizeStats>();

            size.SetSize(CharacterSize.Small, 1, 1);
            inventory        = character.Get <Inventory>();
            smallStats       = character.Get <OffenseStats>();
            meleeAttackBonus = character.Get <MeleeAttackBonus>();
            rangeAttackBonus = character.Get <RangeAttackBonus>();
        }
        /// <summary>
        /// Saves the character class level.
        /// </summary>
        /// <returns>CharacterWeapon Object</returns>
        public CharacterWeapon SaveCharacterWeapon()
        {
            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 = "InsertUpdate_CharacterWeapon";
                command.Parameters.Add(dbconn.GenerateParameterObj("@CharacterWeaponID", SqlDbType.Int, CharacterWeaponID.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@CharacterID", SqlDbType.Int, CharacterID.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@WeaponID", SqlDbType.Int, WeaponID.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@RangeAttackBonus", SqlDbType.Int, RangeAttackBonus.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@RangeDamageBonus", SqlDbType.Int, RangeDamageBonus.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@MeleeAttackBonus", SqlDbType.Int, MeleeAttackBonus.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@MeleeDamageBonus", SqlDbType.Int, MeleeDamageBonus.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@Notes", SqlDbType.VarChar, Notes.ToString(), 100));
                result = command.ExecuteReader();

                result.Read();
                SetReaderToObject(ref result);
            }
            catch
            {
                Exception e = new Exception();
                this._insertUpdateOK = false;
                this._insertUpdateMessage.Append(e.Message + "                     Inner Exception= " + e.InnerException);
                throw e;
            }
            finally
            {
                command.Dispose();
                connection.Close();
            }
            return(this);
        }