protected override void WriteDataXML(XElement ele, ElderScrollsPlugin master)
        {
            XElement subEle;

            ele.TryPathTo("Flags", true, out subEle);
            subEle.Value = MagicEffectFlags.ToString();

            ele.TryPathTo("BaseCost", true, out subEle);
            subEle.Value = BaseCost.ToString("G15");

            ele.TryPathTo("AssociatedItem", true, out subEle);
            AssociatedItem.WriteXML(subEle, master);

            ele.TryPathTo("MagicSchool", true, out subEle);
            subEle.Value = MagicSchool.ToString();

            ele.TryPathTo("ResistanceType", true, out subEle);
            subEle.Value = ResistanceType.ToString();

            ele.TryPathTo("Unknown", true, out subEle);
            subEle.Value = Unknown.ToString();

            WriteUnusedXML(ele, master);

            ele.TryPathTo("Light", true, out subEle);
            Light.WriteXML(subEle, master);

            ele.TryPathTo("ProjectileSpeed", true, out subEle);
            subEle.Value = ProjectileSpeed.ToString("G15");

            ele.TryPathTo("EffectShader", true, out subEle);
            EffectShader.WriteXML(subEle, master);

            ele.TryPathTo("ObjectDisplayShader", true, out subEle);
            ObjectDisplayShader.WriteXML(subEle, master);

            ele.TryPathTo("EffectSound", true, out subEle);
            EffectSound.WriteXML(subEle, master);

            ele.TryPathTo("BoltSound", true, out subEle);
            BoltSound.WriteXML(subEle, master);

            ele.TryPathTo("HitSound", true, out subEle);
            HitSound.WriteXML(subEle, master);

            ele.TryPathTo("AreaSound", true, out subEle);
            AreaSound.WriteXML(subEle, master);

            ele.TryPathTo("ConstantEffectEnchantmentFactor", true, out subEle);
            subEle.Value = ConstantEffectEnchantmentFactor.ToString("G15");

            ele.TryPathTo("ConstantEffectBarterFactor", true, out subEle);
            subEle.Value = ConstantEffectBarterFactor.ToString("G15");

            ele.TryPathTo("Archetype", true, out subEle);
            subEle.Value = Archetype.ToString();

            ele.TryPathTo("ActorValue", true, out subEle);
            subEle.Value = ActorValue.ToString();
        }
예제 #2
0
        /// <summary>
        /// Creates an item from an Archetype and a tag.
        /// The item to be created is random, as long as it shares the correct tag.
        /// </summary>
        /// <param name="archetype"></param>
        /// <param name="tag"></param>
        /// <param name="itemID">The id of the chosen item</param>
        /// <returns></returns>
        public MapItem CreateItem(Archetype archetype, string tag,out int itemID)
        {
            int id = DatabaseHandling.GetItemIdFromTag(archetype, tag);

            itemID = id;

            //Now get the actual item
            return this.CreateItem(archetype.ToString().ToLower(), id);
        }
        /// <summary>
        /// Trains a character for one year
        /// </summary>
        /// <param name="charactertoTrain"></param>
        /// <param name="characterArchetype"></param>
        /// <returns></returns>
        private static StatisticalResults TrainCharacterFor10Years(global::RNPC.Core.Character charactertoTrain, Archetype characterArchetype)
        {
            //ARRANGE
            var preTrainingQs             = charactertoTrain.MyTraits.GetPersonalQualitiesValues();
            int numberOfPretrainingValues = charactertoTrain.MyTraits.PersonalValues.Count;

            Stopwatch timer = new Stopwatch();

            timer.Start();

            PersonalTrainer trainer = new PersonalTrainer(new ItemLinkFactory());

            //ACT
            trainer.TrainForXNumberOfYears(charactertoTrain, 10);

            //ASSERT
            timer.Stop();

            int qualitiesModified = 0;
            int increaseDelta     = 0;
            int decreaseDelta     = 0;

            foreach (var quality in charactertoTrain.MyTraits.GetPersonalQualitiesValues())
            {
                if (quality.Value == preTrainingQs[quality.Key])
                {
                    continue;
                }

                qualitiesModified++;

                if (quality.Value > preTrainingQs[quality.Key])
                {
                    increaseDelta += quality.Value - preTrainingQs[quality.Key];
                }
                else
                {
                    decreaseDelta = preTrainingQs[quality.Key] - quality.Value;
                }
            }

            StatisticalResults results = new StatisticalResults
            {
                Archetype             = characterArchetype.ToString(),
                YearsofTraining       = 10,
                TrainingTime          = timer.ElapsedMilliseconds / 1000,
                ValuesAdded           = charactertoTrain.MyTraits.PersonalValues.Count - numberOfPretrainingValues,
                QualitiesModified     = qualitiesModified,
                QualityIncrease       = increaseDelta,
                QualityDecrease       = decreaseDelta,
                DecisionTreesModified = GetNumberOfRecentlyChangedDecisionTrees(charactertoTrain.MyName)
            };

            return(results);
        }
        private IEnumerable <ArchetypeStatistics> CompileStatistics(List <List <double> > results, Archetype archetype)
        {
            List <ArchetypeStatistics> archetypeStatistics = new List <ArchetypeStatistics>
            {
                new ArchetypeStatistics
                {
                    Archetype = archetype.ToString(),
                    Event     = "Friendly Greeting",
                    Min       = results[0].Min(),
                    Max       = results[0].Max(),
                    Average   = results[0].Average()
                },
                new ArchetypeStatistics
                {
                    Archetype = archetype.ToString(),
                    Event     = "Hostile Threat",
                    Min       = results[1].Min(),
                    Max       = results[1].Max(),
                    Average   = results[1].Average()
                },
                new ArchetypeStatistics
                {
                    Archetype = archetype.ToString(),
                    Event     = "Neutral Greeting",
                    Min       = results[2].Min(),
                    Max       = results[2].Max(),
                    Average   = results[2].Average()
                },
                new ArchetypeStatistics
                {
                    Archetype = archetype.ToString(),
                    Event     = "Friendly How Are You",
                    Min       = results[3].Min(),
                    Max       = results[3].Max(),
                    Average   = results[3].Average()
                },
                new ArchetypeStatistics
                {
                    Archetype = archetype.ToString(),
                    Event     = "Hostile Insult",
                    Min       = results[4].Min(),
                    Max       = results[4].Max(),
                    Average   = results[4].Average()
                },
                new ArchetypeStatistics
                {
                    Archetype = archetype.ToString(),
                    Event     = "Neutral How Are You",
                    Min       = results[5].Min(),
                    Max       = results[5].Max(),
                    Average   = results[5].Average()
                },
                new ArchetypeStatistics
                {
                    Archetype = archetype.ToString(),
                    Event     = "Friendly Teasing",
                    Min       = results[6].Min(),
                    Max       = results[6].Max(),
                    Average   = results[6].Average()
                },
                new ArchetypeStatistics
                {
                    Archetype = archetype.ToString(),
                    Event     = "Hostile Mockery",
                    Min       = results[7].Min(),
                    Max       = results[7].Max(),
                    Average   = results[7].Average()
                },
                new ArchetypeStatistics
                {
                    Archetype = archetype.ToString(),
                    Event     = "Neutral Apologyg",
                    Min       = results[8].Min(),
                    Max       = results[8].Max(),
                    Average   = results[8].Average()
                },
                new ArchetypeStatistics
                {
                    Archetype = archetype.ToString(),
                    Event     = "Friendly Smile",
                    Min       = results[9].Min(),
                    Max       = results[9].Max(),
                    Average   = results[9].Average()
                },
                new ArchetypeStatistics
                {
                    Archetype = archetype.ToString(),
                    Event     = "Hostile Glare",
                    Min       = results[10].Min(),
                    Max       = results[10].Max(),
                    Average   = results[10].Average()
                },
                new ArchetypeStatistics
                {
                    Archetype = archetype.ToString(),
                    Event     = "Neutral Salute",
                    Min       = results[11].Min(),
                    Max       = results[11].Max(),
                    Average   = results[11].Average()
                }
            };

            //Friendly Greeting

            //Hostile Threat

            //Neutral Greeting

            //Friendly How Are You?

            //Hostile-Insult
            //Neutral How Are You?

            //Friendly Teasing

            //Hostile Mockery

            //Neutral Apology

            //Friendly Smile

            //Hostile Glare

            //Neutral Salute

            return(archetypeStatistics);
        }
예제 #5
0
        /// <summary>
        /// Read an entire table into memory
        /// </summary>s
        /// <param name="archetype"></param>
        /// <param name="itemID"></param>
        public static void ReadTableIntoMemory(Archetype archetype)
        {
            //Lazily load the entire table
            using (SqlCeConnection conn = new SqlCeConnection("Data Source=items.sdf;Max Database Size=256;Persist Security Info=False;"))
            {
                conn.Open();
                string tableName = archetype.ToString().ToLower();
                string firstChar = tableName.Substring(0, 1);
                tableName = firstChar.ToUpper() + tableName.Substring(1);

                SqlCeCommand com = new SqlCeCommand("SELECT * from " + tableName, conn);

                SqlCeDataReader reader = com.ExecuteReader();
                Dictionary<int, List<string>> values = new Dictionary<int, List<string>>();

                while (reader.Read())
                {
                    List<string> data = new List<string>();
                    for (int i = 0; i < reader.VisibleFieldCount; i++)
                    {
                        data.Add(reader.GetValue(i).ToString());
                    }

                    //the first one will be an int, with the id
                    values.Add(reader.GetInt32(0), data);
                }

                dictionary.Add(archetype, values);
            }
        }