Пример #1
0
        /// <summary>
        /// Completes the serialization.
        /// </summary>
        /// <param name="character">The character.</param>
        /// <param name="plan">The plan.</param>
        /// <param name="serial">The serial.</param>
        private static void CompleteSerialization(Character character, Plan plan, OutputCharacter serial)
        {
            // Attributes enhancers
            foreach (Implant implant in character.CurrentImplants)
            {
                serial.AttributeEnhancers.Add(new OutputAttributeEnhancer
                {
                    Attribute   = implant.Slot,
                    Description = implant.Slot.GetDescription(),
                    Bonus       = implant.Bonus,
                    Name        = implant.Name
                });
            }

            // Skills (grouped by skill groups)
            foreach (SkillGroup skillGroup in character.SkillGroups)
            {
                OutputSkillGroup outGroup = AddSkillGroup(plan, skillGroup);

                foreach (Skill skill in skillGroup.Where(x => x.IsKnown || (plan != null && plan.IsPlanned(x))))
                {
                    AddSkill(plan, outGroup, skill);
                }

                if (outGroup.Skills.Count != 0)
                {
                    serial.SkillGroups.Add(outGroup);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Creates a HTML format file for character exportation.
        /// </summary>
        /// <param name="character"></param>
        /// <param name="plan"></param>
        private static string ExportAsHTML(Character character, Plan plan)
        {
            // Retrieves a XML representation of this character
            OutputCharacter serial = new OutputCharacter
            {
                Name            = character.Name,
                Balance         = character.Balance.ToNumericString(2, CultureConstants.InvariantCulture),
                Birthday        = character.Birthday.DateTimeToTimeString(),
                CorporationName = character.CorporationName,
                CharacterID     = character.CharacterID,
                BloodLine       = character.Bloodline,
                Ancestry        = character.Ancestry,
                Gender          = character.Gender,
                Race            = character.Race,
                Intelligence    = character.Intelligence.EffectiveValue,
                Perception      = character.Perception.EffectiveValue,
                Willpower       = character.Willpower.EffectiveValue,
                Charisma        = character.Charisma.EffectiveValue,
                Memory          = character.Memory.EffectiveValue
            };

            CompleteSerialization(character, plan, serial);

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

            XslCompiledTransform xslt    = Util.LoadXslt(Properties.Resources.XmlToHtmlXslt);
            XmlDocument          htmlDoc = (XmlDocument)Util.Transform(doc, xslt);

            // Returns the string representation of the generated doc
            return(Util.GetXmlStringRepresentation(htmlDoc));
        }
Пример #3
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));
        }