Обработчик Правил
This commit is contained in:
+29
@@ -0,0 +1,29 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using Pf2eModel.Model.Enum;
|
||||||
|
using Pf2eModel.Model.Structure;
|
||||||
|
|
||||||
|
namespace Pf2eDataScrapper.Importers.Implementations.Aonprd.DataBuilder.Processors.Types;
|
||||||
|
|
||||||
|
[AonprdProcessor("rules")]
|
||||||
|
internal class RuleProcessor(AonprdProcessorInput input) : AbstractEntityProcessor(input)
|
||||||
|
{
|
||||||
|
public override EntityType Type => EntityType.Rule;
|
||||||
|
|
||||||
|
public override Rule Object { get; } = new();
|
||||||
|
|
||||||
|
public override void Add() => Context.Rules.Add(Object);
|
||||||
|
|
||||||
|
public override void Process()
|
||||||
|
{
|
||||||
|
base.Process();
|
||||||
|
|
||||||
|
Object.Breadcrumbs = (Input.GetOptional<JArray>("breadcrumbs") ?? [])
|
||||||
|
.Select(token => token.ToString())
|
||||||
|
.ToArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
+32
-2
@@ -13,7 +13,7 @@ using Pf2eModel.Model.Enum;
|
|||||||
namespace Pf2eModel.Migrations
|
namespace Pf2eModel.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(Pf2eDbContext))]
|
[DbContext(typeof(Pf2eDbContext))]
|
||||||
[Migration("20250506175505_1")]
|
[Migration("20250507075826_1")]
|
||||||
partial class _1
|
partial class _1
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@@ -34,7 +34,7 @@ namespace Pf2eModel.Migrations
|
|||||||
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "deity_fonts", new[] { "none", "heal", "harm", "any" });
|
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "deity_fonts", new[] { "none", "heal", "harm", "any" });
|
||||||
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "deity_sanctification", new[] { "holy", "unholy", "any" });
|
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "deity_sanctification", new[] { "holy", "unholy", "any" });
|
||||||
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "entity_rarity", new[] { "common", "uncommon", "rare", "unique" });
|
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "entity_rarity", new[] { "common", "uncommon", "rare", "unique" });
|
||||||
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "entity_type", new[] { "unknown", "trait", "action", "ancestry", "archetype", "background", "backpack", "campaign_feature", "class", "subclass_group", "subclass", "condition", "deity", "feat", "heritage", "spell", "ritual", "language" });
|
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "entity_type", new[] { "unknown", "trait", "action", "ancestry", "archetype", "background", "backpack", "campaign_feature", "class", "subclass_group", "subclass", "condition", "deity", "feat", "heritage", "spell", "ritual", "language", "rule" });
|
||||||
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "feat_action_type", new[] { "passive", "action", "reaction", "free" });
|
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "feat_action_type", new[] { "passive", "action", "reaction", "free" });
|
||||||
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "feat_category", new[] { "uncategorized", "ancestry-feature", "class-feature", "calling", "class", "skill", "general", "ancestry", "bonus", "deityboon", "curse", "pfsboon", "campaign-feature" });
|
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "feat_category", new[] { "uncategorized", "ancestry-feature", "class-feature", "calling", "class", "skill", "general", "ancestry", "bonus", "deityboon", "curse", "pfsboon", "campaign-feature" });
|
||||||
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "locale_type", new[] { "english", "legacy_english", "russian", "legacy", "hobby", "other" });
|
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "locale_type", new[] { "english", "legacy_english", "russian", "legacy", "hobby", "other" });
|
||||||
@@ -1395,6 +1395,24 @@ namespace Pf2eModel.Migrations
|
|||||||
b.ToTable("ritual_checks", (string)null);
|
b.ToTable("ritual_checks", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Pf2eModel.Model.Structure.Rule", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("id")
|
||||||
|
.HasColumnOrder(1);
|
||||||
|
|
||||||
|
b.PrimitiveCollection<string[]>("Breadcrumbs")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text[]")
|
||||||
|
.HasColumnName("breadcrumbs");
|
||||||
|
|
||||||
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_rules");
|
||||||
|
|
||||||
|
b.ToTable("rules", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Pf2eModel.Model.Structure.Spell", b =>
|
modelBuilder.Entity("Pf2eModel.Model.Structure.Spell", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
@@ -2249,6 +2267,18 @@ namespace Pf2eModel.Migrations
|
|||||||
b.Navigation("Training");
|
b.Navigation("Training");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Pf2eModel.Model.Structure.Rule", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Pf2eModel.Model.Base.Entity", "Entity")
|
||||||
|
.WithOne()
|
||||||
|
.HasForeignKey("Pf2eModel.Model.Structure.Rule", "Id")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired()
|
||||||
|
.HasConstraintName("fk_rules_entities_id");
|
||||||
|
|
||||||
|
b.Navigation("Entity");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Pf2eModel.Model.Structure.Spell", b =>
|
modelBuilder.Entity("Pf2eModel.Model.Structure.Spell", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("Pf2eModel.Model.Base.Entity", "Entity")
|
b.HasOne("Pf2eModel.Model.Base.Entity", "Entity")
|
||||||
+22
-1
@@ -24,7 +24,7 @@ namespace Pf2eModel.Migrations
|
|||||||
.Annotation("Npgsql:Enum:deity_fonts", "none,heal,harm,any")
|
.Annotation("Npgsql:Enum:deity_fonts", "none,heal,harm,any")
|
||||||
.Annotation("Npgsql:Enum:deity_sanctification", "holy,unholy,any")
|
.Annotation("Npgsql:Enum:deity_sanctification", "holy,unholy,any")
|
||||||
.Annotation("Npgsql:Enum:entity_rarity", "common,uncommon,rare,unique")
|
.Annotation("Npgsql:Enum:entity_rarity", "common,uncommon,rare,unique")
|
||||||
.Annotation("Npgsql:Enum:entity_type", "unknown,trait,action,ancestry,archetype,background,backpack,campaign_feature,class,subclass_group,subclass,condition,deity,feat,heritage,spell,ritual,language")
|
.Annotation("Npgsql:Enum:entity_type", "unknown,trait,action,ancestry,archetype,background,backpack,campaign_feature,class,subclass_group,subclass,condition,deity,feat,heritage,spell,ritual,language,rule")
|
||||||
.Annotation("Npgsql:Enum:feat_action_type", "passive,action,reaction,free")
|
.Annotation("Npgsql:Enum:feat_action_type", "passive,action,reaction,free")
|
||||||
.Annotation("Npgsql:Enum:feat_category", "uncategorized,ancestry-feature,class-feature,calling,class,skill,general,ancestry,bonus,deityboon,curse,pfsboon,campaign-feature")
|
.Annotation("Npgsql:Enum:feat_category", "uncategorized,ancestry-feature,class-feature,calling,class,skill,general,ancestry,bonus,deityboon,curse,pfsboon,campaign-feature")
|
||||||
.Annotation("Npgsql:Enum:locale_type", "english,legacy_english,russian,legacy,hobby,other")
|
.Annotation("Npgsql:Enum:locale_type", "english,legacy_english,russian,legacy,hobby,other")
|
||||||
@@ -324,6 +324,24 @@ namespace Pf2eModel.Migrations
|
|||||||
onDelete: ReferentialAction.Cascade);
|
onDelete: ReferentialAction.Cascade);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "rules",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
breadcrumbs = table.Column<string[]>(type: "text[]", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_rules", x => x.id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_rules_entities_id",
|
||||||
|
column: x => x.id,
|
||||||
|
principalTable: "entities",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "spells",
|
name: "spells",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
@@ -1400,6 +1418,9 @@ namespace Pf2eModel.Migrations
|
|||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "ritual_checks");
|
name: "ritual_checks");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "rules");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "spell_areas");
|
name: "spell_areas");
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@ namespace Pf2eModel.Migrations
|
|||||||
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "deity_fonts", new[] { "none", "heal", "harm", "any" });
|
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "deity_fonts", new[] { "none", "heal", "harm", "any" });
|
||||||
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "deity_sanctification", new[] { "holy", "unholy", "any" });
|
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "deity_sanctification", new[] { "holy", "unholy", "any" });
|
||||||
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "entity_rarity", new[] { "common", "uncommon", "rare", "unique" });
|
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "entity_rarity", new[] { "common", "uncommon", "rare", "unique" });
|
||||||
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "entity_type", new[] { "unknown", "trait", "action", "ancestry", "archetype", "background", "backpack", "campaign_feature", "class", "subclass_group", "subclass", "condition", "deity", "feat", "heritage", "spell", "ritual", "language" });
|
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "entity_type", new[] { "unknown", "trait", "action", "ancestry", "archetype", "background", "backpack", "campaign_feature", "class", "subclass_group", "subclass", "condition", "deity", "feat", "heritage", "spell", "ritual", "language", "rule" });
|
||||||
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "feat_action_type", new[] { "passive", "action", "reaction", "free" });
|
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "feat_action_type", new[] { "passive", "action", "reaction", "free" });
|
||||||
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "feat_category", new[] { "uncategorized", "ancestry-feature", "class-feature", "calling", "class", "skill", "general", "ancestry", "bonus", "deityboon", "curse", "pfsboon", "campaign-feature" });
|
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "feat_category", new[] { "uncategorized", "ancestry-feature", "class-feature", "calling", "class", "skill", "general", "ancestry", "bonus", "deityboon", "curse", "pfsboon", "campaign-feature" });
|
||||||
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "locale_type", new[] { "english", "legacy_english", "russian", "legacy", "hobby", "other" });
|
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "locale_type", new[] { "english", "legacy_english", "russian", "legacy", "hobby", "other" });
|
||||||
@@ -1392,6 +1392,24 @@ namespace Pf2eModel.Migrations
|
|||||||
b.ToTable("ritual_checks", (string)null);
|
b.ToTable("ritual_checks", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Pf2eModel.Model.Structure.Rule", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("id")
|
||||||
|
.HasColumnOrder(1);
|
||||||
|
|
||||||
|
b.PrimitiveCollection<string[]>("Breadcrumbs")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text[]")
|
||||||
|
.HasColumnName("breadcrumbs");
|
||||||
|
|
||||||
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_rules");
|
||||||
|
|
||||||
|
b.ToTable("rules", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Pf2eModel.Model.Structure.Spell", b =>
|
modelBuilder.Entity("Pf2eModel.Model.Structure.Spell", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
@@ -2246,6 +2264,18 @@ namespace Pf2eModel.Migrations
|
|||||||
b.Navigation("Training");
|
b.Navigation("Training");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Pf2eModel.Model.Structure.Rule", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Pf2eModel.Model.Base.Entity", "Entity")
|
||||||
|
.WithOne()
|
||||||
|
.HasForeignKey("Pf2eModel.Model.Structure.Rule", "Id")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired()
|
||||||
|
.HasConstraintName("fk_rules_entities_id");
|
||||||
|
|
||||||
|
b.Navigation("Entity");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Pf2eModel.Model.Structure.Spell", b =>
|
modelBuilder.Entity("Pf2eModel.Model.Structure.Spell", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("Pf2eModel.Model.Base.Entity", "Entity")
|
b.HasOne("Pf2eModel.Model.Base.Entity", "Entity")
|
||||||
|
|||||||
@@ -57,4 +57,7 @@ public enum EntityType
|
|||||||
|
|
||||||
[PgName("language")]
|
[PgName("language")]
|
||||||
Language,
|
Language,
|
||||||
|
|
||||||
|
[PgName("rule")]
|
||||||
|
Rule,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using Pf2eModel.Model.Base;
|
||||||
|
using Pf2eModel.Model.Enum;
|
||||||
|
|
||||||
|
namespace Pf2eModel.Model.Structure;
|
||||||
|
|
||||||
|
[EntityOfType(EntityType.Rule)]
|
||||||
|
public class Rule : IEntity
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
[DatabaseGenerated(DatabaseGeneratedOption.None)]
|
||||||
|
[Column(Order = 1)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public Entity Entity { get; set; } = null!;
|
||||||
|
|
||||||
|
public string[] Breadcrumbs { get; set; } = [];
|
||||||
|
}
|
||||||
@@ -100,6 +100,8 @@ public partial class Pf2eDbContext : DbContext
|
|||||||
|
|
||||||
public virtual DbSet<RitualCheck> RitualChecks { get; set; }
|
public virtual DbSet<RitualCheck> RitualChecks { get; set; }
|
||||||
|
|
||||||
|
public virtual DbSet<Rule> Rules { get; set; }
|
||||||
|
|
||||||
public virtual DbSet<Source> Sources { get; set; }
|
public virtual DbSet<Source> Sources { get; set; }
|
||||||
|
|
||||||
public virtual DbSet<Spell> Spells { get; set; }
|
public virtual DbSet<Spell> Spells { get; set; }
|
||||||
|
|||||||
@@ -503,6 +503,12 @@ public partial class Pf2eDbContext
|
|||||||
{
|
{
|
||||||
BindEntity(entity);
|
BindEntity(entity);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Rule
|
||||||
|
modelBuilder.Entity<Rule>(entity =>
|
||||||
|
{
|
||||||
|
BindEntity(entity);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DefineMethods(ModelBuilder modelBuilder)
|
private void DefineMethods(ModelBuilder modelBuilder)
|
||||||
|
|||||||
Reference in New Issue
Block a user