Глобальное обновление #1

Merged
kozhilya merged 33 commits from dev into master 2025-06-01 22:28:15 +04:00
Showing only changes of commit 64c05a393f - Show all commits
@@ -1,5 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Microsoft.EntityFrameworkCore;
using Pf2eDataScrapper.Helpers;
using Pf2eDataScrapper.Importers.Implementations.Aonprd.Helpers;
using Pf2eDataScrapper.Processors;
@@ -25,7 +27,7 @@ namespace Pf2eDataScrapper.Importers.Implementations.Aonprd.Processors.Subclasse
[ProcessorDependencies(
["aonprd:trait", "aonprd:source", "aonprd:class", "aonprd:spell", "aonprd:skill"]
)]
internal class ApparitionProcessor(
internal partial class ApparitionProcessor(
ProcessorInput input,
StringHelper stringHelper,
DatabaseHelper helper,
@@ -44,8 +46,17 @@ internal class ApparitionProcessor(
/// <inheritdoc/>
public override void ProcessObject()
{
// Spells
string spellMd = Input.GetRequired<string>("spell_markdown");
AddSpells(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
.ParseMarkdownLinks(spellMd)
.Links.Select(l => l.Url)
@@ -65,10 +76,32 @@ internal class ApparitionProcessor(
{
Object.Entities.Add(spellEntity);
}
}
// Trainings
string trainingMd = Input.GetRequired<string>("skill_markdown");
/// <summary>
/// Добавление заклинания сосуда.
/// </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<Training> trainings = Context
.Trainings.Where(t => Pf2eDbContext.LocaleSearchArray(t.Name, trainingNames))
@@ -95,7 +128,10 @@ internal class ApparitionProcessor(
}
/// <inheritdoc/>
protected override string GetDescription() =>
base.GetDescription()
+ AddedDescription(["skill_markdown", "spell_markdown", "summary_markdown"]);
//protected override string GetDescription() =>
// base.GetDescription()
// + AddedDescription(["skill_markdown", "spell_markdown", "summary_markdown"]);
[GeneratedRegex(@"\*\*Vessel Spell\*\* \[.*?\]\(/Spells\.aspx\?ID=(\d+)\)")]
private static partial Regex VesselSpellMarkdownRegex();
}