Божествами на Фаундри
This commit is contained in:
+89
@@ -0,0 +1,89 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Pf2eDataScrapper.Helpers;
|
||||
using Pf2eDataScrapper.Importers.Implementations.FoundryEn.Helpers;
|
||||
using Pf2eDataScrapper.Processors;
|
||||
using Pf2eDataScrapper.Processors.Attributes;
|
||||
using Pf2eModel;
|
||||
using Pf2eModel.Model.Enum;
|
||||
using Pf2eModel.Model.Structure;
|
||||
using Pf2eModel.Model.Structure.DeityRelation;
|
||||
|
||||
namespace Pf2eDataScrapper.Importers.Implementations.FoundryEn.Processors.Entities;
|
||||
|
||||
[ProcessorCollection(
|
||||
"foundry-en:deity",
|
||||
InnerType = "deity",
|
||||
CompendiumType = ProcessorCompendiumEnum.FoundryEn,
|
||||
Description = "Божества",
|
||||
Group = ProcessorGroupEnum.FoundryEnEntities,
|
||||
Active = true
|
||||
)]
|
||||
[ProcessorDependencies(["foundry-en:compendium", "foundry-en:external"])]
|
||||
internal class DeityProcessor(
|
||||
DatabaseHelper databaseHelper,
|
||||
Pf2eDbContext context,
|
||||
FoundryEnGlobals globals,
|
||||
ProcessorInput input
|
||||
) : FoundryEnAbstractProcessor<Deity>(databaseHelper, context, globals, input)
|
||||
{
|
||||
public override EntityType Type => EntityType.Deity;
|
||||
|
||||
public override void Process()
|
||||
{
|
||||
base.Process();
|
||||
|
||||
ProcessSanctification();
|
||||
ProcessWeapons();
|
||||
}
|
||||
|
||||
private void ProcessSanctification()
|
||||
{
|
||||
JObject? sanctification = Input.GetOptional<JObject>("system.sanctification");
|
||||
if (sanctification == null)
|
||||
{
|
||||
Object.Sanctification = DeitySanctification.Any;
|
||||
Object.SanctificationMust = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
sanctification["what"] is not JArray sanctificationArray
|
||||
|| sanctificationArray.Count == 0
|
||||
|| sanctificationArray.Count == 2
|
||||
&& sanctificationArray.Any(t => t.ToString() == "holy")
|
||||
&& sanctificationArray.Any(t => t.ToString() == "unholy")
|
||||
)
|
||||
{
|
||||
Object.Sanctification = DeitySanctification.Any;
|
||||
}
|
||||
else if (sanctificationArray.Any(t => t.ToString() == "holy"))
|
||||
{
|
||||
Object.Sanctification = DeitySanctification.Holy;
|
||||
}
|
||||
else if (sanctificationArray.Any(t => t.ToString() == "unholy"))
|
||||
{
|
||||
Object.Sanctification = DeitySanctification.Unholy;
|
||||
}
|
||||
else
|
||||
{
|
||||
Object.Sanctification = DeitySanctification.Any;
|
||||
}
|
||||
|
||||
Object.SanctificationMust = sanctification["modal"]?.ToString() == "must";
|
||||
}
|
||||
|
||||
private void ProcessWeapons()
|
||||
{
|
||||
List<string> weapons = Input
|
||||
.GetRequired<JArray>("system.weapons")
|
||||
.Select(token => token.ToString())
|
||||
.ToList();
|
||||
|
||||
foreach (string weapon in weapons)
|
||||
{
|
||||
Object.DeityWeapons.Add(new() { DeityId = Object.Id, Weapon = weapon });
|
||||
}
|
||||
}
|
||||
}
|
||||
+14
-10
@@ -126,22 +126,26 @@ internal abstract class FoundryEnAbstractProcessor<TEntity>(
|
||||
return entities[0].Id;
|
||||
}
|
||||
|
||||
List<string> inputTraits = Input
|
||||
.GetRequired<JArray>("system.traits.value")
|
||||
.Select(token => token.ToString())
|
||||
.Order()
|
||||
.ToList();
|
||||
JArray? traitArray = Input.GetOptional<JArray>("system.traits.value");
|
||||
|
||||
foreach (Entity entity in entities)
|
||||
if (traitArray is not null)
|
||||
{
|
||||
List<string> entityTraits = entity
|
||||
.Traits.Select(t => t.Entity.Name[LocaleType.English])
|
||||
List<string> inputTraits = traitArray
|
||||
.Select(token => token.ToString())
|
||||
.Order()
|
||||
.ToList();
|
||||
|
||||
if (entityTraits.SequenceEqual(inputTraits))
|
||||
foreach (Entity entity in entities)
|
||||
{
|
||||
return entity.Id;
|
||||
List<string> entityTraits = entity
|
||||
.Traits.Select(t => t.Entity.Name[LocaleType.English])
|
||||
.Order()
|
||||
.ToList();
|
||||
|
||||
if (entityTraits.SequenceEqual(inputTraits))
|
||||
{
|
||||
return entity.Id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user