Beispiel #1
0
        /// <summary>
        /// Get new toon instance from Xml
        /// </summary>
        /// <param name="document">Xml configuration</param>
        /// <returns>Toon instance</returns>
        public Toon ParseToon(XDocument document)
        {
            if (document == null)
                throw new ArgumentNullException("document");

            var element = document.Root;
            var result = new Toon();

            var value = element.Attribute("id").Value;
            result.Id = Guid.Parse(value);

            value = element.Element("mainStat").Value;
            result.MainAttackStat = (StatTypeEnum)Enum.Parse(typeof(StatTypeEnum), value, true);

            value = element.Element("attackModifier").Value;
            result.AttackModifier = double.Parse(value, CultureInfo.InvariantCulture);

            var initialStats = new List<ToonStat>();
            var statParser = new StatParser();
            var statElements = element.Element("stats").Elements().ToList();
            statElements.ForEach(x => initialStats.Add(statParser.ParseToonStat(x)));
            result.InitialStats = initialStats;

            return result;
        }
Beispiel #2
0
        /// <summary>
        /// Calculates stats provided by toon at maximal level with known might
        /// </summary>
        /// <param name="currentToon">Current character</param>
        /// <param name="calculationResult">Calculation results, containing calculated talents data</param>
        public void Calculate(Toon currentToon, CalculationResult calculationResult)
        {
            if (currentToon == null)
                throw new ArgumentNullException("currentToon");

            // Append initial stats (independent from might and talents)
            ApplyInitial(currentToon.InitialStats);

            // Append stats given by might (depends on current might value)
            ApplyMight(currentToon.InitialStats, calculationResult.Might);

            // Append all values to final result
            currentToon.InitialStats
                .ToList()
                .ForEach(x => applyStatValue(x.Type, x.Value, calculationResult));
        }