Exemple #1
0
        public ClassModel()
        {
            QueryInformation   query;
            List <string>      destinyNames;
            DestinySphereModel DefaultDestiny;

            //set up default values for properties where needed
            Name         = DefaultName;
            Abbreviation = DefaultAbbreviation;

            //starting destiny sphere
            destinyNames   = DestinySphereModel.GetNames();
            DefaultDestiny = new DestinySphereModel();
            DefaultDestiny.Initialize(destinyNames[0]);
            MaxSpellLevel           = 0;
            StartingDestinySphereId = DefaultDestiny.Id;

            ImageFilename = DefaultImageFilename;
            Description   = DefaultDescription;
            LevelDetails  = new ClassLevelDetailModel[Constant.NumHeroicLevels];
            for (int i = 0; i < Constant.NumHeroicLevels; i++)
            {
                LevelDetails[i] = new ClassLevelDetailModel();
            }

            //the sequence and reincarnation priority number (default to last record in sequence)
            query                 = QueryInformation.Create(ClassModel.CountQuery);
            query.CommandType     = CommandType.Text;
            Sequence              = BaseModel.GetCount(query);
            ReincarnationPriority = Sequence;
        }
        private static ClassLevelDetailModel Create(DbDataReader reader)
        {
            ClassLevelDetailModel model;

            model = new ClassLevelDetailModel();
            model.Load(reader);

            return(model);
        }
Exemple #3
0
        /// <summary>
        /// Loads the specified reader.
        /// </summary>
        /// <param name="reader">The reader.</param>
        protected override void Load(DbDataReader reader)
        {
            int ordinal;

            if (reader == null)
            {
                return;
            }

            if (!reader.TryGetOrdinal(ClassModel.IdField, out ordinal))
            {
                // No ID field, can't use
                return;
            }

            if (reader.IsDBNull(ordinal))
            {
                // Null, can't use
                return;
            }

            Id = reader.GetGuid(ordinal);

            if (reader.TryGetOrdinal(ClassModel.NameField, out ordinal))
            {
                if (!reader.IsDBNull(ordinal))
                {
                    Name = reader.GetString(ordinal);
                }
            }

            if (reader.TryGetOrdinal(ClassModel.AbbreviationField, out ordinal))
            {
                if (!reader.IsDBNull(ordinal))
                {
                    Abbreviation = reader.GetString(ordinal);
                }
            }

            if (reader.TryGetOrdinal(ClassModel.DescriptionField, out ordinal))
            {
                if (!reader.IsDBNull(ordinal))
                {
                    Description = reader.GetString(ordinal);
                }
            }

            if (reader.TryGetOrdinal(ClassModel.HitDieField, out ordinal))
            {
                if (!reader.IsDBNull(ordinal))
                {
                    HitDie = reader.GetByte(ordinal);
                }
            }

            if (reader.TryGetOrdinal(ClassModel.SkillPointsField, out ordinal))
            {
                if (!reader.IsDBNull(ordinal))
                {
                    SkillPoints = reader.GetByte(ordinal);
                }
            }

            if (reader.TryGetOrdinal(ClassModel.StartingDestinySphereIdField, out ordinal))
            {
                if (!reader.IsDBNull(ordinal))
                {
                    StartingDestinySphereId = reader.GetGuid(ordinal);
                }
            }

            if (reader.TryGetOrdinal(ClassModel.ReincarnationPriorityField, out ordinal))
            {
                if (!reader.IsDBNull(ordinal))
                {
                    ReincarnationPriority = reader.GetByte(ordinal);
                }
            }

            if (reader.TryGetOrdinal(ClassModel.ImageFileNameField, out ordinal))
            {
                if (!reader.IsDBNull(ordinal))
                {
                    ImageFilename = reader.GetString(ordinal);
                }
            }

            if (reader.TryGetOrdinal(ClassModel.LastUpdatedDateField, out ordinal))
            {
                if (!reader.IsDBNull(ordinal))
                {
                    LastUpdatedDate = reader.GetDateTime(ordinal);
                }
            }

            if (reader.TryGetOrdinal(ClassModel.LastUpdatedVersionField, out ordinal))
            {
                if (!reader.IsDBNull(ordinal))
                {
                    LastUpdatedVersion = reader.GetString(ordinal);
                }
            }

            if (reader.TryGetOrdinal(ClassModel.SequenceField, out ordinal))
            {
                if (!reader.IsDBNull(ordinal))
                {
                    Sequence = reader.GetByte(ordinal);
                }
            }

            if (reader.TryGetOrdinal(ClassModel.MaxSpellLevelField, out ordinal))
            {
                if (!reader.IsDBNull(ordinal))
                {
                    MaxSpellLevel = reader.GetByte(ordinal);
                }
            }


            AllowedAlignments = AlignmentModel.GetAllForClass(Id);
            ClassSkills       = SkillModel.GetAllForClass(Id);
            LevelDetails      = ClassLevelDetailModel.GetAll(Id).ToArray();
        }