Категория божества
This commit is contained in:
+58
@@ -0,0 +1,58 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Pf2eDataScrapper.Helpers;
|
||||
using Pf2eDataScrapper.Importers.Implementations.Aonprd.Helpers;
|
||||
using Pf2eDataScrapper.Processors;
|
||||
using Pf2eDataScrapper.Processors.Attributes;
|
||||
using Pf2eModel;
|
||||
using Pf2eModel.Model.Common.I18n;
|
||||
using Pf2eModel.Model.Enum;
|
||||
using Pf2eModel.Model.Structure;
|
||||
|
||||
namespace Pf2eDataScrapper.Importers.Implementations.Aonprd.Processors.Types;
|
||||
|
||||
[ProcessorCollection(
|
||||
"aonprd:deity-category",
|
||||
InnerType = "deity-category",
|
||||
CompendiumType = ProcessorCompendiumEnum.Aonprd,
|
||||
Description = "Категории божеств",
|
||||
Group = ProcessorGroupEnum.AonprdEntities
|
||||
)]
|
||||
internal class DeityCategoryProcessor(
|
||||
ProcessorInput input,
|
||||
StringHelper stringHelper,
|
||||
DatabaseHelper helper,
|
||||
AonprdBuilderGlobals globals
|
||||
) : AbstractEntityProcessor(input, stringHelper, helper, globals)
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override EntityType Type => EntityType.DeityCategory;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override DeityCategory Object { get; } = new();
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override void Add() => Context.DeityCategories.Add(Object);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void Process()
|
||||
{
|
||||
base.Process();
|
||||
|
||||
// Обработка описания категории
|
||||
ProcessDescription();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Обработка описания категории.
|
||||
/// </summary>
|
||||
private void ProcessDescription()
|
||||
{
|
||||
// Получаем markdown с описанием из summary_markdown или другого поля
|
||||
// В данных deity-category.yaml нет summary_markdown, используем пустую строку
|
||||
string descriptionMarkdown = string.Empty;
|
||||
|
||||
// Преобразуем markdown в текст (можно добавить более сложную обработку)
|
||||
// Пока просто сохраняем как есть
|
||||
Object.Description[LocaleType.English] = descriptionMarkdown;
|
||||
}
|
||||
}
|
||||
+23
-1
@@ -45,7 +45,11 @@ internal partial class DeityProcessor(
|
||||
base.Process();
|
||||
|
||||
// Установка категории божества
|
||||
Object.Category = Input.GetRequired<string>("deity_category");
|
||||
string categoryName = Input.GetRequired<string>("deity_category");
|
||||
Object.Category = categoryName;
|
||||
|
||||
// Связываем с сущностью категории
|
||||
ProcessCategory(categoryName);
|
||||
|
||||
ProcessFonts();
|
||||
|
||||
@@ -234,6 +238,24 @@ internal partial class DeityProcessor(
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Обработка категории божества.
|
||||
/// </summary>
|
||||
/// <param name="categoryName">Название категории.</param>
|
||||
private void ProcessCategory(string categoryName)
|
||||
{
|
||||
// Ищем категорию в базе данных
|
||||
DeityCategory? category = Context.DeityCategories.FirstOrDefault(dc =>
|
||||
Pf2eDbContext.LocaleSearch(dc.Entity.Name, categoryName)
|
||||
);
|
||||
|
||||
if (category != null)
|
||||
{
|
||||
Object.CategoryId = category.Id;
|
||||
Object.CategoryEntity = category;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Обработка текстов описания божества.
|
||||
/// </summary>
|
||||
|
||||
@@ -126,4 +126,10 @@ public enum EntityType
|
||||
/// </summary>
|
||||
[PgName("rule")]
|
||||
Rule,
|
||||
|
||||
/// <summary>
|
||||
/// Категория божества.
|
||||
/// </summary>
|
||||
[PgName("deity_category")]
|
||||
DeityCategory,
|
||||
}
|
||||
|
||||
@@ -115,6 +115,18 @@ public class Deity : IEntity
|
||||
/// </summary>
|
||||
public ICollection<DeityWeapon> DeityWeapons { get; set; } = new List<DeityWeapon>();
|
||||
|
||||
/// <summary>
|
||||
/// Категория божества (связь).
|
||||
/// </summary>
|
||||
public DeityCategory? CategoryEntity { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Идентификатор категории божества.
|
||||
/// </summary>
|
||||
[Column(Order = 12)]
|
||||
[Comment("Идентификатор категории божества")]
|
||||
public int? CategoryId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Навыки божества.
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Pf2eModel.Model.Base;
|
||||
using Pf2eModel.Model.Common.I18n;
|
||||
using Pf2eModel.Model.Enum;
|
||||
|
||||
namespace Pf2eModel.Model.Structure;
|
||||
|
||||
/// <summary>
|
||||
/// Категория божества.
|
||||
/// </summary>
|
||||
[EntityOfType(EntityType.DeityCategory)]
|
||||
public class DeityCategory : IEntity
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.None)]
|
||||
[Column(Order = 1)]
|
||||
[Comment("Идентификатор")]
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Entity Entity { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Описание категории.
|
||||
/// </summary>
|
||||
[Column(Order = 2)]
|
||||
[Comment("Описание категории")]
|
||||
public LocaleString Description { get; set; } = [];
|
||||
}
|
||||
@@ -137,6 +137,8 @@ public partial class Pf2eDbContext : DbContext
|
||||
|
||||
public virtual DbSet<Training> Trainings { get; set; }
|
||||
|
||||
public virtual DbSet<DeityCategory> DeityCategories { get; set; }
|
||||
|
||||
public virtual DbSet<Trait> Traits { get; set; }
|
||||
|
||||
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
@@ -571,6 +571,13 @@ public partial class Pf2eDbContext
|
||||
.OnDelete(DeleteBehavior.SetNull);
|
||||
});
|
||||
|
||||
// DeityCategory
|
||||
modelBuilder.Entity<DeityCategory>(entity =>
|
||||
{
|
||||
BindEntity(entity);
|
||||
BindLocaleString(entity, d => d.Description);
|
||||
});
|
||||
|
||||
// Trait
|
||||
modelBuilder.Entity<Trait>(entity =>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user