Пример #1
0
        /// <summary>
        /// Adds the skill group.
        /// </summary>
        /// <param name="plan">The plan.</param>
        /// <param name="skillGroup">The skill group.</param>
        /// <returns></returns>
        private static OutputSkillGroup AddSkillGroup(Plan plan, SkillGroup skillGroup)
        {
            int count = skillGroup
                .Where(x => x.IsKnown || (plan != null && plan.IsPlanned(x)))
                .Select(x => GetMergedSkill(plan, x))
                .Count();

            Int64 skillGroupTotalSP = skillGroup
                .Where(x => x.IsKnown || (plan != null && plan.IsPlanned(x)))
                .Select(x => GetMergedSkill(plan, x))
                .Sum(x => x.Skillpoints);

            OutputSkillGroup outGroup = new OutputSkillGroup
            {
                Name = skillGroup.Name,
                SkillsCount = count,
                TotalSP = FormattableString.Invariant($"{skillGroupTotalSP:N0}")
            };
            return outGroup;
        }
Пример #2
0
        /// <summary>
        /// Creates a HTML format file for character exportation.
        /// </summary>
        /// <param name="character"></param>
        /// <param name="plan"></param>
        public static string ExportAsHTML(Character character, Plan plan)
        {
            // Retrieves a XML representation of this character
            var serial = new OutputCharacter();
            serial.Name = character.Name;
            serial.Balance = character.Balance;
            serial.CorporationName = character.CorporationName;
            serial.CharacterID = character.CharacterID;
            serial.BloodLine = character.Bloodline;
            serial.Gender = character.Gender;
            serial.Race = character.Race;

            serial.Intelligence = character.Intelligence.EffectiveValue;
            serial.Perception = character.Perception.EffectiveValue;
            serial.Willpower = character.Willpower.EffectiveValue;
            serial.Charisma = character.Charisma.EffectiveValue;
            serial.Memory = character.Memory.EffectiveValue;

            // Attributes enhancers
            foreach (var implant in character.CurrentImplants.Where(x => x != Implant.None && (int)x.Slot < 5))
            {
                serial.AttributeEnhancers.Add(new OutputAttributeEnhancer { Attribute = implant.Slot, Bonus = implant.Bonus, Name = implant.Name });
            }

            // Certificates
            foreach (var certClass in character.CertificateClasses)
            {
                var cert = certClass.HighestClaimedGrade;
                if (cert == null)
                    continue;

                serial.Certificates.Add(new OutputCertificate { Name = certClass.Name, Grade = cert.Grade.ToString() });
            }

            // Skills (grouped by skill groups)
            foreach (var skillGroup in character.SkillGroups)
            {
                int count = skillGroup.Where(x => x.IsKnown || (plan != null && plan.IsPlanned(x))).Select(x => GetMergedSkill(plan, x)).Count();
                int skillGroupTotalSP = skillGroup.Where(x => x.IsKnown || (plan != null && plan.IsPlanned(x))).Select(x => GetMergedSkill(plan, x)).Sum(x => x.Skillpoints);

                var outGroup = new OutputSkillGroup { Name = skillGroup.Name, SkillsCount = count, TotalSP = skillGroupTotalSP };

                foreach (var skill in skillGroup.Where(x => x.IsKnown || (plan != null && plan.IsPlanned(x))))
                {
                    var mergedSkill = GetMergedSkill(plan, skill);

                    outGroup.Skills.Add(new OutputSkill
                    {
                        Name = mergedSkill.Name,
                        Rank = skill.Rank,
                        Level = mergedSkill.Level,
                        SkillPoints = mergedSkill.Skillpoints,
                        RomanLevel = Skill.GetRomanForInt(mergedSkill.Level),
                        MaxSkillPoints = skill.StaticData.GetPointsRequiredForLevel(5)
                    });
                }

                if (outGroup.Skills.Count != 0)
                    serial.SkillGroups.Add(outGroup);
            }

            // Serializes to XML and apply a XSLT to generate the HTML doc
            var doc = Util.SerializeToXmlDocument(typeof(OutputCharacter), serial);

            var xslt = Util.LoadXSLT(Properties.Resources.XmlToHtmlXslt);
            var htmlDoc = Util.Transform(doc, xslt);

            // Returns the string representation of the generated doc
            return Util.GetXMLStringRepresentation(htmlDoc);
        }
Пример #3
0
        /// <summary>
        /// Adds the skill.
        /// </summary>
        /// <param name="plan">The plan.</param>
        /// <param name="outGroup">The out group.</param>
        /// <param name="skill">The skill.</param>
        private static void AddSkill(Plan plan, OutputSkillGroup outGroup, Skill skill)
        {
            SerializableCharacterSkill mergedSkill = GetMergedSkill(plan, skill);

            outGroup.Skills.Add(new OutputSkill
            {
                Name = mergedSkill.Name,
                Rank = skill.Rank,
                Level = mergedSkill.Level,
                SkillPoints = FormattableString.Invariant($"{mergedSkill.Skillpoints:N0}"),
                RomanLevel = Skill.GetRomanFromInt(mergedSkill.Level),
                MaxSkillPoints = FormattableString.Invariant($"{skill.StaticData.GetPointsRequiredForLevel(5):N0}")
            });
        }