From 068142914f01c6ca9e7be2e386d4605e01154e6b Mon Sep 17 00:00:00 2001 From: rfi Date: Sun, 25 Feb 2024 10:06:28 +0700 Subject: [PATCH] chaapter dbs but no tuse dyet --- BLHX.Server.Common/Database/Player.cs | 91 ++++- .../20240225030459_ChaptersDB.Designer.cs | 363 ++++++++++++++++++ .../Player/20240225030459_ChaptersDB.cs | 76 ++++ .../Player/PlayerContextModelSnapshot.cs | 105 +++++ 4 files changed, 634 insertions(+), 1 deletion(-) create mode 100644 BLHX.Server.Common/Migrations/Player/20240225030459_ChaptersDB.Designer.cs create mode 100644 BLHX.Server.Common/Migrations/Player/20240225030459_ChaptersDB.cs diff --git a/BLHX.Server.Common/Database/Player.cs b/BLHX.Server.Common/Database/Player.cs index a4d042c..719dc0c 100644 --- a/BLHX.Server.Common/Database/Player.cs +++ b/BLHX.Server.Common/Database/Player.cs @@ -1,10 +1,10 @@ using BLHX.Server.Common.Proto.common; using BLHX.Server.Common.Proto.p12; +using BLHX.Server.Common.Proto.p13; using BLHX.Server.Common.Utils; using Microsoft.EntityFrameworkCore; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using System.Numerics; namespace BLHX.Server.Common.Database { @@ -16,6 +16,7 @@ namespace BLHX.Server.Common.Database public DbSet Resources { get; set; } public DbSet ResourceFields { get; set; } public DbSet Ships { get; set; } + public DbSet ChapterInfoes { get; set; } public PlayerContext() { @@ -127,6 +128,31 @@ namespace BLHX.Server.Common.Database e.Property(b => b.CoreLists) .HasJsonConversion(); }); + modelBuilder.Entity(e => + { + e.Property(x => x.EscortLists) + .HasJsonConversion(); + e.Property(x => x.AiLists) + .HasJsonConversion(); + e.Property(x => x.BuffLists) + .HasJsonConversion(); + e.Property(x => x.GroupLists) + .HasJsonConversion(); + e.Property(x => x.BattleStatistics) + .HasJsonConversion(); + e.Property(x => x.CellFlagLists) + .HasJsonConversion(); + e.Property(x => x.CellLists) + .HasJsonConversion(); + e.Property(x => x.ChapterStrategyLists) + .HasJsonConversion(); + e.Property(x => x.ExtraFlagLists) + .HasJsonConversion(); + e.Property(x => x.FleetDuties) + .HasJsonConversion(); + e.Property(x => x.OperationBuffs) + .HasJsonConversion(); + }); } protected override void OnConfiguring(DbContextOptionsBuilder options) @@ -153,10 +179,12 @@ namespace BLHX.Server.Common.Database public List Fleets { get; set; } = null!; public List ShipSkins { get; set; } = null!; + public uint? CurrentChapter { get; set; } public virtual ICollection Resources { get; set; } = []; public virtual ICollection ResourceFields { get; set; } = []; public virtual ICollection Ships { get; set; } = []; + public virtual ICollection ChapterInfoes { get; set; } = []; public Player(string token, Displayinfo displayInfo, string name) { @@ -389,4 +417,65 @@ namespace BLHX.Server.Common.Database return amount; } } + + [PrimaryKey(nameof(Id), nameof(PlayerUid))] + public class ChapterInfo + { + [Key] + public uint Id { get; set; } + public DateTime Time { get; set; } + public List CellLists { get; set; } = []; + public List GroupLists { get; set; } = []; + public List AiLists { get; set; } = []; + public List EscortLists { get; set; } = []; + public uint Round { get; set; } + public bool IsSubmarineAutoAttack { get; set; } + public List OperationBuffs { get; set; } = []; + public uint ModelActCount { get; set; } + public List BuffLists { get; set; } = []; + public uint LoopFlag { get; set; } + public List ExtraFlagLists { get; set; } = []; + public List CellFlagLists { get; set; } = []; + public uint ChapterHp { get; set; } + public List ChapterStrategyLists { get; set; } = []; + public uint KillCount { get; set; } + public uint InitShipCount { get; set; } + public uint ContinuousKillCount { get; set; } + public List BattleStatistics { get; set; } = []; + public List FleetDuties { get; set; } = []; + public uint MoveStepCount { get; set; } + + [Key] + public uint PlayerUid { get; set; } + public virtual Player Player { get; set; } = null!; + + public Currentchapterinfo ToProto() + { + return new Currentchapterinfo() + { + Id = Id, + AiLists = AiLists, + BattleStatistics = BattleStatistics, + BuffLists = BuffLists, + CellFlagLists = CellFlagLists, + CellLists = CellLists, + ChapterHp = ChapterHp, + ChapterStrategyLists = ChapterStrategyLists, + ContinuousKillCount = ContinuousKillCount, + EscortLists = EscortLists, + ExtraFlagLists = ExtraFlagLists, + FleetDuties = FleetDuties, + GroupLists = GroupLists, + InitShipCount = InitShipCount, + IsSubmarineAutoAttack = Convert.ToUInt32(IsSubmarineAutoAttack), + KillCount = KillCount, + LoopFlag = LoopFlag, + ModelActCount = ModelActCount, + MoveStepCount = MoveStepCount, + OperationBuffs = OperationBuffs, + Round = Round, + Time = (uint)new DateTimeOffset(Time).ToUnixTimeSeconds() + }; + } + } } diff --git a/BLHX.Server.Common/Migrations/Player/20240225030459_ChaptersDB.Designer.cs b/BLHX.Server.Common/Migrations/Player/20240225030459_ChaptersDB.Designer.cs new file mode 100644 index 0000000..8774e1f --- /dev/null +++ b/BLHX.Server.Common/Migrations/Player/20240225030459_ChaptersDB.Designer.cs @@ -0,0 +1,363 @@ +// +using System; +using BLHX.Server.Common.Database; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace BLHX.Server.Common.Migrations.Player +{ + [DbContext(typeof(PlayerContext))] + [Migration("20240225030459_ChaptersDB")] + partial class ChaptersDB + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.2") + .HasAnnotation("Proxies:ChangeTracking", false) + .HasAnnotation("Proxies:CheckEquality", false) + .HasAnnotation("Proxies:LazyLoading", true); + + modelBuilder.Entity("BLHX.Server.Common.Database.ChapterInfo", b => + { + b.Property("Id") + .HasColumnType("INTEGER"); + + b.Property("PlayerUid") + .HasColumnType("INTEGER"); + + b.Property("AiLists") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("BattleStatistics") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("BuffLists") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("CellFlagLists") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("CellLists") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("ChapterHp") + .HasColumnType("INTEGER"); + + b.Property("ChapterStrategyLists") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("ContinuousKillCount") + .HasColumnType("INTEGER"); + + b.Property("EscortLists") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("ExtraFlagLists") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("FleetDuties") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("GroupLists") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("InitShipCount") + .HasColumnType("INTEGER"); + + b.Property("IsSubmarineAutoAttack") + .HasColumnType("INTEGER"); + + b.Property("KillCount") + .HasColumnType("INTEGER"); + + b.Property("LoopFlag") + .HasColumnType("INTEGER"); + + b.Property("ModelActCount") + .HasColumnType("INTEGER"); + + b.Property("MoveStepCount") + .HasColumnType("INTEGER"); + + b.Property("OperationBuffs") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("Round") + .HasColumnType("INTEGER"); + + b.Property("Time") + .HasColumnType("TEXT"); + + b.HasKey("Id", "PlayerUid"); + + b.HasIndex("PlayerUid"); + + b.ToTable("ChapterInfoes"); + }); + + modelBuilder.Entity("BLHX.Server.Common.Database.Player", b => + { + b.Property("Uid") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Adv") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("TEXT") + .HasDefaultValue(""); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("CurrentChapter") + .HasColumnType("INTEGER"); + + b.Property("DisplayInfo") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("Exp") + .HasColumnType("INTEGER"); + + b.Property("Fleets") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("jsonb") + .HasDefaultValue("[{\"Id\":1,\"Name\":null,\"ShipLists\":[1,2],\"Commanders\":[]},{\"Id\":2,\"Name\":null,\"ShipLists\":[],\"Commanders\":[]},{\"Id\":11,\"Name\":null,\"ShipLists\":[],\"Commanders\":[]},{\"Id\":12,\"Name\":null,\"ShipLists\":[],\"Commanders\":[]}]"); + + b.Property("Level") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ShipSkins") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("jsonb") + .HasDefaultValue("[]"); + + b.Property("Token") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Uid"); + + b.HasIndex("Token") + .IsUnique(); + + b.ToTable("Players"); + }); + + modelBuilder.Entity("BLHX.Server.Common.Database.PlayerResource", b => + { + b.Property("Id") + .HasColumnType("INTEGER"); + + b.Property("PlayerUid") + .HasColumnType("INTEGER"); + + b.Property("Num") + .HasColumnType("INTEGER"); + + b.HasKey("Id", "PlayerUid"); + + b.HasIndex("PlayerUid"); + + b.ToTable("Resources"); + }); + + modelBuilder.Entity("BLHX.Server.Common.Database.PlayerShip", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ActivityNpc") + .HasColumnType("INTEGER"); + + b.Property("BluePrintFlag") + .HasColumnType("INTEGER"); + + b.Property("CommanderId") + .HasColumnType("INTEGER"); + + b.Property("CommonFlag") + .HasColumnType("INTEGER"); + + b.Property("CoreLists") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("Energy") + .HasColumnType("INTEGER"); + + b.Property("EquipInfoLists") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("Exp") + .HasColumnType("INTEGER"); + + b.Property("Intimacy") + .HasColumnType("INTEGER"); + + b.Property("IsLocked") + .HasColumnType("INTEGER"); + + b.Property("LastChangeName") + .HasColumnType("TEXT"); + + b.Property("Level") + .HasColumnType("INTEGER"); + + b.Property("MetaRepairLists") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("PlayerUid") + .HasColumnType("INTEGER"); + + b.Property("Proficiency") + .HasColumnType("INTEGER"); + + b.Property("Propose") + .HasColumnType("INTEGER"); + + b.Property("SkillIdLists") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("SkinId") + .HasColumnType("INTEGER"); + + b.Property("State") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("StrengthLists") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("TemplateId") + .HasColumnType("INTEGER"); + + b.Property("TransformLists") + .IsRequired() + .HasColumnType("jsonb"); + + b.HasKey("Id"); + + b.HasIndex("PlayerUid"); + + b.ToTable("Ships"); + }); + + modelBuilder.Entity("BLHX.Server.Common.Database.ResourceField", b => + { + b.Property("Type") + .HasColumnType("INTEGER"); + + b.Property("PlayerUid") + .HasColumnType("INTEGER"); + + b.Property("LastHarvestTime") + .HasColumnType("TEXT"); + + b.Property("Level") + .HasColumnType("INTEGER"); + + b.Property("UpgradeTime") + .HasColumnType("TEXT"); + + b.HasKey("Type", "PlayerUid"); + + b.HasIndex("PlayerUid"); + + b.ToTable("ResourceFields"); + }); + + modelBuilder.Entity("BLHX.Server.Common.Database.ChapterInfo", b => + { + b.HasOne("BLHX.Server.Common.Database.Player", "Player") + .WithMany("ChapterInfoes") + .HasForeignKey("PlayerUid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Player"); + }); + + modelBuilder.Entity("BLHX.Server.Common.Database.PlayerResource", b => + { + b.HasOne("BLHX.Server.Common.Database.Player", "Player") + .WithMany("Resources") + .HasForeignKey("PlayerUid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Player"); + }); + + modelBuilder.Entity("BLHX.Server.Common.Database.PlayerShip", b => + { + b.HasOne("BLHX.Server.Common.Database.Player", "Player") + .WithMany("Ships") + .HasForeignKey("PlayerUid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Player"); + }); + + modelBuilder.Entity("BLHX.Server.Common.Database.ResourceField", b => + { + b.HasOne("BLHX.Server.Common.Database.Player", "Player") + .WithMany("ResourceFields") + .HasForeignKey("PlayerUid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Player"); + }); + + modelBuilder.Entity("BLHX.Server.Common.Database.Player", b => + { + b.Navigation("ChapterInfoes"); + + b.Navigation("ResourceFields"); + + b.Navigation("Resources"); + + b.Navigation("Ships"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/BLHX.Server.Common/Migrations/Player/20240225030459_ChaptersDB.cs b/BLHX.Server.Common/Migrations/Player/20240225030459_ChaptersDB.cs new file mode 100644 index 0000000..92f706e --- /dev/null +++ b/BLHX.Server.Common/Migrations/Player/20240225030459_ChaptersDB.cs @@ -0,0 +1,76 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace BLHX.Server.Common.Migrations.Player +{ + /// + public partial class ChaptersDB : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "CurrentChapter", + table: "Players", + type: "INTEGER", + nullable: true); + + migrationBuilder.CreateTable( + name: "ChapterInfoes", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false), + PlayerUid = table.Column(type: "INTEGER", nullable: false), + Time = table.Column(type: "TEXT", nullable: false), + CellLists = table.Column(type: "jsonb", nullable: false), + GroupLists = table.Column(type: "jsonb", nullable: false), + AiLists = table.Column(type: "jsonb", nullable: false), + EscortLists = table.Column(type: "jsonb", nullable: false), + Round = table.Column(type: "INTEGER", nullable: false), + IsSubmarineAutoAttack = table.Column(type: "INTEGER", nullable: false), + OperationBuffs = table.Column(type: "jsonb", nullable: false), + ModelActCount = table.Column(type: "INTEGER", nullable: false), + BuffLists = table.Column(type: "jsonb", nullable: false), + LoopFlag = table.Column(type: "INTEGER", nullable: false), + ExtraFlagLists = table.Column(type: "jsonb", nullable: false), + CellFlagLists = table.Column(type: "jsonb", nullable: false), + ChapterHp = table.Column(type: "INTEGER", nullable: false), + ChapterStrategyLists = table.Column(type: "jsonb", nullable: false), + KillCount = table.Column(type: "INTEGER", nullable: false), + InitShipCount = table.Column(type: "INTEGER", nullable: false), + ContinuousKillCount = table.Column(type: "INTEGER", nullable: false), + BattleStatistics = table.Column(type: "jsonb", nullable: false), + FleetDuties = table.Column(type: "jsonb", nullable: false), + MoveStepCount = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ChapterInfoes", x => new { x.Id, x.PlayerUid }); + table.ForeignKey( + name: "FK_ChapterInfoes_Players_PlayerUid", + column: x => x.PlayerUid, + principalTable: "Players", + principalColumn: "Uid", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_ChapterInfoes_PlayerUid", + table: "ChapterInfoes", + column: "PlayerUid"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "ChapterInfoes"); + + migrationBuilder.DropColumn( + name: "CurrentChapter", + table: "Players"); + } + } +} diff --git a/BLHX.Server.Common/Migrations/Player/PlayerContextModelSnapshot.cs b/BLHX.Server.Common/Migrations/Player/PlayerContextModelSnapshot.cs index ba786f6..01fb54b 100644 --- a/BLHX.Server.Common/Migrations/Player/PlayerContextModelSnapshot.cs +++ b/BLHX.Server.Common/Migrations/Player/PlayerContextModelSnapshot.cs @@ -21,6 +21,95 @@ namespace BLHX.Server.Common.Migrations.Player .HasAnnotation("Proxies:CheckEquality", false) .HasAnnotation("Proxies:LazyLoading", true); + modelBuilder.Entity("BLHX.Server.Common.Database.ChapterInfo", b => + { + b.Property("Id") + .HasColumnType("INTEGER"); + + b.Property("PlayerUid") + .HasColumnType("INTEGER"); + + b.Property("AiLists") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("BattleStatistics") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("BuffLists") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("CellFlagLists") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("CellLists") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("ChapterHp") + .HasColumnType("INTEGER"); + + b.Property("ChapterStrategyLists") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("ContinuousKillCount") + .HasColumnType("INTEGER"); + + b.Property("EscortLists") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("ExtraFlagLists") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("FleetDuties") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("GroupLists") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("InitShipCount") + .HasColumnType("INTEGER"); + + b.Property("IsSubmarineAutoAttack") + .HasColumnType("INTEGER"); + + b.Property("KillCount") + .HasColumnType("INTEGER"); + + b.Property("LoopFlag") + .HasColumnType("INTEGER"); + + b.Property("ModelActCount") + .HasColumnType("INTEGER"); + + b.Property("MoveStepCount") + .HasColumnType("INTEGER"); + + b.Property("OperationBuffs") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("Round") + .HasColumnType("INTEGER"); + + b.Property("Time") + .HasColumnType("TEXT"); + + b.HasKey("Id", "PlayerUid"); + + b.HasIndex("PlayerUid"); + + b.ToTable("ChapterInfoes"); + }); + modelBuilder.Entity("BLHX.Server.Common.Database.Player", b => { b.Property("Uid") @@ -36,6 +125,9 @@ namespace BLHX.Server.Common.Migrations.Player b.Property("CreatedAt") .HasColumnType("TEXT"); + b.Property("CurrentChapter") + .HasColumnType("INTEGER"); + b.Property("DisplayInfo") .IsRequired() .HasColumnType("jsonb"); @@ -208,6 +300,17 @@ namespace BLHX.Server.Common.Migrations.Player b.ToTable("ResourceFields"); }); + modelBuilder.Entity("BLHX.Server.Common.Database.ChapterInfo", b => + { + b.HasOne("BLHX.Server.Common.Database.Player", "Player") + .WithMany("ChapterInfoes") + .HasForeignKey("PlayerUid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Player"); + }); + modelBuilder.Entity("BLHX.Server.Common.Database.PlayerResource", b => { b.HasOne("BLHX.Server.Common.Database.Player", "Player") @@ -243,6 +346,8 @@ namespace BLHX.Server.Common.Migrations.Player modelBuilder.Entity("BLHX.Server.Common.Database.Player", b => { + b.Navigation("ChapterInfoes"); + b.Navigation("ResourceFields"); b.Navigation("Resources");