Глобальное обновление #1
+44
-8
@@ -1,5 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Pf2eDataScrapper.Helpers;
|
using Pf2eDataScrapper.Helpers;
|
||||||
using Pf2eDataScrapper.Importers.Implementations.Aonprd.Helpers;
|
using Pf2eDataScrapper.Importers.Implementations.Aonprd.Helpers;
|
||||||
using Pf2eDataScrapper.Processors;
|
using Pf2eDataScrapper.Processors;
|
||||||
@@ -25,7 +27,7 @@ namespace Pf2eDataScrapper.Importers.Implementations.Aonprd.Processors.Subclasse
|
|||||||
[ProcessorDependencies(
|
[ProcessorDependencies(
|
||||||
["aonprd:trait", "aonprd:source", "aonprd:class", "aonprd:spell", "aonprd:skill"]
|
["aonprd:trait", "aonprd:source", "aonprd:class", "aonprd:spell", "aonprd:skill"]
|
||||||
)]
|
)]
|
||||||
internal class ApparitionProcessor(
|
internal partial class ApparitionProcessor(
|
||||||
ProcessorInput input,
|
ProcessorInput input,
|
||||||
StringHelper stringHelper,
|
StringHelper stringHelper,
|
||||||
DatabaseHelper helper,
|
DatabaseHelper helper,
|
||||||
@@ -44,8 +46,17 @@ internal class ApparitionProcessor(
|
|||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override void ProcessObject()
|
public override void ProcessObject()
|
||||||
{
|
{
|
||||||
// Spells
|
AddSpells(Input.GetRequired<string>("spell_markdown"));
|
||||||
string spellMd = Input.GetRequired<string>("spell_markdown");
|
AddFocal(Entity.Description);
|
||||||
|
AddTrainings(Input.GetRequired<string>("skill_markdown"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление заклинаний.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="spellMd"></param>
|
||||||
|
public void AddSpells(string spellMd)
|
||||||
|
{
|
||||||
List<string> spellUrls = StringHelper
|
List<string> spellUrls = StringHelper
|
||||||
.ParseMarkdownLinks(spellMd)
|
.ParseMarkdownLinks(spellMd)
|
||||||
.Links.Select(l => l.Url)
|
.Links.Select(l => l.Url)
|
||||||
@@ -65,10 +76,32 @@ internal class ApparitionProcessor(
|
|||||||
{
|
{
|
||||||
Object.Entities.Add(spellEntity);
|
Object.Entities.Add(spellEntity);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Trainings
|
/// <summary>
|
||||||
string trainingMd = Input.GetRequired<string>("skill_markdown");
|
/// Добавление заклинания сосуда.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="description"></param>
|
||||||
|
public void AddFocal(string description)
|
||||||
|
{
|
||||||
|
Match match = VesselSpellMarkdownRegex().Match(description);
|
||||||
|
string aonprdId = $"spell-{match.Groups[1].Value}";
|
||||||
|
|
||||||
|
var entity = Context
|
||||||
|
.EntityExternals.AsNoTracking()
|
||||||
|
.Where(x => x.ExternalId == aonprdId)
|
||||||
|
.Select(x => x.Entity)
|
||||||
|
.First();
|
||||||
|
|
||||||
|
Object.Entities.Add(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление тренировок.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="trainingMd"></param>
|
||||||
|
public void AddTrainings(string trainingMd)
|
||||||
|
{
|
||||||
List<string> trainingNames = trainingMd.Split(", ").ToList();
|
List<string> trainingNames = trainingMd.Split(", ").ToList();
|
||||||
List<Training> trainings = Context
|
List<Training> trainings = Context
|
||||||
.Trainings.Where(t => Pf2eDbContext.LocaleSearchArray(t.Name, trainingNames))
|
.Trainings.Where(t => Pf2eDbContext.LocaleSearchArray(t.Name, trainingNames))
|
||||||
@@ -95,7 +128,10 @@ internal class ApparitionProcessor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
protected override string GetDescription() =>
|
//protected override string GetDescription() =>
|
||||||
base.GetDescription()
|
// base.GetDescription()
|
||||||
+ AddedDescription(["skill_markdown", "spell_markdown", "summary_markdown"]);
|
// + AddedDescription(["skill_markdown", "spell_markdown", "summary_markdown"]);
|
||||||
|
|
||||||
|
[GeneratedRegex(@"\*\*Vessel Spell\*\* \[.*?\]\(/Spells\.aspx\?ID=(\d+)\)")]
|
||||||
|
private static partial Regex VesselSpellMarkdownRegex();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user