feat(packs): add PackDraw* tables and IsEnabled column
Three new EF entities and a migration:
- PackDrawConfigEntry (per-pack: animation rate, has-bonus flag, special-kind label)
- PackDrawSlotRateEntry (pack/slot/tier -> rate, unique index)
- PackDrawCardWeightEntry (per-card-rate facts incl rate-less rows)
DrawSlot {General, Eighth, Bonus} and DrawTier {Bronze, Silver, Gold, Legendary, Special}.
Special collapses leader_card and limited_time_leader (verified mutually exclusive per pack).
IsEnabled column on PackConfigEntry — admin gate for synthesized stubs, distinct from
the wire-mirror IsHide.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
8
SVSim.Database/Enums/DrawSlot.cs
Normal file
8
SVSim.Database/Enums/DrawSlot.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace SVSim.Database.Enums;
|
||||
|
||||
public enum DrawSlot
|
||||
{
|
||||
General = 0,
|
||||
Eighth = 1,
|
||||
Bonus = 2,
|
||||
}
|
||||
16
SVSim.Database/Enums/DrawTier.cs
Normal file
16
SVSim.Database/Enums/DrawTier.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
namespace SVSim.Database.Enums;
|
||||
|
||||
/// <summary>
|
||||
/// Per-draw page tier the slot rolls into. Distinct from card-master <see cref="Rarity"/>:
|
||||
/// for the four base values they line up, but <c>Special</c> covers the per-pack
|
||||
/// "Leader Card" / "Limited-Time Leader" tiers — its cards are typically Rarity.Legendary
|
||||
/// with the IsLeader printing flag set.
|
||||
/// </summary>
|
||||
public enum DrawTier
|
||||
{
|
||||
Bronze = 0,
|
||||
Silver = 1,
|
||||
Gold = 2,
|
||||
Legendary = 3,
|
||||
Special = 4,
|
||||
}
|
||||
3930
SVSim.Database/Migrations/20260531013928_AddPackDrawTable.Designer.cs
generated
Normal file
3930
SVSim.Database/Migrations/20260531013928_AddPackDrawTable.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
107
SVSim.Database/Migrations/20260531013928_AddPackDrawTable.cs
Normal file
107
SVSim.Database/Migrations/20260531013928_AddPackDrawTable.cs
Normal file
@@ -0,0 +1,107 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace SVSim.Database.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddPackDrawTable : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "IsEnabled",
|
||||
table: "Packs",
|
||||
type: "boolean",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "PackDrawCardWeights",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<long>(type: "bigint", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
PackId = table.Column<int>(type: "integer", nullable: false),
|
||||
Slot = table.Column<int>(type: "integer", nullable: false),
|
||||
Tier = table.Column<int>(type: "integer", nullable: false),
|
||||
CardId = table.Column<long>(type: "bigint", nullable: false),
|
||||
RatePct = table.Column<double>(type: "double precision", nullable: true),
|
||||
IsLeader = table.Column<bool>(type: "boolean", nullable: false),
|
||||
IsAltArt = table.Column<bool>(type: "boolean", nullable: false),
|
||||
DateCreated = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||
DateUpdated = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_PackDrawCardWeights", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "PackDrawConfigs",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false),
|
||||
AnimationRatePct = table.Column<double>(type: "double precision", nullable: false),
|
||||
HasBonusSlot = table.Column<bool>(type: "boolean", nullable: false),
|
||||
SpecialKind = table.Column<string>(type: "text", nullable: true),
|
||||
ShortCode = table.Column<string>(type: "text", nullable: true),
|
||||
DateCreated = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||
DateUpdated = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_PackDrawConfigs", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "PackDrawSlotRates",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<long>(type: "bigint", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
PackId = table.Column<int>(type: "integer", nullable: false),
|
||||
Slot = table.Column<int>(type: "integer", nullable: false),
|
||||
Tier = table.Column<int>(type: "integer", nullable: false),
|
||||
RatePct = table.Column<double>(type: "double precision", nullable: false),
|
||||
DateCreated = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||
DateUpdated = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_PackDrawSlotRates", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PackDrawCardWeights_PackId_Slot_Tier",
|
||||
table: "PackDrawCardWeights",
|
||||
columns: new[] { "PackId", "Slot", "Tier" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PackDrawSlotRates_PackId_Slot_Tier",
|
||||
table: "PackDrawSlotRates",
|
||||
columns: new[] { "PackId", "Slot", "Tier" },
|
||||
unique: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "PackDrawCardWeights");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "PackDrawConfigs");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "PackDrawSlotRates");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "IsEnabled",
|
||||
table: "Packs");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1500,6 +1500,9 @@ namespace SVSim.Database.Migrations
|
||||
b.Property<int>("GachaType")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<bool>("IsEnabled")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<bool>("IsHide")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
@@ -1538,6 +1541,110 @@ namespace SVSim.Database.Migrations
|
||||
b.ToTable("Packs");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SVSim.Database.Models.PackDrawCardWeightEntry", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<long>("CardId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<DateTime>("DateCreated")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime?>("DateUpdated")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<bool>("IsAltArt")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<bool>("IsLeader")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<int>("PackId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<double?>("RatePct")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<int>("Slot")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Tier")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PackId", "Slot", "Tier");
|
||||
|
||||
b.ToTable("PackDrawCardWeights");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SVSim.Database.Models.PackDrawConfigEntry", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<double>("AnimationRatePct")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<DateTime>("DateCreated")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime?>("DateUpdated")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<bool>("HasBonusSlot")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<string>("ShortCode")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("SpecialKind")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("PackDrawConfigs");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SVSim.Database.Models.PackDrawSlotRateEntry", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<DateTime>("DateCreated")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime?>("DateUpdated")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int>("PackId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<double>("RatePct")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<int>("Slot")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Tier")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PackId", "Slot", "Tier")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("PackDrawSlotRates");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SVSim.Database.Models.PaymentItemEntry", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
|
||||
@@ -33,6 +33,13 @@ public class PackConfigEntry : BaseEntity<int>
|
||||
|
||||
public int OpenCountLimit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Server admin gate. True for live-capture-derived rows; false for synthesized stubs
|
||||
/// (operator opt-in per pack). Filtered in PackRepository.GetActivePacks; distinct from
|
||||
/// the wire-mirror IsHide.
|
||||
/// </summary>
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
|
||||
public PackGachaPointConfig? GachaPointConfig { get; set; }
|
||||
|
||||
public List<PackBannerEntry> Banners { get; set; } = new();
|
||||
|
||||
24
SVSim.Database/Models/PackDrawCardWeightEntry.cs
Normal file
24
SVSim.Database/Models/PackDrawCardWeightEntry.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using SVSim.Database.Common;
|
||||
using SVSim.Database.Enums;
|
||||
|
||||
namespace SVSim.Database.Models;
|
||||
|
||||
/// <summary>
|
||||
/// Per-card-rate fact: which card prints in which (pack, slot, tier) at what rate.
|
||||
/// RatePct is nullable for rate-less "Guaranteed Leader Card" rows (sampler uses
|
||||
/// "uniform over (pool minus owned)" in that case).
|
||||
/// </summary>
|
||||
public class PackDrawCardWeightEntry : BaseEntity<long>
|
||||
{
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public override long Id { get; set; }
|
||||
|
||||
public int PackId { get; set; }
|
||||
public DrawSlot Slot { get; set; }
|
||||
public DrawTier Tier { get; set; }
|
||||
public long CardId { get; set; }
|
||||
public double? RatePct { get; set; }
|
||||
public bool IsLeader { get; set; }
|
||||
public bool IsAltArt { get; set; }
|
||||
}
|
||||
16
SVSim.Database/Models/PackDrawConfigEntry.cs
Normal file
16
SVSim.Database/Models/PackDrawConfigEntry.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using SVSim.Database.Common;
|
||||
|
||||
namespace SVSim.Database.Models;
|
||||
|
||||
/// <summary>
|
||||
/// One row per pack covered by drawrates data. PK is the pack id (matches PackConfigEntry.Id
|
||||
/// for live-capture rows; standalone for archive-only packs). Weak relationship — PackDraw rows
|
||||
/// exist for all archived packs even when no PackConfigEntry is enabled.
|
||||
/// </summary>
|
||||
public class PackDrawConfigEntry : BaseEntity<int>
|
||||
{
|
||||
public double AnimationRatePct { get; set; }
|
||||
public bool HasBonusSlot { get; set; }
|
||||
public string? SpecialKind { get; set; }
|
||||
public string? ShortCode { get; set; }
|
||||
}
|
||||
20
SVSim.Database/Models/PackDrawSlotRateEntry.cs
Normal file
20
SVSim.Database/Models/PackDrawSlotRateEntry.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using SVSim.Database.Common;
|
||||
using SVSim.Database.Enums;
|
||||
|
||||
namespace SVSim.Database.Models;
|
||||
|
||||
/// <summary>
|
||||
/// Per (pack, slot, tier) rate. Natural key (PackId, Slot, Tier) is enforced via unique index.
|
||||
/// Id is auto-generated — override BaseEntity's [DatabaseGenerated(None)] default.
|
||||
/// </summary>
|
||||
public class PackDrawSlotRateEntry : BaseEntity<long>
|
||||
{
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public override long Id { get; set; }
|
||||
|
||||
public int PackId { get; set; }
|
||||
public DrawSlot Slot { get; set; }
|
||||
public DrawTier Tier { get; set; }
|
||||
public double RatePct { get; set; }
|
||||
}
|
||||
@@ -68,6 +68,9 @@ public class SVSimDbContext : DbContext
|
||||
public DbSet<SpecialDeckFormatEntry> SpecialDeckFormats => Set<SpecialDeckFormatEntry>();
|
||||
public DbSet<PaymentItemEntry> PaymentItems => Set<PaymentItemEntry>();
|
||||
public DbSet<PackConfigEntry> Packs => Set<PackConfigEntry>();
|
||||
public DbSet<PackDrawConfigEntry> PackDrawConfigs => Set<PackDrawConfigEntry>();
|
||||
public DbSet<PackDrawSlotRateEntry> PackDrawSlotRates => Set<PackDrawSlotRateEntry>();
|
||||
public DbSet<PackDrawCardWeightEntry> PackDrawCardWeights => Set<PackDrawCardWeightEntry>();
|
||||
public DbSet<BuildDeckSeriesEntry> BuildDeckSeries => Set<BuildDeckSeriesEntry>();
|
||||
public DbSet<BuildDeckProductEntry> BuildDeckProducts => Set<BuildDeckProductEntry>();
|
||||
public DbSet<StoryDeckEntry> StoryDecks => Set<StoryDeckEntry>();
|
||||
@@ -146,6 +149,15 @@ public class SVSimDbContext : DbContext
|
||||
|
||||
modelBuilder.Entity<PackConfigEntry>().OwnsMany(p => p.ChildGachas);
|
||||
modelBuilder.Entity<PackConfigEntry>().OwnsMany(p => p.Banners);
|
||||
|
||||
modelBuilder.Entity<PackDrawSlotRateEntry>(e =>
|
||||
{
|
||||
e.HasIndex(x => new { x.PackId, x.Slot, x.Tier }).IsUnique();
|
||||
});
|
||||
modelBuilder.Entity<PackDrawCardWeightEntry>(e =>
|
||||
{
|
||||
e.HasIndex(x => new { x.PackId, x.Slot, x.Tier });
|
||||
});
|
||||
modelBuilder.Entity<Viewer>().OwnsMany(v => v.PackOpenCounts);
|
||||
|
||||
// OwnedCardEntry and OwnedItemEntry use composite PK (ViewerId, Id) where Id is auto-
|
||||
|
||||
Reference in New Issue
Block a user