void ExportPointsSummary(GCACharacter pc, GCAWriter fw) { fw.WriteLine(); }
void ExportEquiment(GCACharacter pc, GCAWriter fw) { fw.WriteHeader("Equipment [$" + pc.get_Cost(modConstants.Equipment) + "]"); foreach (var item in ComplexListTrait(TraitTypes.Equipment, fw).Where(x => string.IsNullOrEmpty(x) != true)) { fw.Write(item); } fw.WriteLine(); }
void ExportLoadout(GCACharacter pc, GCAWriter fw) { fw.WriteLine(); }
string AdvantageFormatter(GCATrait trait, GCAWriter fw) { var builder = new StringBuilder(); builder.Append(trait.Name); if (!trait.get_TagItem("level").Equals("1") || !string.IsNullOrEmpty(trait.get_TagItem("upto")) || !string.IsNullOrEmpty(trait.LevelName)) // has more than one level { builder.AppendFormat(" {0}", string.IsNullOrEmpty(trait.LevelName) ? trait.get_TagItem("level") : trait.LevelName); } var label = builder.ToString(); builder.Clear(); if (!string.IsNullOrEmpty(trait.NameExt) || trait.Mods.Count() > 0) builder.Append(" ("); if (!string.IsNullOrEmpty(trait.NameExt)) builder.Append(trait.NameExt); if (!string.IsNullOrEmpty(trait.NameExt) && trait.Mods.Count() > 0) builder.Append("; "); if (trait.Mods.Count() > 0) { var mods = new List<GCAModifier>(); foreach (GCAModifier item in trait.Mods) { mods.Add(item); } builder.Append(String.Join("; ", mods.Select(x => ModifierFormatter(x, fw)))); } if (!string.IsNullOrEmpty(trait.NameExt) || trait.Mods.Count() > 0) builder.Append(")"); builder.AppendFormat(" [{0}]", trait.Points); return fw.FormatTrait(label, builder.ToString()); }
void ExportCultural(GCACharacter pc, GCAWriter fw) { fw.WriteHeader("Cultural Background"); var label = "TL:"; var curItem = pc.ItemByNameAndExt("Tech Level", modConstants.Stats); if (curItem != null) { var buffer = curItem.DisplayScore; if (curItem.Points != 0) { buffer = string.Format("{0} [{1}]", buffer, curItem.Points); } fw.WriteTrait(label, buffer); } fw.WriteLine(); if (pc.get_Count(modConstants.Cultures) > 0) { label = "Cultures: "; var buffer = SimpleStringTrait(TraitTypes.Cultures); fw.WriteTrait(label, buffer); } if (pc.get_Count(modConstants.Languages) > 0) { label = "Languages: "; var buffer = SimpleStringTrait(TraitTypes.Languages); fw.WriteTrait(label, buffer); } fw.WriteLine(); }
string FormatTrait(GCATrait trait, GCAWriter fw, int childDepth = 0) { //fw.WriteLine("DEBUG TRAIT {0} DEPTH {1}", trait.Name, childDepth); TraitFormatter formatter = null; switch (trait.ItemType) { case TraitTypes.Attributes: formatter = AttributeFormatter; break; case TraitTypes.Languages: formatter = AdvantageFormatter; break; case TraitTypes.Cultures: formatter = AdvantageFormatter; break; case TraitTypes.Advantages: formatter = AdvantageFormatter; break; case TraitTypes.Perks: formatter = AdvantageFormatter; break; case TraitTypes.Disadvantages: formatter = AdvantageFormatter; break; case TraitTypes.Quirks: formatter = AdvantageFormatter; break; case TraitTypes.Skills: formatter = SkillFormatter; break; case TraitTypes.Spells: formatter = SkillFormatter; break; case TraitTypes.Equipment: formatter = EquipmentFormatter; break; case TraitTypes.Templates: formatter = TemplateFormatter; break; } var builder = new StringBuilder(); if ( string.IsNullOrEmpty(trait.get_TagItem("parentkey")) || childDepth > 0) { for (int i = 0; i < childDepth; i++) { builder.Append(":"); } builder.Append(formatter != null ? formatter(trait, fw) : string.Empty); builder.Append(Environment.NewLine); if (!string.IsNullOrEmpty(trait.get_ChildKeyList())) { var keys = trait.get_ChildKeyList().Split(','); //fw.WriteLine("DEBUG TRAIT '{0}' CHILDREN '{1}'", trait.Name, string.Join(",", keys)); foreach (var key in keys) { var cleanKey = key.Trim().Substring(1); var child = Traits.FirstOrDefault(x => x.IDKey.Equals(Convert.ToInt32( cleanKey))); //fw.WriteLine("DEBUG TRAIT '{0}' KEY '{1}' CHILD '{2}'", trait.Name, cleanKey, child); if (child != null) { //fw.WriteLine("DEBUG FORMATTING CHILD '{2}'", trait.Name, cleanKey, child); builder.Append(FormatTrait(child, fw, childDepth + 1)); } } } } return builder.ToString(); }
string SkillFormatter(GCATrait trait, GCAWriter fw) { var builder = new StringBuilder(); builder.AppendFormat("{0} {1}:", trait.DisplayName, trait.get_TagItem("type")); var label = builder.ToString(); builder.Clear(); switch ((SkillType)int.Parse(trait.get_TagItem("sd"))) { case SkillType.Skill: string stepOff = trait.get_TagItem("stepoff"); if (!stepOff.Equals(string.Empty)) { builder.Append(stepOff); string step = trait.get_TagItem("step"); if (!step.Equals(string.Empty)) builder.Append(step); else builder.Append("?"); } else { builder.Append("?+?"); } builder.AppendFormat(" - {0}", trait.get_TagItem("level")); break; case SkillType.Technique: builder.AppendFormat(" - {0}", trait.get_TagItem("level")); break; case SkillType.Combo: builder.AppendFormat(" - {0}", trait.get_TagItem("combolevel")); break; default: break; } builder.AppendFormat(" [{0}]", trait.Points); return fw.FormatTrait(label, builder.ToString()); }
string EquipmentFormatter(GCATrait trait, GCAWriter fw) { var builder = new StringBuilder(); builder.Append(trait.DisplayName); var label = builder.ToString(); builder.Clear(); if (!string.IsNullOrEmpty(trait.NameExt) || trait.Mods.Count() > 0) builder.Append("("); if (!string.IsNullOrEmpty(trait.NameExt)) builder.Append(trait.NameExt); if (!string.IsNullOrEmpty(trait.NameExt) && trait.Mods.Count() > 0) builder.Append("; "); if (trait.Mods.Count() > 0) { var mods = new List<GCAModifier>(); foreach (GCAModifier item in trait.Mods) { mods.Add(item); } builder.Append(String.Join("; ", mods.Select(x => ModifierFormatter(x, fw)))); } if (!string.IsNullOrEmpty(trait.NameExt) || trait.Mods.Count() > 0) builder.Append(")"); if ( Convert.ToInt32( trait.get_TagItem("count")) > 1 ) { builder.AppendFormat(" {0} lbs, ${1} ×{2} = {3} lbs ${4}", trait.get_TagItem("precountweight"), trait.get_TagItem("precountcost"), trait.get_TagItem("count"), trait.get_TagItem("weight"), trait.get_TagItem("cost")); } else { builder.AppendFormat(" {0} lbs ${1}", trait.get_TagItem("weight"), trait.get_TagItem("cost")); } return fw.FormatTrait(label, builder.ToString()); }
void ExportAttributes(GCACharacter pc, GCAWriter fw) { fw.WriteHeader("Attributes [" + pc.get_Cost(modConstants.Stats) + "]"); var StatNames = new List<string> { "ST", "DX", "IQ", "HT"}; foreach (var item in ComplexListAttributes(StatNames, fw)) { fw.Write(item); } fw.WriteLine(); StatNames.Clear(); StatNames.AddRange(new string[] { "Hit Points", "Will", "Perception", "Fatigue Points"} ); foreach (var item in ComplexListAttributes(StatNames, fw)) { fw.Write(item); } fw.WriteLine(); }
/// <summary> /// Generates a SJG-formatted list of the specified trait type, visible traits only. /// This includes level, name extensions, and modifiers, but not "effective skill". /// </summary> /// <param name="traitType">Type of trait to harvest.</param> /// <returns>A semicolon separated, period-terminated list.</returns> string ComplexStringAdsDisads(TraitTypes traitType, GCAWriter fw) { var result = from trait in Traits where trait.ItemType == traitType where string.IsNullOrEmpty(trait.get_TagItem("hide")) select trait; return String.Join("; ", result.Select(x => AdvantageFormatter(x, fw))) + "."; }
void DoCharacterSeparator(int separatorOptionChoice, GCAWriter fw) { string separator = " "; switch ((CharacterSeparators)separatorOptionChoice) { case CharacterSeparators.DoNothing: break; case CharacterSeparators.PrintStars: separator = "*"; break; case CharacterSeparators.PrintEquals: separator = "="; break; case CharacterSeparators.PrintHyphens: separator = "-"; break; case CharacterSeparators.PrintHTMLHR: separator = "<hr/>"; break; } if (!Equals(separator, " ") && !Equals(separator, "<hr/>")) { fw.WriteLine(new String(separator.ToCharArray()[0], 60)); } else if (Equals(separator, "<hr/>")) { fw.WriteLine(separator); } fw.WriteLine(); }
IEnumerable<string> ComplexListTrait(TraitTypes traitType, GCAWriter fw) { var result = from trait in Traits where trait.ItemType == traitType where string.IsNullOrEmpty(trait.get_TagItem("hide")) select FormatTrait(trait, fw); return result; }
IEnumerable<string> ComplexListAttributes(List<string> attributeList, GCAWriter fw) { var result = from trait in Traits where trait.ItemType == TraitTypes.Attributes where attributeList.Contains( trait.Name ) //where !string.IsNullOrEmpty(trait.get_TagItem("mainwin")) //where !string.IsNullOrEmpty(trait.get_TagItem("display")) //where string.IsNullOrEmpty(trait.get_TagItem("hide")) orderby trait.get_TagItem("mainwin") select FormatTrait(trait, fw); return result; }
string AttributeFormatter(GCATrait trait, GCAWriter fw) { var builder = new StringBuilder(); builder.Append(trait.DisplayName); var label = builder.ToString(); builder.Clear(); builder.Append(trait.DisplayScore); builder.AppendFormat(" [{0}]", trait.Points); return fw.FormatTrait(label, builder.ToString()); }
void ExportReaction(GCACharacter pc, GCAWriter fw) { fw.WriteHeader("Reaction Modifiers"); fw.WriteLine(); }
void ExportBiography(GCACharacter CurChar, GCAWriter fw) { fw.WriteTrait("Name:", CurChar.Name); fw.WriteTrait("Player:", CurChar.Player); fw.WriteTrait("Race:", CurChar.Race); if (! string.IsNullOrEmpty( CurChar.Appearance)) fw.WriteTrait("Appearance: ", CurChar.Appearance); if (!string.IsNullOrEmpty(CurChar.Height)) fw.WriteTrait("Height:", CurChar.Height); if (!string.IsNullOrEmpty(CurChar.Weight)) fw.WriteTrait("Weight:", CurChar.Weight); if (!string.IsNullOrEmpty(CurChar.Age)) fw.WriteTrait("Age:", CurChar.Age); fw.WriteLine(""); }
void ExportSpells(GCACharacter pc, GCAWriter fw) { fw.WriteHeader("Spells [" + pc.get_Cost(modConstants.Spells) + "]"); foreach (var item in ComplexListTrait(TraitTypes.Spells, fw).Where(x => string.IsNullOrEmpty(x) != true)) { fw.Write(item); } fw.WriteLine(); }
void ExportCharacter(GCACharacter pc, GCAWriter fw) { this.Traits = new List<GCATrait>(); foreach (GCATrait item in pc.Items) { this.Traits.Add(item); } ExportBiography(pc, fw); ExportAttributes(pc, fw); ExportCultural(pc, fw); ExportReaction(pc, fw); ExportAdvantages(pc, fw); ExportPerks(pc, fw); ExportDisadvantages(pc, fw); ExportQuirks(pc, fw); ExportSkills(pc, fw); ExportSpells(pc, fw); ExportMeta(pc, fw); ExportPointsSummary(pc, fw); ExportEquiment(pc, fw); ExportCombat(pc, fw); ExportLoadout(pc, fw); }
string ModifierFormatter(GCAModifier trait, GCAWriter fw) { var builder = new StringBuilder(); builder.Append(trait.DisplayName.Trim()); if (!trait.get_TagItem("level").Equals("1") || !string.IsNullOrEmpty(trait.get_TagItem("upto")) || !string.IsNullOrEmpty(trait.LevelName())) // has more than one level or has named levels { builder.AppendFormat(" {0}", string.IsNullOrEmpty(trait.LevelName()) ? trait.get_TagItem("level") : trait.LevelName()); } builder.AppendFormat(", {0}", trait.get_TagItem("value")); return builder.ToString(); }
void ExportCombat(GCACharacter pc, GCAWriter fw) { fw.WriteLine(); }
string TemplateFormatter(GCATrait trait, GCAWriter fw) { return AdvantageFormatter(trait, fw); }
/// <summary> /// This creates the export file on disk. /// </summary> /// <param name="Party"></param> /// <param name="TargetFilename"></param> /// <param name="Options"></param> /// <returns></returns> bool IExportSheet.GenerateExport(Party Party, string TargetFilename, SheetOptionsManager Options) { MyOptions = Options; bool printMults = (int)MyOptions.get_Value("OutputCharacters") == 1; try { using (var fw = new GCAWriter(TargetFilename, false, MyOptions)) { if (Party.Characters.Count > 1 && printMults) foreach (GCACharacter pc in Party.Characters) { ExportCharacter(pc, fw); DoCharacterSeparator((int)MyOptions.get_Value("CharacterSeparator"), fw); } else ExportCharacter(Party.Current, fw); } } catch (Exception ex) { modHelperFunctions.Notify(Name + ": failed on export. " + ex.Message + "\n" + "Stack Trace: " + "\n" + ex.StackTrace, Priority.Red); } return true; }