Отчистка кода
This commit is contained in:
+42
-31
@@ -1,35 +1,42 @@
|
||||
using Pf2eModel.Model.Enum;
|
||||
|
||||
namespace Pf2eDataScrapper.Importers.Implementations.Aonprd.DataBuilder;
|
||||
|
||||
public static class AonprdEnumResolver
|
||||
{
|
||||
private static readonly ICollection<Solver> Solvers = [
|
||||
new Solver<SourceCategory>(new()
|
||||
{
|
||||
{ "Rulebooks", SourceCategory.Rulebooks },
|
||||
{ "Adventure Paths", SourceCategory.AdventurePaths },
|
||||
{ "Lost Omens", SourceCategory.LostOmens },
|
||||
{ "Adventures", SourceCategory.Adventures },
|
||||
{ "Comics", SourceCategory.Comics },
|
||||
{ "Blog Posts", SourceCategory.BlogPosts },
|
||||
{ "Society", SourceCategory.Society },
|
||||
}),
|
||||
|
||||
new Solver<AncestryVision>(new()
|
||||
{
|
||||
{ "Low-Light Vision", AncestryVision.LowLightVision },
|
||||
{ "Darkvision", AncestryVision.DarkVision },
|
||||
}),
|
||||
|
||||
new Solver<AttributeValues>(new()
|
||||
{
|
||||
{ "Consitution", AttributeValues.Constitution },
|
||||
{ "Other", AttributeValues.Free },
|
||||
{ "other", AttributeValues.Free },
|
||||
})
|
||||
private static readonly ICollection<Solver> Solvers =
|
||||
[
|
||||
new Solver<SourceCategory>(
|
||||
new()
|
||||
{
|
||||
{ "Rulebooks", SourceCategory.Rulebooks },
|
||||
{ "Adventure Paths", SourceCategory.AdventurePaths },
|
||||
{ "Lost Omens", SourceCategory.LostOmens },
|
||||
{ "Adventures", SourceCategory.Adventures },
|
||||
{ "Comics", SourceCategory.Comics },
|
||||
{ "Blog Posts", SourceCategory.BlogPosts },
|
||||
{ "Society", SourceCategory.Society },
|
||||
}
|
||||
),
|
||||
new Solver<AncestryVision>(
|
||||
new()
|
||||
{
|
||||
{ "Low-Light Vision", AncestryVision.LowLightVision },
|
||||
{ "Darkvision", AncestryVision.DarkVision },
|
||||
}
|
||||
),
|
||||
new Solver<AttributeValues>(
|
||||
new()
|
||||
{
|
||||
{ "Consitution", AttributeValues.Constitution },
|
||||
{ "Other", AttributeValues.Free },
|
||||
{ "other", AttributeValues.Free },
|
||||
}
|
||||
),
|
||||
];
|
||||
|
||||
public static T Resolve<T>(string value) where T : Enum
|
||||
public static T Resolve<T>(string value)
|
||||
where T : Enum
|
||||
{
|
||||
Type type = typeof(T);
|
||||
|
||||
@@ -40,9 +47,11 @@ public static class AonprdEnumResolver
|
||||
throw new EnumResolverEnumUnknownException(type);
|
||||
}
|
||||
|
||||
Solver<T> tSolver = (Solver<T>) solver;
|
||||
Solver<T> tSolver = (Solver<T>)solver;
|
||||
|
||||
return tSolver.Data.TryGetValue(value, out T? data) ? data : throw new EnumResolverValueUnknownException(type, value);
|
||||
return tSolver.Data.TryGetValue(value, out T? data)
|
||||
? data
|
||||
: throw new EnumResolverValueUnknownException(type, value);
|
||||
}
|
||||
|
||||
private abstract class Solver
|
||||
@@ -50,14 +59,16 @@ public static class AonprdEnumResolver
|
||||
public abstract Type Type { get; }
|
||||
}
|
||||
|
||||
private class Solver<T>(Dictionary<string, T> data) : Solver where T : Enum
|
||||
private class Solver<T>(Dictionary<string, T> data) : Solver
|
||||
where T : Enum
|
||||
{
|
||||
public override Type Type { get; } = typeof(T);
|
||||
public Dictionary<string, T> Data { get; } = data;
|
||||
}
|
||||
|
||||
public class EnumResolverEnumUnknownException(Type t) : Exception($"Can't resolve type '{t.FullName}': Solver not defined");
|
||||
|
||||
public class EnumResolverValueUnknownException(Type t, string value) : Exception($"Can't resolve type '{t.FullName}': Value '{value}' is not matched");
|
||||
public class EnumResolverEnumUnknownException(Type t)
|
||||
: Exception($"Can't resolve type '{t.FullName}': Solver not defined");
|
||||
|
||||
public class EnumResolverValueUnknownException(Type t, string value)
|
||||
: Exception($"Can't resolve type '{t.FullName}': Value '{value}' is not matched");
|
||||
}
|
||||
|
||||
+21
-17
@@ -1,4 +1,6 @@
|
||||
using LinqToDB.Reflection;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
@@ -10,10 +12,6 @@ using Pf2eModel.Model.Base.Targets;
|
||||
using Pf2eModel.Model.Common.I18n;
|
||||
using Pf2eModel.Model.Enum;
|
||||
using Pf2eModel.Model.Structure;
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Pf2eDataScrapper.Importers.Implementations.Aonprd.DataBuilder.Processors;
|
||||
|
||||
@@ -32,7 +30,7 @@ internal abstract partial class AbstractProcessor(AonprdProcessorInput input)
|
||||
public abstract IEntity Object { get; }
|
||||
|
||||
protected abstract void Add();
|
||||
|
||||
|
||||
public virtual void Process()
|
||||
{
|
||||
if (Input.GetOptional<JArray>("remaster_id") is not null)
|
||||
@@ -57,9 +55,11 @@ internal abstract partial class AbstractProcessor(AonprdProcessorInput input)
|
||||
Context.SaveChanges();
|
||||
}
|
||||
|
||||
protected string AddedDescription(string path) => $"\r\n\r\n========== [{path}] ==========\r\n\r\n{Input.GetOptional<string>(path) ?? ""}";
|
||||
protected string AddedDescription(string path) =>
|
||||
$"\r\n\r\n========== [{path}] ==========\r\n\r\n{Input.GetOptional<string>(path) ?? ""}";
|
||||
|
||||
protected string AddedDescription(string[] paths) => string.Join("", paths.Select(AddedDescription));
|
||||
protected string AddedDescription(string[] paths) =>
|
||||
string.Join("", paths.Select(AddedDescription));
|
||||
|
||||
protected virtual string GetDescription() => Input.GetRequired<string>("markdown");
|
||||
|
||||
@@ -130,7 +130,7 @@ internal abstract partial class AbstractProcessor(AonprdProcessorInput input)
|
||||
Entity = Entity,
|
||||
Source = source,
|
||||
Suffix = ((match?.Captures.Count > 0) ? match?.Captures[0]?.Value : "") ?? "",
|
||||
IsRemaster = Input.GetOptional<JArray>("legacy_id") is not null
|
||||
IsRemaster = Input.GetOptional<JArray>("legacy_id") is not null,
|
||||
};
|
||||
|
||||
Context.EntitySources.Add(entitySource);
|
||||
@@ -140,7 +140,9 @@ internal abstract partial class AbstractProcessor(AonprdProcessorInput input)
|
||||
{
|
||||
if (AonprdTarget is null)
|
||||
{
|
||||
AonprdTarget = Context.ExternalTargets.FirstOrDefault(t => t.Name == AonprdImporter.SourceName);
|
||||
AonprdTarget = Context.ExternalTargets.FirstOrDefault(t =>
|
||||
t.Name == AonprdImporter.SourceName
|
||||
);
|
||||
|
||||
AonprdTarget ??= new()
|
||||
{
|
||||
@@ -155,7 +157,7 @@ internal abstract partial class AbstractProcessor(AonprdProcessorInput input)
|
||||
Entity = Entity,
|
||||
Target = AonprdTarget,
|
||||
Suffix = Input.GetRequired<string>("url"),
|
||||
Md5 = Md5(Input.Input.ToString())
|
||||
Md5 = Md5(Input.Input.ToString()),
|
||||
};
|
||||
Context.EntityExternals.Add(external);
|
||||
}
|
||||
@@ -170,13 +172,13 @@ internal abstract partial class AbstractProcessor(AonprdProcessorInput input)
|
||||
}
|
||||
|
||||
IEnumerable<string> names = traitsJson.ToArray().Select(jToken => jToken.ToString());
|
||||
List<Entity> traitEntities = Context.Traits
|
||||
.Select(t => t.Entity)
|
||||
List<Entity> traitEntities = Context
|
||||
.Traits.Select(t => t.Entity)
|
||||
.Where(e => Pf2eDbContext.LocaleSearchArray(e.Name, names))
|
||||
.ToList();
|
||||
|
||||
List<Trait> traits = Context.Traits
|
||||
.Include(t => t.Entity)
|
||||
List<Trait> traits = Context
|
||||
.Traits.Include(t => t.Entity)
|
||||
.Where(t => traitEntities.Contains(t.Entity))
|
||||
.ToList();
|
||||
|
||||
@@ -238,7 +240,9 @@ internal abstract partial class AbstractProcessor(AonprdProcessorInput input)
|
||||
[GeneratedRegex(@"^\[.*?\]\(.*?\)\s+(.*)$")]
|
||||
private static partial Regex SourceSuffixRegex();
|
||||
|
||||
public class LegacyItemException(string name) : Exception($"Item '{name}' is linked with newer version, skipping.") { }
|
||||
public class LegacyItemException(string name)
|
||||
: Exception($"Item '{name}' is linked with newer version, skipping.") { }
|
||||
|
||||
public class SkipItemException(string name, string reason) : Exception($"Item '{name}' is skipped, reason: {reason}.") { }
|
||||
public class SkipItemException(string name, string reason)
|
||||
: Exception($"Item '{name}' is skipped, reason: {reason}.") { }
|
||||
}
|
||||
|
||||
+18
-15
@@ -1,6 +1,4 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Pf2eModel.Model;
|
||||
using Pf2eModel.Model.Enum;
|
||||
using Pf2eModel.Model.Enum;
|
||||
|
||||
namespace Pf2eDataScrapper.Importers.Implementations.Aonprd.DataBuilder.Processors.Types;
|
||||
|
||||
@@ -17,25 +15,30 @@ internal class ActionProcessor(AonprdProcessorInput input) : AbstractProcessor(i
|
||||
{
|
||||
base.Process();
|
||||
|
||||
AonprdProcessorInput.ActionStruct action = Input.ResolveActionString(Input.GetOptional<string>("actions") ?? "");
|
||||
AonprdProcessorInput.ActionStruct action = Input.ResolveActionString(
|
||||
Input.GetOptional<string>("actions") ?? ""
|
||||
);
|
||||
|
||||
Object.Actions = action.Actions;
|
||||
Object.MaxActions = action.MaxActions;
|
||||
Object.IsFreeAction = action.IsFreeAction;
|
||||
Object.IsPassive = action.IsPassive;
|
||||
Object.IsReaction = action.IsReaction;
|
||||
;
|
||||
;
|
||||
Object.Extra = GenerateExtra("school");
|
||||
}
|
||||
|
||||
protected override string GetDescription()
|
||||
=> base.GetDescription() + AddedDescription([
|
||||
"cost_markdown",
|
||||
"trait_markdown",
|
||||
"source_markdown",
|
||||
"search_markdown",
|
||||
"requirement_markdown",
|
||||
"trigger_markdown",
|
||||
"summary_markdown",
|
||||
]);
|
||||
protected override string GetDescription() =>
|
||||
base.GetDescription()
|
||||
+ AddedDescription(
|
||||
[
|
||||
"cost_markdown",
|
||||
"trait_markdown",
|
||||
"source_markdown",
|
||||
"search_markdown",
|
||||
"requirement_markdown",
|
||||
"trigger_markdown",
|
||||
"summary_markdown",
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
+8
-7
@@ -1,10 +1,8 @@
|
||||
using LinqToDB;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Pf2eModel.Model;
|
||||
using Pf2eModel.Model.Enum;
|
||||
using Pf2eModel.Model.Structure;
|
||||
using Pf2eModel.Model.Structure.AncestryRelation;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Pf2eDataScrapper.Importers.Implementations.Aonprd.DataBuilder.Processors.Types;
|
||||
|
||||
@@ -28,8 +26,11 @@ internal class AncestryProcessor(AonprdProcessorInput input) : AbstractProcessor
|
||||
|
||||
base.Process();
|
||||
|
||||
Object.Size = Input.GetRequired<JArray>("size").Select(t => Input.Enum<Size>(t.ToString())).ToArray();
|
||||
|
||||
Object.Size = Input
|
||||
.GetRequired<JArray>("size")
|
||||
.Select(t => Input.Enum<Size>(t.ToString()))
|
||||
.ToArray();
|
||||
|
||||
string hp = Input.GetRequired<string>("hp_raw");
|
||||
Object.Hp = Convert.ToInt32((hp != "") ? hp : "0");
|
||||
|
||||
@@ -46,7 +47,8 @@ internal class AncestryProcessor(AonprdProcessorInput input) : AbstractProcessor
|
||||
|
||||
protected void AddBoosts(string path, bool isBoost)
|
||||
{
|
||||
List<string> boosts = Input.GetOptional<JArray>(path)?.ToArray().Select(t => t.ToString()).ToList() ?? [];
|
||||
List<string> boosts =
|
||||
Input.GetOptional<JArray>(path)?.ToArray().Select(t => t.ToString()).ToList() ?? [];
|
||||
|
||||
if (boosts.Contains("Two free ability boosts"))
|
||||
{
|
||||
@@ -67,5 +69,4 @@ internal class AncestryProcessor(AonprdProcessorInput input) : AbstractProcessor
|
||||
Context.AncestryBoosts.Add(ancestryBoost);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+3
-12
@@ -1,10 +1,5 @@
|
||||
using Pf2eModel.Model.Enum;
|
||||
using Pf2eModel.Model.Structure;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Pf2eDataScrapper.Importers.Implementations.Aonprd.DataBuilder.Processors.Types;
|
||||
|
||||
@@ -22,13 +17,9 @@ internal class ArchetypeProcessor(AonprdProcessorInput input) : AbstractProcesso
|
||||
base.Process();
|
||||
|
||||
Object.Level = Input.GetOptional<int>("level");
|
||||
|
||||
}
|
||||
|
||||
protected override string GetDescription()
|
||||
=> base.GetDescription() + AddedDescription([
|
||||
"prerequisite_markdown",
|
||||
"requirement_markdown",
|
||||
"summary_markdown"
|
||||
]);
|
||||
protected override string GetDescription() =>
|
||||
base.GetDescription()
|
||||
+ AddedDescription(["prerequisite_markdown", "requirement_markdown", "summary_markdown"]);
|
||||
}
|
||||
|
||||
+6
-17
@@ -1,13 +1,7 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Pf2eModel.Model;
|
||||
using Pf2eModel.Model.Enum;
|
||||
using Pf2eModel.Model.Structure;
|
||||
using Pf2eModel.Model.Structure.BackgroundRelation;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Pf2eDataScrapper.Importers.Implementations.Aonprd.DataBuilder.Processors.Types;
|
||||
|
||||
@@ -29,22 +23,17 @@ internal class BackgroundProcessor(AonprdProcessorInput input) : AbstractProcess
|
||||
BackgroundBoost boost = new()
|
||||
{
|
||||
Background = Object,
|
||||
Attribute = Input.Enum<AttributeValues>(token.ToString())
|
||||
Attribute = Input.Enum<AttributeValues>(token.ToString()),
|
||||
};
|
||||
|
||||
Object.BackgroundBoosts.Add(boost);
|
||||
Context.BackgroundBoosts.Add(boost);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected override string GetDescription()
|
||||
=> base.GetDescription() + AddedDescription([
|
||||
"feat_markdown",
|
||||
"summary_markdown",
|
||||
"skill_markdown",
|
||||
"prerequisite_markdown",
|
||||
]);
|
||||
protected override string GetDescription() =>
|
||||
base.GetDescription()
|
||||
+ AddedDescription(
|
||||
["feat_markdown", "summary_markdown", "skill_markdown", "prerequisite_markdown"]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+57
-58
@@ -1,18 +1,11 @@
|
||||
using LinqToDB;
|
||||
using System.Text.RegularExpressions;
|
||||
using LinqToDB;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Pf2eModel.Model;
|
||||
using Pf2eModel.Model.Common;
|
||||
using Pf2eModel.Model.Enum;
|
||||
using Pf2eModel.Model.Structure;
|
||||
using Pf2eModel.Model.Structure.ClassRelation;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Pf2eDataScrapper.Importers.Implementations.Aonprd.DataBuilder.Processors.Types;
|
||||
|
||||
@@ -28,10 +21,11 @@ internal class ClassProcessor(AonprdProcessorInput input) : AbstractProcessor(in
|
||||
public override void Process()
|
||||
{
|
||||
base.Process();
|
||||
|
||||
|
||||
Object.Hp = Convert.ToInt32(Input.GetRequired<string>("hp_raw"));
|
||||
|
||||
AttributeValues[] attributes = Input.GetRequired<JArray>("attribute")
|
||||
AttributeValues[] attributes = Input
|
||||
.GetRequired<JArray>("attribute")
|
||||
.Select(token => Input.Enum<AttributeValues>(token.ToString()))
|
||||
.ToArray();
|
||||
|
||||
@@ -39,18 +33,24 @@ internal class ClassProcessor(AonprdProcessorInput input) : AbstractProcessor(in
|
||||
{
|
||||
ClassKeyAbility classKeyAbility = new ClassKeyAbility()
|
||||
{
|
||||
Class = Object,
|
||||
Value = attribute
|
||||
Class = Object,
|
||||
Value = attribute,
|
||||
};
|
||||
|
||||
Context.ClassKeyAbilities.Add(classKeyAbility);
|
||||
Object.ClassKeyAbilities.Add(classKeyAbility);
|
||||
}
|
||||
|
||||
|
||||
ClassTraining[] classTrainings =
|
||||
[
|
||||
.. ProcessTraining(Input.GetRequired<JArray>("attack_proficiency"), TrainingType.Weapon),
|
||||
.. ProcessTraining(Input.GetRequired<JArray>("defense_proficiency"), TrainingType.Armor),
|
||||
.. ProcessTraining(
|
||||
Input.GetRequired<JArray>("attack_proficiency"),
|
||||
TrainingType.Weapon
|
||||
),
|
||||
.. ProcessTraining(
|
||||
Input.GetRequired<JArray>("defense_proficiency"),
|
||||
TrainingType.Armor
|
||||
),
|
||||
.. GetSkillTrainings(),
|
||||
.. GetSaveTrainings(),
|
||||
];
|
||||
@@ -84,19 +84,22 @@ internal class ClassProcessor(AonprdProcessorInput input) : AbstractProcessor(in
|
||||
|
||||
protected ICollection<ClassTraining> GetSkillTrainings()
|
||||
{
|
||||
string[] skillNames = Input.GetRequired<JArray>("skill_proficiency")
|
||||
string[] skillNames = Input
|
||||
.GetRequired<JArray>("skill_proficiency")
|
||||
.Select(token => token.ToString())
|
||||
.ToArray();
|
||||
|
||||
Training[] skills = Context.Trainings.Where(t => skillNames.Contains(t.Name)).ToArray();
|
||||
// Training[] skills = Context.Trainings.Where(t => Pf2eDbContext.LocaleSearchArray(t.Name, skillNames)).ToArray();
|
||||
|
||||
return skills.Select(skill => new ClassTraining()
|
||||
{
|
||||
Class = Object,
|
||||
Training = skill,
|
||||
Stage = TrainingStage.Trained,
|
||||
}).ToArray();
|
||||
return skills
|
||||
.Select(skill => new ClassTraining()
|
||||
{
|
||||
Class = Object,
|
||||
Training = skill,
|
||||
Stage = TrainingStage.Trained,
|
||||
})
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
protected ICollection<ClassTraining> ProcessTraining(JArray array, TrainingType type)
|
||||
@@ -119,16 +122,13 @@ internal class ClassProcessor(AonprdProcessorInput input) : AbstractProcessor(in
|
||||
|
||||
foreach (string part in parts)
|
||||
{
|
||||
Training? training = Context.Trainings
|
||||
.FirstOrDefault(t => t.Name == part && t.Type == type);
|
||||
Training? training = Context.Trainings.FirstOrDefault(t =>
|
||||
t.Name == part && t.Type == type
|
||||
);
|
||||
|
||||
if (training == null)
|
||||
{
|
||||
training = new Training()
|
||||
{
|
||||
Name = part,
|
||||
Type = type,
|
||||
};
|
||||
training = new Training() { Name = part, Type = type };
|
||||
|
||||
Context.Trainings.Add(training);
|
||||
}
|
||||
@@ -137,7 +137,7 @@ internal class ClassProcessor(AonprdProcessorInput input) : AbstractProcessor(in
|
||||
{
|
||||
Class = Object,
|
||||
Training = training,
|
||||
Stage = stage
|
||||
Stage = stage,
|
||||
};
|
||||
|
||||
trainings.Add(classTraining);
|
||||
@@ -149,27 +149,20 @@ internal class ClassProcessor(AonprdProcessorInput input) : AbstractProcessor(in
|
||||
|
||||
protected string[] GetTrainingString(string value)
|
||||
{
|
||||
if (value.StartsWith("favored weapon of your deity"))
|
||||
{
|
||||
return ["Favored weapon of your deity"];
|
||||
}
|
||||
|
||||
if (value == "simple and martial weapons")
|
||||
{
|
||||
return ["Simple weapon", "Martial weapon"];
|
||||
}
|
||||
|
||||
return Regex.Split(value, @"\s*(?:,|and)\s*")
|
||||
.Where(s => s != "")
|
||||
.Select(s => string.Concat(s[0].ToString().ToUpper(), s.AsSpan(1)))
|
||||
.ToArray();
|
||||
;
|
||||
return value.StartsWith("favored weapon of your deity") ? ["Favored weapon of your deity"]
|
||||
: value == "simple and martial weapons" ? ["Simple weapon", "Martial weapon"]
|
||||
: Regex
|
||||
.Split(value, @"\s*(?:,|and)\s*")
|
||||
.Where(s => s != "")
|
||||
.Select(s => string.Concat(s[0].ToString().ToUpper(), s.AsSpan(1)))
|
||||
.ToArray();
|
||||
;
|
||||
}
|
||||
|
||||
protected ICollection<ClassTraining> GetSaveTrainings()
|
||||
{
|
||||
Dictionary<string, Training> result = Context.Trainings
|
||||
.Where(t => t.Type == TrainingType.Save)
|
||||
Dictionary<string, Training> result = Context
|
||||
.Trainings.Where(t => t.Type == TrainingType.Save)
|
||||
.ToDictionary(t => t.Name);
|
||||
|
||||
foreach (string name in new[] { "Will", "Fortitude", "Reflex", "Perception" })
|
||||
@@ -179,23 +172,29 @@ internal class ClassProcessor(AonprdProcessorInput input) : AbstractProcessor(in
|
||||
continue;
|
||||
}
|
||||
|
||||
Training training = new() { Name = name, Type = (name == "Perception") ? TrainingType.Perception : TrainingType.Save };
|
||||
Training training = new()
|
||||
{
|
||||
Name = name,
|
||||
Type = (name == "Perception") ? TrainingType.Perception : TrainingType.Save,
|
||||
};
|
||||
|
||||
result.Add(name, training);
|
||||
Context.Trainings.Add(training);
|
||||
}
|
||||
|
||||
return result.Select(pair =>
|
||||
{
|
||||
ClassTraining classTraining = new()
|
||||
return result
|
||||
.Select(pair =>
|
||||
{
|
||||
Class = Object,
|
||||
Training = pair.Value,
|
||||
Stage = Input.EnumRequired<TrainingStage>($"{pair.Key.ToLower()}_proficiency"),
|
||||
};
|
||||
ClassTraining classTraining = new()
|
||||
{
|
||||
Class = Object,
|
||||
Training = pair.Value,
|
||||
Stage = Input.EnumRequired<TrainingStage>($"{pair.Key.ToLower()}_proficiency"),
|
||||
};
|
||||
|
||||
return classTraining;
|
||||
}).ToList();
|
||||
return classTraining;
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
|
||||
protected void ProcessDependecies()
|
||||
|
||||
+23
-17
@@ -20,11 +20,13 @@ internal class FeatProcessor(AonprdProcessorInput input) : AbstractProcessor(inp
|
||||
|
||||
Object.Level = Input.GetRequired<int>("level");
|
||||
|
||||
Object.Category = (Entity.Traits.Any(t => t.Type == TraitType.Class))
|
||||
? ActionCategory.ClassFeat
|
||||
Object.Category = Entity.Traits.Any(t => t.Type == TraitType.Class)
|
||||
? ActionCategory.ClassFeat
|
||||
: ActionCategory.Unknown;
|
||||
|
||||
AonprdProcessorInput.ActionStruct action = Input.ResolveActionString(Input.GetOptional<string>("actions") ?? "");
|
||||
AonprdProcessorInput.ActionStruct action = Input.ResolveActionString(
|
||||
Input.GetOptional<string>("actions") ?? ""
|
||||
);
|
||||
Object.Actions = action.Actions;
|
||||
Object.MaxActions = action.MaxActions;
|
||||
Object.IsFreeAction = action.IsFreeAction;
|
||||
@@ -39,12 +41,13 @@ internal class FeatProcessor(AonprdProcessorInput input) : AbstractProcessor(inp
|
||||
"heighten_level",
|
||||
"school",
|
||||
"frequency"
|
||||
);
|
||||
);
|
||||
|
||||
string[] archetypeStrings = Input.GetOptional<JArray>("archetype")?.Select(t => t.ToString()).ToArray() ?? [];
|
||||
string[] archetypeStrings =
|
||||
Input.GetOptional<JArray>("archetype")?.Select(t => t.ToString()).ToArray() ?? [];
|
||||
|
||||
var archetypes = Context.Archetypes
|
||||
.Where(a => Pf2eDbContext.LocaleSearchArray(a.Entity.Name, archetypeStrings))
|
||||
Archetype[] archetypes = Context
|
||||
.Archetypes.Where(a => Pf2eDbContext.LocaleSearchArray(a.Entity.Name, archetypeStrings))
|
||||
// .Where(a => archetypeStrings.Contains(a.Entity.Name.ToString()))
|
||||
.ToArray();
|
||||
|
||||
@@ -53,7 +56,7 @@ internal class FeatProcessor(AonprdProcessorInput input) : AbstractProcessor(inp
|
||||
Object.Category = ActionCategory.Archetype;
|
||||
}
|
||||
|
||||
foreach (var archetype in archetypes)
|
||||
foreach (Archetype? archetype in archetypes)
|
||||
{
|
||||
Object.Archetypes.Add(archetype);
|
||||
|
||||
@@ -64,13 +67,16 @@ internal class FeatProcessor(AonprdProcessorInput input) : AbstractProcessor(inp
|
||||
}
|
||||
}
|
||||
|
||||
protected override string GetDescription()
|
||||
=> base.GetDescription() + AddedDescription([
|
||||
"cost_markdown",
|
||||
"feat_markdown",
|
||||
"summary_markdown",
|
||||
"prerequisite_markdown",
|
||||
"requirement_markdown",
|
||||
"trigger_markdown"
|
||||
]);
|
||||
protected override string GetDescription() =>
|
||||
base.GetDescription()
|
||||
+ AddedDescription(
|
||||
[
|
||||
"cost_markdown",
|
||||
"feat_markdown",
|
||||
"summary_markdown",
|
||||
"prerequisite_markdown",
|
||||
"requirement_markdown",
|
||||
"trigger_markdown",
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
+2
-8
@@ -1,12 +1,6 @@
|
||||
using Pf2eDataScrapper.Importers.Implementations.Aonprd.DataBuilder;
|
||||
using Pf2eModel.Model;
|
||||
using Pf2eModel.Model;
|
||||
using Pf2eModel.Model.Base.Source;
|
||||
using Pf2eModel.Model.Enum;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Pf2eDataScrapper.Importers.Implementations.Aonprd.DataBuilder.Processors.Types;
|
||||
|
||||
@@ -15,7 +9,7 @@ internal class SourceProcessor(AonprdProcessorInput input) : AbstractProcessor(i
|
||||
{
|
||||
public override EntityType Type => EntityType.Unknown;
|
||||
|
||||
public override IEntity Object => null;
|
||||
public override IEntity? Object => null;
|
||||
|
||||
protected override void Add() { }
|
||||
|
||||
|
||||
+3
-9
@@ -1,12 +1,6 @@
|
||||
using Pf2eModel.Model.Base.Source;
|
||||
using Pf2eModel.Model.Enum;
|
||||
using Pf2eModel.Model;
|
||||
using Pf2eModel.Model;
|
||||
using Pf2eModel.Model.Common;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Pf2eModel.Model.Enum;
|
||||
|
||||
namespace Pf2eDataScrapper.Importers.Implementations.Aonprd.DataBuilder.Processors.Types;
|
||||
|
||||
@@ -15,7 +9,7 @@ internal class TrainingProcessor(AonprdProcessorInput input) : AbstractProcessor
|
||||
{
|
||||
public override EntityType Type => EntityType.Unknown;
|
||||
|
||||
public override IEntity Object => null;
|
||||
public override IEntity? Object => null;
|
||||
|
||||
protected override void Add() { }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user