From 768dfcee867b878d02e18694668d92005c8ba6c1 Mon Sep 17 00:00:00 2001 From: dingo Date: Sun, 19 Apr 2026 13:02:24 -0400 Subject: [PATCH] feat(phase2): ability revamp DB migration -- add SpiritToken, drop EffectsJson - Add CardType.SpiritToken enum value (stored as text, no Postgres enum change) - Drop catalog.card_definitions.effects column (migration 20260419170135) with safety-pass to copy any remaining effects -> abilities before drop - Remove CardDefinition.EffectsJson property and CatalogDbContext mapping - Remove CardInstance.EffectsJson snapshot from GameState/GameEngine - Remove EffectsJson from all DTOs: UnitDelta, CardUpdateDto, ContentCardDto - Remove EffectsJson from GameStateDiffer, ContentDtoMapper, CardEditor, CardReport - Simplify AbilitySystem.FireCardEffects to use AbilitiesJson only (no fallback) - Enforce SpiritToken exclusion in CollectionAddCardHandler (deck builds) - Enforce SpiritToken exclusion in BazaarBuyBoosterPackHandler (pack draws) Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude Co-Authored-By: Happy --- .../Components/Pages/Cards/CardEditor.razor | 20 +- .../Components/Pages/Reports/CardReport.razor | 2 +- .../Handlers/BazaarBuyBoosterPackHandler.cs | 8 +- .../Handlers/CollectionAddCardHandler.cs | 4 + Server/src/SOR.Content/ContentMessages.cs | 1 - .../SOR.Content/Handlers/ContentDtoMapper.cs | 1 - .../SOR.Database/Contexts/CatalogDbContext.cs | 3 - .../Entities/Catalog/CardDefinition.cs | 10 +- Server/src/SOR.Database/Enums/CardEnums.cs | 6 + ...419170135_AbilityRevamp_Phase2.Designer.cs | 604 ++++++++++++++++++ .../20260419170135_AbilityRevamp_Phase2.cs | 43 ++ .../Catalog/CatalogDbContextModelSnapshot.cs | 4 - .../src/SOR.Game/Abilities/AbilitySystem.cs | 29 +- .../Abilities/Models/AbilityDefinition.cs | 2 +- Server/src/SOR.Game/GameEngine.cs | 9 +- Server/src/SOR.Game/GameMessages.cs | 4 +- Server/src/SOR.Game/GameState.cs | 6 - Server/src/SOR.Game/GameStateDiffer.cs | 2 - 18 files changed, 673 insertions(+), 85 deletions(-) create mode 100644 Server/src/SOR.Database/Migrations/Catalog/20260419170135_AbilityRevamp_Phase2.Designer.cs create mode 100644 Server/src/SOR.Database/Migrations/Catalog/20260419170135_AbilityRevamp_Phase2.cs diff --git a/Server/src/SOR.Admin/Components/Pages/Cards/CardEditor.razor b/Server/src/SOR.Admin/Components/Pages/Cards/CardEditor.razor index 1782a0f..bd5ed56 100644 --- a/Server/src/SOR.Admin/Components/Pages/Cards/CardEditor.razor +++ b/Server/src/SOR.Admin/Components/Pages/Cards/CardEditor.razor @@ -945,12 +945,7 @@ else _availableGenus.Add(tag); _availableGenus.Sort(StringComparer.OrdinalIgnoreCase); - _abilitiesJson = _card.CardType is CardType.Repentance - or CardType.Instinct or CardType.Terramorpha - ? (!string.IsNullOrWhiteSpace(_card.AbilitiesJson) - ? _card.AbilitiesJson! - : _card.EffectsJson ?? string.Empty) - : _card.AbilitiesJson ?? string.Empty; + _abilitiesJson = _card.AbilitiesJson ?? string.Empty; } } } @@ -968,18 +963,7 @@ else { _card.Genus = _selectedGenus.Count > 0 ? _selectedGenus.ToArray() : null; - if (_card.CardType is CardType.Repentance or CardType.Instinct or CardType.Terramorpha) - { - var canonical = string.IsNullOrWhiteSpace(_abilitiesJson) ? null : _abilitiesJson; - // Canonical store for ability-schema cards. - _card.AbilitiesJson = canonical; - // Transition mirror-write for backward compatibility. - _card.EffectsJson = canonical; - } - else - { - _card.AbilitiesJson = string.IsNullOrWhiteSpace(_abilitiesJson) ? null : _abilitiesJson; - } + _card.AbilitiesJson = string.IsNullOrWhiteSpace(_abilitiesJson) ? null : _abilitiesJson; _card.UpdatedAt = DateTimeOffset.UtcNow; diff --git a/Server/src/SOR.Admin/Components/Pages/Reports/CardReport.razor b/Server/src/SOR.Admin/Components/Pages/Reports/CardReport.razor index fa08734..0c74dfa 100644 --- a/Server/src/SOR.Admin/Components/Pages/Reports/CardReport.razor +++ b/Server/src/SOR.Admin/Components/Pages/Reports/CardReport.razor @@ -366,7 +366,7 @@ var art = c.Assets.Where(a => a.AssetType == CardAssetType.Art2D).ToList(); var hasSfx = c.MoveSoundUrl != null || c.DamagedSoundUrl != null || c.BlockedSoundUrl != null || c.AttackSoundUrl != null || c.DeathSoundUrl != null; - var abilityJson = c.AbilitiesJson ?? c.EffectsJson; + var abilityJson = c.AbilitiesJson; var hasAbilities = JsonArrayHasElements(abilityJson); cardToDecks.TryGetValue(c.Id, out var decks); return new CardRow( diff --git a/Server/src/SOR.Bazaar/Handlers/BazaarBuyBoosterPackHandler.cs b/Server/src/SOR.Bazaar/Handlers/BazaarBuyBoosterPackHandler.cs index 3d5cdd9..cdef128 100644 --- a/Server/src/SOR.Bazaar/Handlers/BazaarBuyBoosterPackHandler.cs +++ b/Server/src/SOR.Bazaar/Handlers/BazaarBuyBoosterPackHandler.cs @@ -114,7 +114,8 @@ internal sealed class BazaarBuyBoosterPackHandler : BazaarHandlerBase, IMessageH else if (pack.CardSetId.HasValue) setId = pack.CardSetId; - var q = _catalogDb.CardDefinitions.Where(cd => cd.Rarity == rarity && cd.IsPublished); + var q = _catalogDb.CardDefinitions.Where(cd => cd.Rarity == rarity && cd.IsPublished + && cd.CardType != CardType.SpiritToken); if (setId.HasValue) q = q.Where(cd => cd.SetId == setId.Value); var pool = await q.Select(cd => new { cd.Id, cd.Name, cd.Rarity }).ToListAsync(ct); @@ -157,7 +158,8 @@ internal sealed class BazaarBuyBoosterPackHandler : BazaarHandlerBase, IMessageH if (!Guid.TryParse(sp.GetString(), out var setId)) break; var pool = await _catalogDb.CardDefinitions - .Where(cd => cd.SetId == setId && cd.IsPublished) + .Where(cd => cd.SetId == setId && cd.IsPublished + && cd.CardType != CardType.SpiritToken) .Select(cd => new { cd.Id, cd.Name, cd.Rarity }) .ToListAsync(ct); if (pool.Count == 0) break; @@ -176,7 +178,7 @@ internal sealed class BazaarBuyBoosterPackHandler : BazaarHandlerBase, IMessageH case "Random": { var pool = await _catalogDb.CardDefinitions - .Where(cd => cd.IsPublished) + .Where(cd => cd.IsPublished && cd.CardType != CardType.SpiritToken) .Select(cd => new { cd.Id, cd.Name, cd.Rarity }) .ToListAsync(ct); if (pool.Count == 0) break; diff --git a/Server/src/SOR.Collection/Handlers/CollectionAddCardHandler.cs b/Server/src/SOR.Collection/Handlers/CollectionAddCardHandler.cs index da02f15..b7b2d10 100644 --- a/Server/src/SOR.Collection/Handlers/CollectionAddCardHandler.cs +++ b/Server/src/SOR.Collection/Handlers/CollectionAddCardHandler.cs @@ -68,6 +68,10 @@ internal sealed class CollectionAddCardHandler : CollectionHandlerBase, IMessage if (cardMeta == null) return ServerMessage.Error(message.Seq, "CARD_NOT_FOUND", "Card definition not found."); + if (cardMeta.CardType == CardType.SpiritToken) + return ServerMessage.Error(message.Seq, "SPIRIT_TOKEN_NOT_ALLOWED", + "Spirit tokens are summoned by effects and cannot be added to decks."); + // if (cardMeta.CardType == CardType.ArchSpirit && (cardMeta.Tier ?? 1) == 1) // return ServerMessage.Error(message.Seq, "ARCH_SPIRIT_NOT_ALLOWED", // "Tier 1 ArchSpirits are your deck commander — set them at the deck level. " + diff --git a/Server/src/SOR.Content/ContentMessages.cs b/Server/src/SOR.Content/ContentMessages.cs index e89da2f..aa3226a 100644 --- a/Server/src/SOR.Content/ContentMessages.cs +++ b/Server/src/SOR.Content/ContentMessages.cs @@ -89,7 +89,6 @@ public sealed record CardDefinitionDto( Guid? PreviousTierId, string? TerramorphaMode, string? AbilitiesJson, - string? EffectsJson, // Publishing Guid? SetId, int? CollectorNumber, diff --git a/Server/src/SOR.Content/Handlers/ContentDtoMapper.cs b/Server/src/SOR.Content/Handlers/ContentDtoMapper.cs index 7eead34..4d985fd 100644 --- a/Server/src/SOR.Content/Handlers/ContentDtoMapper.cs +++ b/Server/src/SOR.Content/Handlers/ContentDtoMapper.cs @@ -38,7 +38,6 @@ internal static class ContentDtoMapper PreviousTierId: c.PreviousTierId, TerramorphaMode: c.TerramorphaMode?.ToString(), AbilitiesJson: c.AbilitiesJson, - EffectsJson: c.EffectsJson, SetId: c.SetId, CollectorNumber: c.CollectorNumber, IsPublished: c.IsPublished, diff --git a/Server/src/SOR.Database/Contexts/CatalogDbContext.cs b/Server/src/SOR.Database/Contexts/CatalogDbContext.cs index 2608152..0053cc2 100644 --- a/Server/src/SOR.Database/Contexts/CatalogDbContext.cs +++ b/Server/src/SOR.Database/Contexts/CatalogDbContext.cs @@ -64,9 +64,6 @@ public sealed class CatalogDbContext : DbContext e.Property(c => c.AbilitiesJson) .HasColumnType("jsonb") .HasColumnName("abilities"); - e.Property(c => c.EffectsJson) - .HasColumnType("jsonb") - .HasColumnName("effects"); e.Property(c => c.OtherCostsJson) .HasColumnType("jsonb") .HasColumnName("other_costs"); diff --git a/Server/src/SOR.Database/Entities/Catalog/CardDefinition.cs b/Server/src/SOR.Database/Entities/Catalog/CardDefinition.cs index 0d8c692..8d33707 100644 --- a/Server/src/SOR.Database/Entities/Catalog/CardDefinition.cs +++ b/Server/src/SOR.Database/Entities/Catalog/CardDefinition.cs @@ -9,9 +9,8 @@ using SOR.Database.Enums; /// (name, type, affinity, costs, combat stats). /// /// The ability/effect system is highly recursive and type-specific, so it is -/// stored as JSONB. The game engine and admin tool own serialization. -/// AbilitiesJson: used by ArchSpirit, Spirit, Ruin. -/// EffectsJson: used by Repentance, Instinct, Terramorpha. +/// stored as JSONB in AbilitiesJson (array of AbilityDefinition) for all card types. +/// The game engine and admin tool own serialization. /// /// Genus tags are stored as a Postgres text[] array — fast for containment /// queries (@>) without the overhead of a junction table. @@ -97,12 +96,9 @@ public sealed class CardDefinition public string? DeathSoundUrl { get; set; } // ── Ability / Effect data (JSONB) ──────────────────────────────────────── - /// JSONB array of AbilityDefinition objects (ArchSpirit, Spirit, Ruin). + /// JSONB array of AbilityDefinition objects (all card types). public string? AbilitiesJson { get; set; } - /// JSONB array of Action objects (Repentance, Instinct, Terramorpha). - public string? EffectsJson { get; set; } - // ── Publishing metadata ────────────────────────────────────────────────── public CardRarity Rarity { get; set; } = CardRarity.Common; public Guid? SetId { get; set; } diff --git a/Server/src/SOR.Database/Enums/CardEnums.cs b/Server/src/SOR.Database/Enums/CardEnums.cs index e046177..45f4467 100644 --- a/Server/src/SOR.Database/Enums/CardEnums.cs +++ b/Server/src/SOR.Database/Enums/CardEnums.cs @@ -8,6 +8,12 @@ public enum CardType Terramorpha, Ruin, Instinct, + /// + /// Spirit tokens are summoned by effects; they cannot be added to decks + /// or granted to player collections. Stored as full CardDefinition rows + /// so the engine can reference their stats and abilities. + /// + SpiritToken, } /// diff --git a/Server/src/SOR.Database/Migrations/Catalog/20260419170135_AbilityRevamp_Phase2.Designer.cs b/Server/src/SOR.Database/Migrations/Catalog/20260419170135_AbilityRevamp_Phase2.Designer.cs new file mode 100644 index 0000000..7c148cb --- /dev/null +++ b/Server/src/SOR.Database/Migrations/Catalog/20260419170135_AbilityRevamp_Phase2.Designer.cs @@ -0,0 +1,604 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using SOR.Database.Contexts; + +#nullable disable + +namespace SOR.Database.Migrations.Catalog +{ + [DbContext(typeof(CatalogDbContext))] + [Migration("20260419170135_AbilityRevamp_Phase2")] + partial class AbilityRevamp_Phase2 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("catalog") + .HasAnnotation("ProductVersion", "8.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("SOR.Database.Entities.Catalog.CardAnimationBinding", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ActionName") + .IsRequired() + .HasColumnType("text"); + + b.Property("AnimationCdnUrl") + .IsRequired() + .HasColumnType("text"); + + b.Property("AnimationTrackName") + .HasColumnType("text"); + + b.Property("CardDefinitionId") + .HasColumnType("uuid"); + + b.Property("CastSoundCdnUrl") + .HasColumnType("text"); + + b.Property("ImpactSoundCdnUrl") + .HasColumnType("text"); + + b.Property("IsAiGenerated") + .HasColumnType("boolean"); + + b.HasKey("Id"); + + b.HasIndex("CardDefinitionId", "ActionName") + .IsUnique(); + + b.ToTable("card_animation_bindings", "catalog"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Catalog.CardAsset", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AssetType") + .IsRequired() + .HasColumnType("text"); + + b.Property("CardDefinitionId") + .HasColumnType("uuid"); + + b.Property("CdnUrl") + .IsRequired() + .HasColumnType("text"); + + b.Property("ContentETag") + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("IsAiGenerated") + .HasColumnType("boolean"); + + b.Property("MimeType") + .HasColumnType("text"); + + b.Property("ModelFacingDirection") + .HasColumnType("text"); + + b.Property("ModelTintMaskUrl") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("CardDefinitionId", "AssetType"); + + b.ToTable("card_assets", "catalog"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Catalog.CardDefinition", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AbilitiesJson") + .HasColumnType("jsonb") + .HasColumnName("abilities"); + + b.Property("Affinity") + .IsRequired() + .HasColumnType("text"); + + b.Property("AttackSoundUrl") + .HasColumnType("text"); + + b.Property("AttackType") + .HasColumnType("text"); + + b.Property("BlockedSoundUrl") + .HasColumnType("text"); + + b.Property("CanAttack") + .HasColumnType("boolean"); + + b.Property("CanBeAttacked") + .HasColumnType("boolean"); + + b.Property("CanBeBlocked") + .HasColumnType("boolean"); + + b.Property("CanBeObstructed") + .HasColumnType("boolean"); + + b.Property("CanBeSacrificed") + .HasColumnType("boolean"); + + b.Property("CanDefend") + .HasColumnType("boolean"); + + b.Property("CanMove") + .HasColumnType("boolean"); + + b.Property("CanUseAbility") + .HasColumnType("boolean"); + + b.Property("CardType") + .IsRequired() + .HasColumnType("text"); + + b.Property("CollectorNumber") + .HasColumnType("integer"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Damage") + .HasColumnType("integer"); + + b.Property("DamagedSoundUrl") + .HasColumnType("text"); + + b.Property("DeathSoundUrl") + .HasColumnType("text"); + + b.Property("DefinitionVersion") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasDefaultValue(0L); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("Genus") + .HasColumnType("text[]"); + + b.Property("IsPublished") + .HasColumnType("boolean"); + + b.Property("IsRetired") + .HasColumnType("boolean"); + + b.Property("MaxAttackRange") + .HasColumnType("integer"); + + b.Property("MaxChannelRange") + .HasColumnType("integer"); + + b.Property("MaxDefense") + .HasColumnType("integer"); + + b.Property("MaxHealth") + .HasColumnType("integer"); + + b.Property("MinAttackRange") + .HasColumnType("integer"); + + b.Property("MinChannelRange") + .HasColumnType("integer"); + + b.Property("ModelScale") + .HasColumnType("real"); + + b.Property("ModelTintColor") + .HasColumnType("text"); + + b.Property("MoveSoundUrl") + .HasColumnType("text"); + + b.Property("MovementPoints") + .HasColumnType("integer"); + + b.Property("MovementType") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("OtherCostsJson") + .HasColumnType("jsonb") + .HasColumnName("other_costs"); + + b.Property("PreviousTierId") + .HasColumnType("uuid"); + + b.Property("Rarity") + .IsRequired() + .HasColumnType("text"); + + b.Property("RequiresLos") + .HasColumnType("boolean"); + + b.Property("RetiredAt") + .HasColumnType("timestamp with time zone"); + + b.Property("SetId") + .HasColumnType("uuid"); + + b.Property("SpCost") + .HasColumnType("integer"); + + b.Property("StCost") + .HasColumnType("integer"); + + b.Property("TerramorphaMode") + .HasColumnType("text"); + + b.Property("Tier") + .HasColumnType("integer"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Affinity"); + + b.HasIndex("CardType"); + + b.HasIndex("DefinitionVersion"); + + b.HasIndex("Name"); + + b.HasIndex("PreviousTierId"); + + b.HasIndex("Rarity"); + + b.HasIndex("SetId"); + + b.HasIndex("IsPublished", "SetId"); + + b.ToTable("card_definitions", "catalog"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Catalog.CardSet", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("ReleaseDate") + .HasColumnType("date"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("card_sets", "catalog"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Catalog.CdnUploadRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ContentType") + .HasColumnType("text"); + + b.Property("IsAiGenerated") + .HasColumnType("boolean"); + + b.Property("ObjectKey") + .IsRequired() + .HasColumnType("text"); + + b.Property("Prefix") + .IsRequired() + .HasColumnType("text"); + + b.Property("PublicUrl") + .IsRequired() + .HasColumnType("text"); + + b.Property("UploadedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("IsAiGenerated"); + + b.HasIndex("ObjectKey") + .IsUnique(); + + b.HasIndex("Prefix"); + + b.ToTable("cdn_upload_records", "catalog"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Catalog.GameAudioConfig", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Context") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("TrackCdnUrl") + .IsRequired() + .HasColumnType("text"); + + b.Property("TrackName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("Context"); + + b.HasIndex("IsActive"); + + b.ToTable("game_audio_configs", "catalog"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Catalog.HighlightConfig", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CdnPath") + .IsRequired() + .HasColumnType("text"); + + b.Property("FallbackHex") + .IsRequired() + .HasColumnType("text"); + + b.Property("Fps") + .HasColumnType("real"); + + b.Property("FrameCount") + .HasColumnType("integer"); + + b.Property("HighlightType") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsAnimated") + .HasColumnType("boolean"); + + b.HasKey("Id"); + + b.HasIndex("HighlightType") + .IsUnique(); + + b.ToTable("highlight_configs", "catalog"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Catalog.SkyboxDefinition", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CdnPath") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CubeNxUrl") + .HasColumnType("text") + .HasColumnName("cube_nx_url"); + + b.Property("CubeNyUrl") + .HasColumnType("text") + .HasColumnName("cube_ny_url"); + + b.Property("CubeNzUrl") + .HasColumnType("text") + .HasColumnName("cube_nz_url"); + + b.Property("CubePxUrl") + .HasColumnType("text") + .HasColumnName("cube_px_url"); + + b.Property("CubePyUrl") + .HasColumnType("text") + .HasColumnName("cube_py_url"); + + b.Property("CubePzUrl") + .HasColumnType("text") + .HasColumnName("cube_pz_url"); + + b.Property("Fps") + .HasColumnType("real"); + + b.Property("FrameCount") + .HasColumnType("integer"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("IsAnimated") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("SkyboxType") + .HasColumnType("text") + .HasColumnName("skybox_type"); + + b.HasKey("Id"); + + b.HasIndex("IsActive"); + + b.ToTable("skybox_definitions", "catalog"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Catalog.TileBottomModel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CdnKey") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("PublicUrl") + .IsRequired() + .HasColumnType("text"); + + b.Property("Shape") + .IsRequired() + .HasColumnType("text"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Shape", "IsActive"); + + b.ToTable("tile_bottom_models", "catalog"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Catalog.TileModelBinding", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Affinity") + .IsRequired() + .HasColumnType("text"); + + b.Property("ModelCdnKey") + .IsRequired() + .HasColumnType("text"); + + b.Property("ModelPublicUrl") + .IsRequired() + .HasColumnType("text"); + + b.Property("Shape") + .IsRequired() + .HasColumnType("text"); + + b.Property("TexturePublicUrl") + .HasColumnType("text"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Affinity", "Shape") + .IsUnique(); + + b.ToTable("tile_model_bindings", "catalog"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Catalog.CardAnimationBinding", b => + { + b.HasOne("SOR.Database.Entities.Catalog.CardDefinition", "CardDefinition") + .WithMany("AnimationBindings") + .HasForeignKey("CardDefinitionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CardDefinition"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Catalog.CardAsset", b => + { + b.HasOne("SOR.Database.Entities.Catalog.CardDefinition", "CardDefinition") + .WithMany("Assets") + .HasForeignKey("CardDefinitionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CardDefinition"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Catalog.CardDefinition", b => + { + b.HasOne("SOR.Database.Entities.Catalog.CardDefinition", "PreviousTier") + .WithMany() + .HasForeignKey("PreviousTierId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("SOR.Database.Entities.Catalog.CardSet", "Set") + .WithMany("Cards") + .HasForeignKey("SetId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("PreviousTier"); + + b.Navigation("Set"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Catalog.CardDefinition", b => + { + b.Navigation("AnimationBindings"); + + b.Navigation("Assets"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Catalog.CardSet", b => + { + b.Navigation("Cards"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Server/src/SOR.Database/Migrations/Catalog/20260419170135_AbilityRevamp_Phase2.cs b/Server/src/SOR.Database/Migrations/Catalog/20260419170135_AbilityRevamp_Phase2.cs new file mode 100644 index 0000000..da6d9c9 --- /dev/null +++ b/Server/src/SOR.Database/Migrations/Catalog/20260419170135_AbilityRevamp_Phase2.cs @@ -0,0 +1,43 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace SOR.Database.Migrations.Catalog +{ + /// + public partial class AbilityRevamp_Phase2 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + // Safety pass: any card that still has effects data but no abilities data + // gets the effects copied over (guards against the BackfillAbilitiesFromEffectsForAbilityCards + // migration having been skipped or partially applied). + migrationBuilder.Sql(@" +UPDATE catalog.card_definitions +SET abilities = effects +WHERE effects IS NOT NULL + AND btrim(effects::text) NOT IN ('', 'null', '""""') + AND ( + abilities IS NULL + OR btrim(abilities::text) IN ('', 'null', '""""') + ); +"); + migrationBuilder.DropColumn( + name: "effects", + schema: "catalog", + table: "card_definitions"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "effects", + schema: "catalog", + table: "card_definitions", + type: "jsonb", + nullable: true); + } + } +} diff --git a/Server/src/SOR.Database/Migrations/Catalog/CatalogDbContextModelSnapshot.cs b/Server/src/SOR.Database/Migrations/Catalog/CatalogDbContextModelSnapshot.cs index 5388410..badcbbd 100644 --- a/Server/src/SOR.Database/Migrations/Catalog/CatalogDbContextModelSnapshot.cs +++ b/Server/src/SOR.Database/Migrations/Catalog/CatalogDbContextModelSnapshot.cs @@ -177,10 +177,6 @@ namespace SOR.Database.Migrations.Catalog .IsRequired() .HasColumnType("text"); - b.Property("EffectsJson") - .HasColumnType("jsonb") - .HasColumnName("effects"); - b.Property("Genus") .HasColumnType("text[]"); diff --git a/Server/src/SOR.Game/Abilities/AbilitySystem.cs b/Server/src/SOR.Game/Abilities/AbilitySystem.cs index 6424d03..499b4b5 100644 --- a/Server/src/SOR.Game/Abilities/AbilitySystem.cs +++ b/Server/src/SOR.Game/Abilities/AbilitySystem.cs @@ -126,46 +126,19 @@ public static class AbilitySystem // ── Triggered ability firing ─────────────────────────────────────────────── /// - /// Resolve the EffectsJson action list on a non-unit card (Repentance, Instinct, Ruin) + /// Resolve the AbilitiesJson active ability list on a non-unit card (Repentance, Instinct) /// immediately when it is channeled. The card itself is the source in the context. /// public static GameState FireCardEffects(GameState state, string actorId, CardInstance card, IReadOnlyList? clientTargets = null) { - // 1. EffectsJson — backward-compatible flat action list. - // NOTE: Some content pipelines historically wrote AbilityDefinition[] into - // EffectsJson for Repentance/Instinct. When that happens, ParseEffects yields - // empty/no-op actions. We still attempt to execute active abilities from - // EffectsJson below as a compatibility path. - var actions = ParseEffects(card.EffectsJson) - .Where(a => a.Effects is { Length: > 0 }) - .ToArray(); - if (actions.Length > 0) - { - var ctx = new AbilityContext { State = state, ActorId = actorId, Source = card }; - ExecuteActions(actions, ctx, clientTargets, requireClientTargets: true); - } - - // 2. AbilitiesJson — Active abilities (e.g. Repentance / Instinct cards with targeting). - // 3. Compatibility fallback: if AbilitiesJson has no active entries, also try - // parsing active abilities from EffectsJson. var activeDefs = ParseAbilities(card.AbilitiesJson) .Where(d => d.Type == AbilityType.Active) .ToList(); - if (activeDefs.Count == 0) - { - var fallback = ParseAbilities(card.EffectsJson) - .Where(d => d.Type == AbilityType.Active) - .ToList(); - if (fallback.Count > 0) - activeDefs = fallback; - } - foreach (var def in activeDefs) { var ctx = new AbilityContext { State = state, ActorId = actorId, Source = card }; - // Keep condition and duration behavior aligned with ActivateAbility. if (!ValidateSourceActivationConditions(def, ctx, card)) continue; diff --git a/Server/src/SOR.Game/Abilities/Models/AbilityDefinition.cs b/Server/src/SOR.Game/Abilities/Models/AbilityDefinition.cs index 785e0cb..89ab962 100644 --- a/Server/src/SOR.Game/Abilities/Models/AbilityDefinition.cs +++ b/Server/src/SOR.Game/Abilities/Models/AbilityDefinition.cs @@ -15,7 +15,7 @@ public enum AbilityType /// /// The top-level definition of a unit ability or card effect. -/// Stored as JSONB in CardDefinition.AbilitiesJson (array) and CardDefinition.EffectsJson. +/// Stored as JSONB in CardDefinition.AbilitiesJson (array) for all card types. /// /// All four ability types share the Action/Effect/Condition model. /// Type-specific fields are non-null only for the relevant type. diff --git a/Server/src/SOR.Game/GameEngine.cs b/Server/src/SOR.Game/GameEngine.cs index 142de30..f10012e 100644 --- a/Server/src/SOR.Game/GameEngine.cs +++ b/Server/src/SOR.Game/GameEngine.cs @@ -437,12 +437,11 @@ public static class GameEngine } else { - // Repentance, Instinct — pay cost, fire EffectsJson actions, then discard. + // Repentance, Instinct — pay cost, fire AbilitiesJson active abilities, then discard. player.Hand.Remove(card); player.CurrentSp -= card.SpCost; player.CurrentSt -= card.StCost; - // Fire inline effects if the card has an EffectsJson action list. AbilitySystem.FireCardEffects(state, actorId, card, cardTargets); player.Discard.Add(card); @@ -1293,7 +1292,6 @@ public static class GameEngine Tier = archSpiritDef.Tier, PreviousTierId = archSpiritDef.PreviousTierId, AbilitiesJson = archSpiritDef.AbilitiesJson, - EffectsJson = archSpiritDef.EffectsJson, }; ps.CurrentSp = 0; @@ -1332,7 +1330,6 @@ public static class GameEngine PreviousTierId = def.PreviousTierId, TerramorphaMode = def.TerramorphaMode, AbilitiesJson = def.AbilitiesJson, - EffectsJson = def.EffectsJson, Genus = def.Genus?.ToList(), }; @@ -1519,7 +1516,6 @@ public static class GameEngine PreviousTierId = source.PreviousTierId, TerramorphaMode = source.TerramorphaMode, AbilitiesJson = source.AbilitiesJson, - EffectsJson = source.EffectsJson, Genus = source.Genus?.ToList(), Position = position, }; @@ -1586,8 +1582,7 @@ public static class GameEngine AttackRequiresLos : c.RequiresLos, ExtraAttacksRemaining : c.ExtraAttacksRemaining, CanBeAttacked : c.CanBeAttacked, - AbilitiesJson : c.AbilitiesJson, - EffectsJson : c.EffectsJson); + AbilitiesJson : c.AbilitiesJson); } private static BoardDto ToBoardDto(Board board) diff --git a/Server/src/SOR.Game/GameMessages.cs b/Server/src/SOR.Game/GameMessages.cs index 8589868..099e0c7 100644 --- a/Server/src/SOR.Game/GameMessages.cs +++ b/Server/src/SOR.Game/GameMessages.cs @@ -555,7 +555,6 @@ public sealed record UnitDelta( int? MaxMp, int? ExtraAttacksRemaining, CoordDto? Position, - string? EffectsJson, string? AbilitiesJson, string? AbilityUsesJson); @@ -687,8 +686,7 @@ public sealed record CardInstanceDto( bool AttackRequiresLos, int ExtraAttacksRemaining, bool CanBeAttacked, - string? AbilitiesJson, - string? EffectsJson); + string? AbilitiesJson); public sealed record BoardDto( int Width, diff --git a/Server/src/SOR.Game/GameState.cs b/Server/src/SOR.Game/GameState.cs index 0171953..2502f82 100644 --- a/Server/src/SOR.Game/GameState.cs +++ b/Server/src/SOR.Game/GameState.cs @@ -273,12 +273,6 @@ public class CardInstance /// public string? AbilitiesJson { get; set; } - /// - /// Snapshot of CardDefinition.EffectsJson (for Repentance/Instinct/Ruin cards). - /// Format: JSON array of Action (resolved once when the card is channeled). - /// - public string? EffectsJson { get; set; } - /// /// Tracks Active ability uses this turn. Key = ability index, value = use count. /// Reset to empty at the start of the owning player's turn (in EndTurn). diff --git a/Server/src/SOR.Game/GameStateDiffer.cs b/Server/src/SOR.Game/GameStateDiffer.cs index 998e4c2..16651d8 100644 --- a/Server/src/SOR.Game/GameStateDiffer.cs +++ b/Server/src/SOR.Game/GameStateDiffer.cs @@ -250,7 +250,6 @@ internal static class GameStateDiffer prevC.MaxMp != nextC.MaxMp || prevC.ExtraAttacksRemaining != nextC.ExtraAttacksRemaining || prevFc?.Position != nextFc?.Position || - prevC.EffectsJson != nextC.EffectsJson || prevC.AbilitiesJson != nextC.AbilitiesJson || abilityUsesChanged; @@ -280,7 +279,6 @@ internal static class GameStateDiffer MaxMp : prevC.MaxMp != nextC.MaxMp ? nextC.MaxMp : null, ExtraAttacksRemaining : prevC.ExtraAttacksRemaining != nextC.ExtraAttacksRemaining ? nextC.ExtraAttacksRemaining : null, Position : positionDelta, - EffectsJson : prevC.EffectsJson != nextC.EffectsJson ? nextC.EffectsJson : null, AbilitiesJson : prevC.AbilitiesJson != nextC.AbilitiesJson ? nextC.AbilitiesJson : null, AbilityUsesJson : abilityUsesJson); }