Example #1
0
        /// <summary>
        /// Creates a XML format file for character exportation.
        /// </summary>
        /// <param name="character"></param>
        /// <param name="plan"></param>
        public static string ExportAsEVEMonXML(Character character, Plan plan)
        {
            var serial = character.Export();

            if (plan != null)
            {
                serial.Skills = character.Skills.Where(x => x.IsKnown || (plan != null && plan.IsPlanned(x))).Select(x => GetMergedSkill(plan, x)).ToList();
            }

            var doc = Util.SerializeToXmlDocument(serial.GetType(), serial);

            return(Util.GetXMLStringRepresentation(doc));
        }
Example #2
0
        /// <summary>
        /// Creates a TXT format file for character exportation.
        /// </summary>
        /// <param name="character"></param>
        /// <param name="plan"></param>
        public static string ExportAsText(Character character, Plan plan)
        {
            string Separator    = "=======================================================================";
            string SubSeparator = "-----------------------------------------------------------------------";

            StringBuilder builder = new StringBuilder();

            builder.AppendLine("BASIC INFO");
            builder.AppendLine(Separator);
            builder.AppendFormat(CultureConstants.DefaultCulture, "     Name: {0}{1}", character.Name, Environment.NewLine);
            builder.AppendFormat(CultureConstants.DefaultCulture, "   Gender: {0}{1}", character.Gender, Environment.NewLine);
            builder.AppendFormat(CultureConstants.DefaultCulture, "     Race: {0}{1}", character.Race, Environment.NewLine);
            builder.AppendFormat(CultureConstants.DefaultCulture, "Bloodline: {0}{1}", character.Bloodline, Environment.NewLine);
            builder.AppendFormat(CultureConstants.DefaultCulture, "  Balance: {0} ISK{1}", character.Balance.ToString("#,##0.00"), Environment.NewLine);
            builder.AppendLine();
            builder.AppendFormat(CultureConstants.DefaultCulture, "Intelligence: {0}{1}", character.Intelligence.EffectiveValue.ToString("#0.00").PadLeft(5), Environment.NewLine);
            builder.AppendFormat(CultureConstants.DefaultCulture, "    Charisma: {0}{1}", character.Charisma.EffectiveValue.ToString("#0.00").PadLeft(5), Environment.NewLine);
            builder.AppendFormat(CultureConstants.DefaultCulture, "  Perception: {0}{1}", character.Perception.EffectiveValue.ToString("#0.00").PadLeft(5), Environment.NewLine);
            builder.AppendFormat(CultureConstants.DefaultCulture, "      Memory: {0}{1}", character.Memory.EffectiveValue.ToString("#0.00").PadLeft(5), Environment.NewLine);
            builder.AppendFormat(CultureConstants.DefaultCulture, "   Willpower: {0}{1}", character.Willpower.EffectiveValue.ToString("#0.00").PadLeft(5), Environment.NewLine);
            builder.AppendLine();

            // Implants
            var implants = character.CurrentImplants.Where(x => x != Implant.None && (int)x.Slot < 5);

            if (implants.Count() > 0)
            {
                builder.AppendLine("IMPLANTS");
                builder.AppendLine(Separator);
                foreach (var implant in implants)
                {
                    builder.AppendFormat(CultureConstants.DefaultCulture, "+{0} {1} : {2}{3}", implant.Bonus, implant.Slot.ToString().PadRight(13), implant.Name, Environment.NewLine);
                }
                builder.AppendLine();
            }

            // Skill groups
            builder.AppendLine("SKILLS");
            builder.AppendLine(Separator);
            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);

                // Skill Group
                builder.AppendFormat(CultureConstants.DefaultCulture, "{0}, {1} Skill{2}, {3} Points{4}",
                                     skillGroup.Name, count, count > 1 ? "s" : String.Empty,
                                     skillGroupTotalSP.ToString("#,##0"), Environment.NewLine);

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

                    string skillDesc = String.Format(CultureConstants.DefaultCulture, "{0} ({1})", skill.ToString(), skill.Rank.ToString());
                    builder.AppendFormat(CultureConstants.DefaultCulture, ": {0} L{1} {2}/{3} Points{4}",
                                         skillDesc.PadRight(45), mergedSkill.Level.ToString().PadRight(5), mergedSkill.Skillpoints.ToString("#,##0"),
                                         skill.StaticData.GetPointsRequiredForLevel(5).ToString("#,##0"), Environment.NewLine);

                    // If the skill is in training...
                    if (skill.IsTraining)
                    {
                        DateTime adjustedEndTime = character.CurrentlyTrainingSkill.EndTime.ToLocalTime();
                        builder.AppendFormat(CultureConstants.DefaultCulture, ":  (Currently training to level {0}, completes {1}){2}",
                                             Skill.GetRomanForInt(character.CurrentlyTrainingSkill.Level), adjustedEndTime, Environment.NewLine);
                    }
                }

                builder.AppendLine(SubSeparator);
            }

            return(builder.ToString());
        }
Example #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));
        }