public void BuildNPCFromEmbed(Embed embed) { foreach (var aspectField in embed.Fields.Where(fld => fld.Name == StarforgedNPCResources.Aspect)) { Aspects.Add(aspectField.Value); } foreach (var dispositionField in embed.Fields.Where(fld => fld.Name == StarforgedNPCResources.Disposition)) { Dispositions.Add(dispositionField.Value); } foreach (var firstLook in embed.Fields.Where(fld => fld.Name == StarforgedNPCResources.FirstLook)) { FirstLooks.Add(firstLook.Value); } foreach (var goal in embed.Fields.Where(fld => fld.Name == NPCResources.Goal)) { Goals.Add(goal.Value); } foreach (var role in embed.Fields.Where(fld => fld.Name == NPCResources.Role)) { Roles.Add(role.Value); } Name = embed.Fields.FirstOrDefault(fld => fld.Name == NPCResources.Name).Value; IconUrl = embed.Thumbnail.HasValue ? embed.Thumbnail.Value.Url : null; EmbedDesc = embed.Description; }
public INpcGenerator Build(string NPCCreationOptions) { //TODO fix the regex so it can support Role: role1 Role: role2 syntax Match AspectsRegex = Regex.Match(NPCCreationOptions, $"{StarforgedNPCResources.Aspect}[{NPCResources.ItemSeperators}]([\\w ,]*)"); Match DispositionRegex = Regex.Match(NPCCreationOptions, $"{StarforgedNPCResources.Disposition}[{NPCResources.ItemSeperators}]([\\w ,]*)"); Match FirstLookRegex = Regex.Match(NPCCreationOptions, $"{StarforgedNPCResources.FirstLook}[{NPCResources.ItemSeperators}]([\\w ,]*)"); Match RolesRegex = Regex.Match(NPCCreationOptions, $"{NPCResources.Role}[{NPCResources.ItemSeperators}]([\\w ,]*)"); Match GoalsRegex = Regex.Match(NPCCreationOptions, $"{NPCResources.Goal}[{NPCResources.ItemSeperators}]([\\w ,]*)"); if (AspectsRegex.Success) { Aspects = AspectsRegex.Groups[1].Value.Split(',').ToList(); NPCCreationOptions = NPCCreationOptions.Replace(AspectsRegex.Groups[0].Value, ""); } if (DispositionRegex.Success) { Dispositions = DispositionRegex.Groups[1].Value.Split(',').ToList(); NPCCreationOptions = NPCCreationOptions.Replace(DispositionRegex.Groups[0].Value, ""); } if (FirstLookRegex.Success) { FirstLooks = FirstLookRegex.Groups[1].Value.Split(',').ToList(); NPCCreationOptions = NPCCreationOptions.Replace(FirstLookRegex.Groups[0].Value, ""); } if (GoalsRegex.Success) { Goals = GoalsRegex.Groups[1].Value.Split(',').ToList(); NPCCreationOptions = NPCCreationOptions.Replace(GoalsRegex.Groups[0].Value, ""); } if (RolesRegex.Success) { Roles = RolesRegex.Groups[1].Value.Split(',').ToList(); NPCCreationOptions = NPCCreationOptions.Replace(RolesRegex.Groups[0].Value, ""); } var oracles = Services.GetRequiredService <OracleService>(); if (FirstLooks.Count == 0) { FirstLooks.Add(oracles.RandomOracleResult("Character First Look", Services, GameName.Starforged)); } //TODO make this starforged name when available Name = (NPCCreationOptions.Trim().Length > 0) ? NPCCreationOptions : oracles.RandomRow("Ironlander Names", GameName.Ironsworn).GetOracleResult(Services, GameName.Starforged); return(this); }