Категория божества
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();
|
base.Process();
|
||||||
|
|
||||||
// Установка категории божества
|
// Установка категории божества
|
||||||
Object.Category = Input.GetRequired<string>("deity_category");
|
string categoryName = Input.GetRequired<string>("deity_category");
|
||||||
|
Object.Category = categoryName;
|
||||||
|
|
||||||
|
// Связываем с сущностью категории
|
||||||
|
ProcessCategory(categoryName);
|
||||||
|
|
||||||
ProcessFonts();
|
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>
|
||||||
/// Обработка текстов описания божества.
|
/// Обработка текстов описания божества.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -126,4 +126,10 @@ public enum EntityType
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[PgName("rule")]
|
[PgName("rule")]
|
||||||
Rule,
|
Rule,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Категория божества.
|
||||||
|
/// </summary>
|
||||||
|
[PgName("deity_category")]
|
||||||
|
DeityCategory,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,6 +115,18 @@ public class Deity : IEntity
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public ICollection<DeityWeapon> DeityWeapons { get; set; } = new List<DeityWeapon>();
|
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>
|
||||||
/// Навыки божества.
|
/// Навыки божества.
|
||||||
/// </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<Training> Trainings { get; set; }
|
||||||
|
|
||||||
|
public virtual DbSet<DeityCategory> DeityCategories { get; set; }
|
||||||
|
|
||||||
public virtual DbSet<Trait> Traits { get; set; }
|
public virtual DbSet<Trait> Traits { get; set; }
|
||||||
|
|
||||||
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
|
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
|
||||||
|
|||||||
@@ -571,6 +571,13 @@ public partial class Pf2eDbContext
|
|||||||
.OnDelete(DeleteBehavior.SetNull);
|
.OnDelete(DeleteBehavior.SetNull);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// DeityCategory
|
||||||
|
modelBuilder.Entity<DeityCategory>(entity =>
|
||||||
|
{
|
||||||
|
BindEntity(entity);
|
||||||
|
BindLocaleString(entity, d => d.Description);
|
||||||
|
});
|
||||||
|
|
||||||
// Trait
|
// Trait
|
||||||
modelBuilder.Entity<Trait>(entity =>
|
modelBuilder.Entity<Trait>(entity =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -84,9 +84,9 @@ INNER JOIN entities AS E ON A.id = E.id;
|
|||||||
- [ ] sidebar.yaml
|
- [ ] sidebar.yaml
|
||||||
|
|
||||||
**Боги**
|
**Боги**
|
||||||
- [ ] deity.yaml
|
- [x] deity.yaml
|
||||||
- [ ] deity-category.yaml
|
- [x] deity-category.yaml
|
||||||
- [ ] domain.yaml
|
- [x] domain.yaml
|
||||||
|
|
||||||
**Фиты**
|
**Фиты**
|
||||||
- [x] feat.yaml
|
- [x] feat.yaml
|
||||||
|
|||||||
Reference in New Issue
Block a user