Работа с подклассами
This commit is contained in:
+87
@@ -0,0 +1,87 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Pf2eModel;
|
||||
using Pf2eModel.Model;
|
||||
using Pf2eModel.Model.Base;
|
||||
using Pf2eModel.Model.Common.I18n;
|
||||
using Pf2eModel.Model.Enum;
|
||||
using Pf2eModel.Model.Structure;
|
||||
|
||||
namespace Pf2eDataScrapper.Importers.Implementations.Aonprd.DataBuilder.Processors;
|
||||
|
||||
internal abstract class AbstractSubclassProcessor(AonprdProcessorInput input)
|
||||
: AbstractProcessor(input)
|
||||
{
|
||||
public override EntityType Type => EntityType.Subclass;
|
||||
|
||||
public abstract override Subclass Object { get; }
|
||||
|
||||
public abstract string? ClassName { get; }
|
||||
|
||||
public abstract string GroupName { get; }
|
||||
|
||||
protected override void Add() => Context.Subclasses.Add(Object);
|
||||
|
||||
public override void Process()
|
||||
{
|
||||
base.Process();
|
||||
|
||||
Object.Group = GetGroup();
|
||||
}
|
||||
|
||||
public abstract void ProcessObject();
|
||||
|
||||
public SubclassGroup GetGroup()
|
||||
{
|
||||
SubclassGroup? group = Context.SubclassGroups.FirstOrDefault(g =>
|
||||
Pf2eDbContext.LocaleSearch(g.Entity.Name, GroupName)
|
||||
);
|
||||
|
||||
if (group is null)
|
||||
{
|
||||
Class? cl =
|
||||
(ClassName is not null)
|
||||
? Context.Classes.FirstOrDefault(c =>
|
||||
Pf2eDbContext.LocaleSearch(c.Entity.Name, GroupName)
|
||||
)
|
||||
: null;
|
||||
|
||||
Entity groupEntity = new()
|
||||
{
|
||||
Id = Helper.NextEntityId,
|
||||
Type = EntityType.SubclassGroup,
|
||||
Img = "",
|
||||
Description = "",
|
||||
Rarity = EntityRarity.Common,
|
||||
IsTranslated = false,
|
||||
IsChecked = false,
|
||||
};
|
||||
|
||||
groupEntity.Name[LocaleType.English] = GroupName;
|
||||
groupEntity.Slug = Helper.GenerateSlug(GroupName);
|
||||
Context.Entities.Add(groupEntity);
|
||||
|
||||
/*
|
||||
|
||||
Entity.Id = Helper.NextEntityId;
|
||||
Entity.Type = Type;
|
||||
Entity.Name[LocaleType.English] = Input.GetRequired<string>("name");
|
||||
Entity.Img = "";
|
||||
Entity.Description = GetDescription();
|
||||
Entity.Rarity = Input.EnumOptional<EntityRarity>("rarity", EntityRarity.Common);
|
||||
Entity.Slug = Helper.GenerateSlug(Entity.Name[LocaleType.English]);
|
||||
Entity.IsTranslated = false;
|
||||
Entity.IsChecked = false;
|
||||
|
||||
*/
|
||||
|
||||
group = new SubclassGroup() { Entity = groupEntity, Class = cl };
|
||||
Context.SubclassGroups.Add(group);
|
||||
}
|
||||
|
||||
return group;
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Pf2eModel.Model.Structure;
|
||||
|
||||
namespace Pf2eDataScrapper.Importers.Implementations.Aonprd.DataBuilder.Processors.Subclasses;
|
||||
|
||||
[AonprdProcessor("apparition", ["class"])]
|
||||
internal class ApparitionProcessor(AonprdProcessorInput input) : AbstractSubclassProcessor(input)
|
||||
{
|
||||
public override Subclass Object { get; } = new();
|
||||
|
||||
public override string? ClassName => "Animist";
|
||||
|
||||
public override string GroupName => "Apparition";
|
||||
|
||||
public override void ProcessObject() { }
|
||||
|
||||
protected override string GetDescription() =>
|
||||
base.GetDescription()
|
||||
+ AddedDescription(["skill_markdown", "spell_markdown", "summary_markdown"]);
|
||||
}
|
||||
+1
-1
@@ -5,7 +5,7 @@ using Pf2eModel.Model.Structure;
|
||||
|
||||
namespace Pf2eDataScrapper.Importers.Implementations.Aonprd.DataBuilder.Processors.Types;
|
||||
|
||||
[AonprdProcessor("feat", ["trait", "source", "archetype"])]
|
||||
// [AonprdProcessor("feat", ["trait", "source", "archetype"])]
|
||||
internal class FeatProcessor(AonprdProcessorInput input) : AbstractProcessor(input)
|
||||
{
|
||||
public override EntityType Type => EntityType.Feat;
|
||||
|
||||
@@ -32,7 +32,4 @@
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Importers\Implementations\Aonprd\DataBuilder\Processors\Subclasses\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@@ -11,5 +11,5 @@ Pf2EFoundryImporter importer = new();
|
||||
|
||||
AonprdImporter importer = new();
|
||||
importer.Prepare();
|
||||
// importer.Import();
|
||||
importer.BuildSchemas();
|
||||
importer.Import();
|
||||
// importer.BuildSchemas();
|
||||
|
||||
Reference in New Issue
Block a user