From bbe0d7ab11141b293b1339fd10070a30fd68608b Mon Sep 17 00:00:00 2001 From: raphaeIl Date: Fri, 5 Apr 2024 01:35:08 -0400 Subject: [PATCH] added all params to player database --- BLHX.Server.Common/Database/Player.cs | 111 +++- .../20240220103529_Init_PlayerContext.cs | 1 - ...240405053357_Players_AddParams.Designer.cs | 583 ++++++++++++++++++ .../20240405053357_Players_AddParams.cs | 441 +++++++++++++ .../Player/PlayerContextModelSnapshot.cs | 220 +++++++ .../Commands/SetPlayerDataCommand.cs | 50 ++ BLHX.Server.Game/Commands/ShipCommand.cs | 4 +- BLHX.Server.Game/Handlers/P11.cs | 45 +- BLHX.Server.Game/Handlers/P12.cs | 4 +- 9 files changed, 1437 insertions(+), 22 deletions(-) create mode 100644 BLHX.Server.Common/Migrations/Player/20240405053357_Players_AddParams.Designer.cs create mode 100644 BLHX.Server.Common/Migrations/Player/20240405053357_Players_AddParams.cs create mode 100644 BLHX.Server.Game/Commands/SetPlayerDataCommand.cs diff --git a/BLHX.Server.Common/Database/Player.cs b/BLHX.Server.Common/Database/Player.cs index 85048eb..6ec231c 100644 --- a/BLHX.Server.Common/Database/Player.cs +++ b/BLHX.Server.Common/Database/Player.cs @@ -74,6 +74,8 @@ namespace BLHX.Server.Common.Database { modelBuilder.Entity(e => { e.Property(b => b.DisplayInfo) .HasJsonConversion(); + e.Property(b => b.Appreciation) + .HasJsonConversion(); e.Property(b => b.Fleets) .HasJsonConversion() .HasDefaultValue(new List() { @@ -99,6 +101,11 @@ namespace BLHX.Server.Common.Database { .WithOne(e => e.Player) .HasForeignKey(e => e.PlayerUid) .IsRequired(); + e.OwnsOne(x => x.RefundShopInfoLists); + e.OwnsOne(x => x.CardLists); + e.OwnsOne(x => x.CdLists); + e.OwnsOne(x => x.TakingShipLists); + }); modelBuilder.Entity(e => { e.Property(b => b.Id) @@ -153,26 +160,113 @@ namespace BLHX.Server.Common.Database { [PrimaryKey(nameof(Uid))] [Index(nameof(Token), IsUnique = true)] public class Player { + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public uint Uid { get; set; } - public string Token { get; set; } + public string Name { get; set; } - // Aka. manifesto - public string Adv { get; set; } = string.Empty; - public uint ShipBagMax { get; set; } = 9854938; + public uint Level { get; set; } - // TODO: Exp add setter to recalculate cap and set level - public uint Exp { get; set; } + + public uint Exp { get; set; } // TODO: Exp add setter to recalculate cap and set level + + public uint AttackCount { get; set; } + + public uint WinCount { get; set; } + + public string Adv { get; set; } = string.Empty; // Aka. manifesto + + public uint ShipBagMax { get; set; } = 150; + + public uint EquipBagMax { get; set; } = 250; + + public uint GmFlag { get; set; } = 1; + + public uint Rank { get; set; } = 1; + + public uint PvpAttackCount { get; set; } + + public uint PvpWinCount { get; set; } + + public uint CollectAttackCount { get; set; } + + public uint GuideIndex { get; set; } = 1000000; + + public uint BuyOilCount { get; set; } + + public uint ChatRoomId { get; set; } = 1; + + public uint MaxRank { get; set; } + + public uint ShipCount { get { return (uint)Ships.Count; } } + + public uint AccPayLv { get; set; } + + public uint GuildWaitTime { get; set; } + + public uint ChatMsgBanTime { get; set; } + + public uint CommanderBagMax { get; set; } = 40; + public Displayinfo DisplayInfo { get; set; } + + public uint Rmb { get; set; } + + public Appreciationinfo Appreciation { get; set; } + + public uint ThemeUploadNotAllowedTime { get; set; } + + public uint RandomShipMode { get; set; } + + public uint MarryShip { get; set; } + + public uint ChildDisplay { get; set; } + public DateTime CreatedAt { get; set; } - public List Fleets { get; set; } = null!; - public List ShipSkins { get; set; } = null!; + public List Characters { get; set; } = [1]; + + public List StoryLists { get; set; } = []; + + public List FlagLists { get; set; } = []; + + public List MedalIds { get; set; } = []; + + public List CartoonReadMarks { get; set; } = []; + + public List CartoonCollectMarks { get; set; } = []; + + public List RandomShipLists { get; set; } = []; + + public List Soundstories { get; set; } = []; + + public virtual List CardLists { get; set; } = []; + + public virtual List CdLists { get; set; } = []; + + public virtual List IconFrameLists { get; set; } = []; + + public virtual List ChatFrameLists { get; set; } = []; + + public virtual List RefundShopInfoLists { get; set; } = []; + + public virtual List TakingShipLists { get; set; } = []; + + // + public string Token { get; set; } + public uint? CurrentChapter { get; set; } + public List Fleets { get; set; } = null!; + + public List ShipSkins { get; set; } = null!; + 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) { @@ -181,6 +275,7 @@ namespace BLHX.Server.Common.Database { Name = name; Level = 1; CreatedAt = DateTime.Now; + Appreciation = new Appreciationinfo() { Gallerys = [], Musics = [], FavorGallerys = [], FavorMusics = [] }; } public void DoResource(uint id, int num) { diff --git a/BLHX.Server.Common/Migrations/Player/20240220103529_Init_PlayerContext.cs b/BLHX.Server.Common/Migrations/Player/20240220103529_Init_PlayerContext.cs index c551be4..860ee18 100644 --- a/BLHX.Server.Common/Migrations/Player/20240220103529_Init_PlayerContext.cs +++ b/BLHX.Server.Common/Migrations/Player/20240220103529_Init_PlayerContext.cs @@ -17,7 +17,6 @@ namespace BLHX.Server.Common.Migrations.Player { Name = table.Column(type: "TEXT", nullable: false), Level = table.Column(type: "INTEGER", nullable: false), Exp = table.Column(type: "INTEGER", nullable: false), - ShipBagMax = table.Column(type: "INTEGER", nullable: false), DisplayInfo = table.Column(type: "jsonb", nullable: false), CreatedAt = table.Column(type: "TEXT", nullable: false) }, diff --git a/BLHX.Server.Common/Migrations/Player/20240405053357_Players_AddParams.Designer.cs b/BLHX.Server.Common/Migrations/Player/20240405053357_Players_AddParams.Designer.cs new file mode 100644 index 0000000..7c5f11b --- /dev/null +++ b/BLHX.Server.Common/Migrations/Player/20240405053357_Players_AddParams.Designer.cs @@ -0,0 +1,583 @@ +// +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("20240405053357_Players_AddParams")] + partial class Players_AddParams + { + /// + 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("AccPayLv") + .HasColumnType("INTEGER"); + + b.Property("Adv") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("TEXT") + .HasDefaultValue(""); + + b.Property("Appreciation") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("AttackCount") + .HasColumnType("INTEGER"); + + b.Property("BuyOilCount") + .HasColumnType("INTEGER"); + + b.Property("CartoonCollectMarks") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("CartoonReadMarks") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Characters") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ChatMsgBanTime") + .HasColumnType("INTEGER"); + + b.Property("ChatRoomId") + .HasColumnType("INTEGER"); + + b.Property("ChildDisplay") + .HasColumnType("INTEGER"); + + b.Property("CollectAttackCount") + .HasColumnType("INTEGER"); + + b.Property("CommanderBagMax") + .HasColumnType("INTEGER"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("CurrentChapter") + .HasColumnType("INTEGER"); + + b.Property("DisplayInfo") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("EquipBagMax") + .HasColumnType("INTEGER"); + + b.Property("Exp") + .HasColumnType("INTEGER"); + + b.Property("FlagLists") + .IsRequired() + .HasColumnType("TEXT"); + + 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("GmFlag") + .HasColumnType("INTEGER"); + + b.Property("GuideIndex") + .HasColumnType("INTEGER"); + + b.Property("GuildWaitTime") + .HasColumnType("INTEGER"); + + b.Property("Level") + .HasColumnType("INTEGER"); + + b.Property("MarryShip") + .HasColumnType("INTEGER"); + + b.Property("MaxRank") + .HasColumnType("INTEGER"); + + b.Property("MedalIds") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("PvpAttackCount") + .HasColumnType("INTEGER"); + + b.Property("PvpWinCount") + .HasColumnType("INTEGER"); + + b.Property("RandomShipLists") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("RandomShipMode") + .HasColumnType("INTEGER"); + + b.Property("Rank") + .HasColumnType("INTEGER"); + + b.Property("Rmb") + .HasColumnType("INTEGER"); + + b.Property("ShipBagMax") + .HasColumnType("INTEGER"); + + b.Property("ShipSkins") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("jsonb") + .HasDefaultValue("[]"); + + b.Property("Soundstories") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("StoryLists") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ThemeUploadNotAllowedTime") + .HasColumnType("INTEGER"); + + b.Property("Token") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("WinCount") + .HasColumnType("INTEGER"); + + 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.Proto.common.Idtimeinfo", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("PlayerUid") + .HasColumnType("INTEGER"); + + b.Property("PlayerUid1") + .HasColumnType("INTEGER"); + + b.Property("Time") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("PlayerUid"); + + b.HasIndex("PlayerUid1"); + + b.ToTable("Idtimeinfo"); + }); + + 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.Player", b => + { + b.OwnsOne("System.Collections.Generic.List", "RefundShopInfoLists", b1 => + { + b1.Property("PlayerUid") + .HasColumnType("INTEGER"); + + b1.Property("Capacity") + .HasColumnType("INTEGER"); + + b1.HasKey("PlayerUid"); + + b1.ToTable("Players"); + + b1.WithOwner() + .HasForeignKey("PlayerUid"); + }); + + b.OwnsOne("System.Collections.Generic.List", "CardLists", b1 => + { + b1.Property("PlayerUid") + .HasColumnType("INTEGER"); + + b1.Property("Capacity") + .HasColumnType("INTEGER"); + + b1.HasKey("PlayerUid"); + + b1.ToTable("Players"); + + b1.WithOwner() + .HasForeignKey("PlayerUid"); + }); + + b.OwnsOne("System.Collections.Generic.List", "CdLists", b1 => + { + b1.Property("PlayerUid") + .HasColumnType("INTEGER"); + + b1.Property("Capacity") + .HasColumnType("INTEGER"); + + b1.HasKey("PlayerUid"); + + b1.ToTable("Players"); + + b1.WithOwner() + .HasForeignKey("PlayerUid"); + }); + + b.OwnsOne("System.Collections.Generic.List", "TakingShipLists", b1 => + { + b1.Property("PlayerUid") + .HasColumnType("INTEGER"); + + b1.Property("Capacity") + .HasColumnType("INTEGER"); + + b1.HasKey("PlayerUid"); + + b1.ToTable("Players"); + + b1.WithOwner() + .HasForeignKey("PlayerUid"); + }); + + b.Navigation("CardLists") + .IsRequired(); + + b.Navigation("CdLists") + .IsRequired(); + + b.Navigation("RefundShopInfoLists") + .IsRequired(); + + b.Navigation("TakingShipLists") + .IsRequired(); + }); + + 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.Proto.common.Idtimeinfo", b => + { + b.HasOne("BLHX.Server.Common.Database.Player", null) + .WithMany("ChatFrameLists") + .HasForeignKey("PlayerUid"); + + b.HasOne("BLHX.Server.Common.Database.Player", null) + .WithMany("IconFrameLists") + .HasForeignKey("PlayerUid1"); + }); + + modelBuilder.Entity("BLHX.Server.Common.Database.Player", b => + { + b.Navigation("ChapterInfoes"); + + b.Navigation("ChatFrameLists"); + + b.Navigation("IconFrameLists"); + + b.Navigation("ResourceFields"); + + b.Navigation("Resources"); + + b.Navigation("Ships"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/BLHX.Server.Common/Migrations/Player/20240405053357_Players_AddParams.cs b/BLHX.Server.Common/Migrations/Player/20240405053357_Players_AddParams.cs new file mode 100644 index 0000000..a83b3a5 --- /dev/null +++ b/BLHX.Server.Common/Migrations/Player/20240405053357_Players_AddParams.cs @@ -0,0 +1,441 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace BLHX.Server.Common.Migrations.Player +{ + /// + public partial class Players_AddParams : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "AccPayLv", + table: "Players", + type: "INTEGER", + nullable: false, + defaultValue: 0u); + + migrationBuilder.AddColumn( + name: "Appreciation", + table: "Players", + type: "jsonb", + nullable: false, + defaultValue: ""); + + migrationBuilder.AddColumn( + name: "AttackCount", + table: "Players", + type: "INTEGER", + nullable: false, + defaultValue: 0u); + + migrationBuilder.AddColumn( + name: "BuyOilCount", + table: "Players", + type: "INTEGER", + nullable: false, + defaultValue: 0u); + + migrationBuilder.AddColumn( + name: "CardLists_Capacity", + table: "Players", + type: "INTEGER", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "CartoonCollectMarks", + table: "Players", + type: "TEXT", + nullable: false, + defaultValue: ""); + + migrationBuilder.AddColumn( + name: "CartoonReadMarks", + table: "Players", + type: "TEXT", + nullable: false, + defaultValue: ""); + + migrationBuilder.AddColumn( + name: "CdLists_Capacity", + table: "Players", + type: "INTEGER", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "Characters", + table: "Players", + type: "TEXT", + nullable: false, + defaultValue: ""); + + migrationBuilder.AddColumn( + name: "ChatMsgBanTime", + table: "Players", + type: "INTEGER", + nullable: false, + defaultValue: 0u); + + migrationBuilder.AddColumn( + name: "ChatRoomId", + table: "Players", + type: "INTEGER", + nullable: false, + defaultValue: 0u); + + migrationBuilder.AddColumn( + name: "ChildDisplay", + table: "Players", + type: "INTEGER", + nullable: false, + defaultValue: 0u); + + migrationBuilder.AddColumn( + name: "CollectAttackCount", + table: "Players", + type: "INTEGER", + nullable: false, + defaultValue: 0u); + + migrationBuilder.AddColumn( + name: "CommanderBagMax", + table: "Players", + type: "INTEGER", + nullable: false, + defaultValue: 0u); + + migrationBuilder.AddColumn( + name: "EquipBagMax", + table: "Players", + type: "INTEGER", + nullable: false, + defaultValue: 0u); + + migrationBuilder.AddColumn( + name: "FlagLists", + table: "Players", + type: "TEXT", + nullable: false, + defaultValue: ""); + + migrationBuilder.AddColumn( + name: "GmFlag", + table: "Players", + type: "INTEGER", + nullable: false, + defaultValue: 0u); + + migrationBuilder.AddColumn( + name: "GuideIndex", + table: "Players", + type: "INTEGER", + nullable: false, + defaultValue: 0u); + + migrationBuilder.AddColumn( + name: "GuildWaitTime", + table: "Players", + type: "INTEGER", + nullable: false, + defaultValue: 0u); + + migrationBuilder.AddColumn( + name: "MarryShip", + table: "Players", + type: "INTEGER", + nullable: false, + defaultValue: 0u); + + migrationBuilder.AddColumn( + name: "MaxRank", + table: "Players", + type: "INTEGER", + nullable: false, + defaultValue: 0u); + + migrationBuilder.AddColumn( + name: "MedalIds", + table: "Players", + type: "TEXT", + nullable: false, + defaultValue: ""); + + migrationBuilder.AddColumn( + name: "PvpAttackCount", + table: "Players", + type: "INTEGER", + nullable: false, + defaultValue: 0u); + + migrationBuilder.AddColumn( + name: "PvpWinCount", + table: "Players", + type: "INTEGER", + nullable: false, + defaultValue: 0u); + + migrationBuilder.AddColumn( + name: "RandomShipLists", + table: "Players", + type: "TEXT", + nullable: false, + defaultValue: ""); + + migrationBuilder.AddColumn( + name: "RandomShipMode", + table: "Players", + type: "INTEGER", + nullable: false, + defaultValue: 0u); + + migrationBuilder.AddColumn( + name: "Rank", + table: "Players", + type: "INTEGER", + nullable: false, + defaultValue: 0u); + + migrationBuilder.AddColumn( + name: "RefundShopInfoLists_Capacity", + table: "Players", + type: "INTEGER", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "Rmb", + table: "Players", + type: "INTEGER", + nullable: false, + defaultValue: 0u); + + migrationBuilder.AddColumn( + name: "ShipBagMax", + table: "Players", + type: "INTEGER", + nullable: false, + defaultValue: 0u); + + migrationBuilder.AddColumn( + name: "Soundstories", + table: "Players", + type: "TEXT", + nullable: false, + defaultValue: ""); + + migrationBuilder.AddColumn( + name: "StoryLists", + table: "Players", + type: "TEXT", + nullable: false, + defaultValue: ""); + + migrationBuilder.AddColumn( + name: "TakingShipLists_Capacity", + table: "Players", + type: "INTEGER", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "ThemeUploadNotAllowedTime", + table: "Players", + type: "INTEGER", + nullable: false, + defaultValue: 0u); + + migrationBuilder.AddColumn( + name: "WinCount", + table: "Players", + type: "INTEGER", + nullable: false, + defaultValue: 0u); + + migrationBuilder.CreateTable( + name: "Idtimeinfo", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Time = table.Column(type: "INTEGER", nullable: false), + PlayerUid = table.Column(type: "INTEGER", nullable: true), + PlayerUid1 = table.Column(type: "INTEGER", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Idtimeinfo", x => x.Id); + table.ForeignKey( + name: "FK_Idtimeinfo_Players_PlayerUid", + column: x => x.PlayerUid, + principalTable: "Players", + principalColumn: "Uid"); + table.ForeignKey( + name: "FK_Idtimeinfo_Players_PlayerUid1", + column: x => x.PlayerUid1, + principalTable: "Players", + principalColumn: "Uid"); + }); + + migrationBuilder.CreateIndex( + name: "IX_Idtimeinfo_PlayerUid", + table: "Idtimeinfo", + column: "PlayerUid"); + + migrationBuilder.CreateIndex( + name: "IX_Idtimeinfo_PlayerUid1", + table: "Idtimeinfo", + column: "PlayerUid1"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Idtimeinfo"); + + migrationBuilder.DropColumn( + name: "AccPayLv", + table: "Players"); + + migrationBuilder.DropColumn( + name: "Appreciation", + table: "Players"); + + migrationBuilder.DropColumn( + name: "AttackCount", + table: "Players"); + + migrationBuilder.DropColumn( + name: "BuyOilCount", + table: "Players"); + + migrationBuilder.DropColumn( + name: "CardLists_Capacity", + table: "Players"); + + migrationBuilder.DropColumn( + name: "CartoonCollectMarks", + table: "Players"); + + migrationBuilder.DropColumn( + name: "CartoonReadMarks", + table: "Players"); + + migrationBuilder.DropColumn( + name: "CdLists_Capacity", + table: "Players"); + + migrationBuilder.DropColumn( + name: "Characters", + table: "Players"); + + migrationBuilder.DropColumn( + name: "ChatMsgBanTime", + table: "Players"); + + migrationBuilder.DropColumn( + name: "ChatRoomId", + table: "Players"); + + migrationBuilder.DropColumn( + name: "ChildDisplay", + table: "Players"); + + migrationBuilder.DropColumn( + name: "CollectAttackCount", + table: "Players"); + + migrationBuilder.DropColumn( + name: "CommanderBagMax", + table: "Players"); + + migrationBuilder.DropColumn( + name: "EquipBagMax", + table: "Players"); + + migrationBuilder.DropColumn( + name: "FlagLists", + table: "Players"); + + migrationBuilder.DropColumn( + name: "GmFlag", + table: "Players"); + + migrationBuilder.DropColumn( + name: "GuideIndex", + table: "Players"); + + migrationBuilder.DropColumn( + name: "GuildWaitTime", + table: "Players"); + + migrationBuilder.DropColumn( + name: "MarryShip", + table: "Players"); + + migrationBuilder.DropColumn( + name: "MaxRank", + table: "Players"); + + migrationBuilder.DropColumn( + name: "MedalIds", + table: "Players"); + + migrationBuilder.DropColumn( + name: "PvpAttackCount", + table: "Players"); + + migrationBuilder.DropColumn( + name: "PvpWinCount", + table: "Players"); + + migrationBuilder.DropColumn( + name: "RandomShipLists", + table: "Players"); + + migrationBuilder.DropColumn( + name: "RandomShipMode", + table: "Players"); + + migrationBuilder.DropColumn( + name: "Rank", + table: "Players"); + + migrationBuilder.DropColumn( + name: "RefundShopInfoLists_Capacity", + table: "Players"); + + migrationBuilder.DropColumn( + name: "Rmb", + table: "Players"); + + migrationBuilder.DropColumn( + name: "ShipBagMax", + table: "Players"); + + migrationBuilder.DropColumn( + name: "Soundstories", + table: "Players"); + + migrationBuilder.DropColumn( + name: "StoryLists", + table: "Players"); + + migrationBuilder.DropColumn( + name: "TakingShipLists_Capacity", + table: "Players"); + + migrationBuilder.DropColumn( + name: "ThemeUploadNotAllowedTime", + table: "Players"); + + migrationBuilder.DropColumn( + name: "WinCount", + table: "Players"); + } + } +} diff --git a/BLHX.Server.Common/Migrations/Player/PlayerContextModelSnapshot.cs b/BLHX.Server.Common/Migrations/Player/PlayerContextModelSnapshot.cs index 01fb54b..ac168d5 100644 --- a/BLHX.Server.Common/Migrations/Player/PlayerContextModelSnapshot.cs +++ b/BLHX.Server.Common/Migrations/Player/PlayerContextModelSnapshot.cs @@ -116,12 +116,52 @@ namespace BLHX.Server.Common.Migrations.Player .ValueGeneratedOnAdd() .HasColumnType("INTEGER"); + b.Property("AccPayLv") + .HasColumnType("INTEGER"); + b.Property("Adv") .IsRequired() .ValueGeneratedOnAdd() .HasColumnType("TEXT") .HasDefaultValue(""); + b.Property("Appreciation") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("AttackCount") + .HasColumnType("INTEGER"); + + b.Property("BuyOilCount") + .HasColumnType("INTEGER"); + + b.Property("CartoonCollectMarks") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("CartoonReadMarks") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Characters") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ChatMsgBanTime") + .HasColumnType("INTEGER"); + + b.Property("ChatRoomId") + .HasColumnType("INTEGER"); + + b.Property("ChildDisplay") + .HasColumnType("INTEGER"); + + b.Property("CollectAttackCount") + .HasColumnType("INTEGER"); + + b.Property("CommanderBagMax") + .HasColumnType("INTEGER"); + b.Property("CreatedAt") .HasColumnType("TEXT"); @@ -132,32 +172,94 @@ namespace BLHX.Server.Common.Migrations.Player .IsRequired() .HasColumnType("jsonb"); + b.Property("EquipBagMax") + .HasColumnType("INTEGER"); + b.Property("Exp") .HasColumnType("INTEGER"); + b.Property("FlagLists") + .IsRequired() + .HasColumnType("TEXT"); + 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("GmFlag") + .HasColumnType("INTEGER"); + + b.Property("GuideIndex") + .HasColumnType("INTEGER"); + + b.Property("GuildWaitTime") + .HasColumnType("INTEGER"); + b.Property("Level") .HasColumnType("INTEGER"); + b.Property("MarryShip") + .HasColumnType("INTEGER"); + + b.Property("MaxRank") + .HasColumnType("INTEGER"); + + b.Property("MedalIds") + .IsRequired() + .HasColumnType("TEXT"); + b.Property("Name") .IsRequired() .HasColumnType("TEXT"); + b.Property("PvpAttackCount") + .HasColumnType("INTEGER"); + + b.Property("PvpWinCount") + .HasColumnType("INTEGER"); + + b.Property("RandomShipLists") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("RandomShipMode") + .HasColumnType("INTEGER"); + + b.Property("Rank") + .HasColumnType("INTEGER"); + + b.Property("Rmb") + .HasColumnType("INTEGER"); + + b.Property("ShipBagMax") + .HasColumnType("INTEGER"); + b.Property("ShipSkins") .IsRequired() .ValueGeneratedOnAdd() .HasColumnType("jsonb") .HasDefaultValue("[]"); + b.Property("Soundstories") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("StoryLists") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ThemeUploadNotAllowedTime") + .HasColumnType("INTEGER"); + b.Property("Token") .IsRequired() .HasColumnType("TEXT"); + b.Property("WinCount") + .HasColumnType("INTEGER"); + b.HasKey("Uid"); b.HasIndex("Token") @@ -300,6 +402,30 @@ namespace BLHX.Server.Common.Migrations.Player b.ToTable("ResourceFields"); }); + modelBuilder.Entity("BLHX.Server.Common.Proto.common.Idtimeinfo", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("PlayerUid") + .HasColumnType("INTEGER"); + + b.Property("PlayerUid1") + .HasColumnType("INTEGER"); + + b.Property("Time") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("PlayerUid"); + + b.HasIndex("PlayerUid1"); + + b.ToTable("Idtimeinfo"); + }); + modelBuilder.Entity("BLHX.Server.Common.Database.ChapterInfo", b => { b.HasOne("BLHX.Server.Common.Database.Player", "Player") @@ -311,6 +437,85 @@ namespace BLHX.Server.Common.Migrations.Player b.Navigation("Player"); }); + modelBuilder.Entity("BLHX.Server.Common.Database.Player", b => + { + b.OwnsOne("System.Collections.Generic.List", "RefundShopInfoLists", b1 => + { + b1.Property("PlayerUid") + .HasColumnType("INTEGER"); + + b1.Property("Capacity") + .HasColumnType("INTEGER"); + + b1.HasKey("PlayerUid"); + + b1.ToTable("Players"); + + b1.WithOwner() + .HasForeignKey("PlayerUid"); + }); + + b.OwnsOne("System.Collections.Generic.List", "CardLists", b1 => + { + b1.Property("PlayerUid") + .HasColumnType("INTEGER"); + + b1.Property("Capacity") + .HasColumnType("INTEGER"); + + b1.HasKey("PlayerUid"); + + b1.ToTable("Players"); + + b1.WithOwner() + .HasForeignKey("PlayerUid"); + }); + + b.OwnsOne("System.Collections.Generic.List", "CdLists", b1 => + { + b1.Property("PlayerUid") + .HasColumnType("INTEGER"); + + b1.Property("Capacity") + .HasColumnType("INTEGER"); + + b1.HasKey("PlayerUid"); + + b1.ToTable("Players"); + + b1.WithOwner() + .HasForeignKey("PlayerUid"); + }); + + b.OwnsOne("System.Collections.Generic.List", "TakingShipLists", b1 => + { + b1.Property("PlayerUid") + .HasColumnType("INTEGER"); + + b1.Property("Capacity") + .HasColumnType("INTEGER"); + + b1.HasKey("PlayerUid"); + + b1.ToTable("Players"); + + b1.WithOwner() + .HasForeignKey("PlayerUid"); + }); + + b.Navigation("CardLists") + .IsRequired(); + + b.Navigation("CdLists") + .IsRequired(); + + b.Navigation("RefundShopInfoLists") + .IsRequired(); + + b.Navigation("TakingShipLists") + .IsRequired(); + }); + modelBuilder.Entity("BLHX.Server.Common.Database.PlayerResource", b => { b.HasOne("BLHX.Server.Common.Database.Player", "Player") @@ -344,10 +549,25 @@ namespace BLHX.Server.Common.Migrations.Player b.Navigation("Player"); }); + modelBuilder.Entity("BLHX.Server.Common.Proto.common.Idtimeinfo", b => + { + b.HasOne("BLHX.Server.Common.Database.Player", null) + .WithMany("ChatFrameLists") + .HasForeignKey("PlayerUid"); + + b.HasOne("BLHX.Server.Common.Database.Player", null) + .WithMany("IconFrameLists") + .HasForeignKey("PlayerUid1"); + }); + modelBuilder.Entity("BLHX.Server.Common.Database.Player", b => { b.Navigation("ChapterInfoes"); + b.Navigation("ChatFrameLists"); + + b.Navigation("IconFrameLists"); + b.Navigation("ResourceFields"); b.Navigation("Resources"); diff --git a/BLHX.Server.Game/Commands/SetPlayerDataCommand.cs b/BLHX.Server.Game/Commands/SetPlayerDataCommand.cs new file mode 100644 index 0000000..5dc38ff --- /dev/null +++ b/BLHX.Server.Game/Commands/SetPlayerDataCommand.cs @@ -0,0 +1,50 @@ +using BLHX.Server.Common.Database; +using BLHX.Server.Common.Utils; +using BLHX.Server.Game.Handlers; +using System.ComponentModel; +using System.Globalization; +using System.Reflection; +using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database; + +namespace BLHX.Server.Game.Commands; + +// Chatbox has 40 character limit, original command is setplayerdata shortened -> spd +[CommandHandler("spd", "set a player's data", "spd property=level value=20")] +public class SetPlayerDataCommand : Command { + + [Argument("property")] + public string? Property { get; set; } + + [Argument("value")] + public string? Value { get; set; } + + public override void Execute(Dictionary args, Connection connection) { + base.Execute(args); + + if (Property is null || Value is null) { + connection.SendSystemMsg($"Usage: /spd property= value=1"); + return; + } + + PropertyInfo? targetProperty = typeof(Player).GetProperty(Property); + TypeConverter converter = TypeDescriptor.GetConverter(targetProperty.PropertyType); + + if (converter != null && converter.CanConvertFrom(typeof(string))) { + try { + object targetValue = converter.ConvertFromInvariantString(Value); + + targetProperty.SetValue(connection.player, targetValue); + } catch (Exception) { + connection.SendSystemMsg("Invalid Value"); + return; + } + } else { + connection.SendSystemMsg($"Invalid Player Property!"); + return; + } + + DBManager.PlayerContext.Save(); + connection.NotifyPlayerData(); + connection.SendSystemMsg($"Set Player with UID {connection.player.Uid}'s {Property} to {Value}"); + } +} diff --git a/BLHX.Server.Game/Commands/ShipCommand.cs b/BLHX.Server.Game/Commands/ShipCommand.cs index 19e0aeb..619b663 100644 --- a/BLHX.Server.Game/Commands/ShipCommand.cs +++ b/BLHX.Server.Game/Commands/ShipCommand.cs @@ -17,7 +17,7 @@ namespace BLHX.Server.Game.Commands { base.Execute(args); if (Unlock is null) { - Logger.c.Log($"Usage: /ship unlock= rarity=1-6"); + connection.SendSystemMsg($"Usage: /ship unlock= rarity=1-6"); return; } @@ -31,7 +31,7 @@ namespace BLHX.Server.Game.Commands { all_ship_ids = Data.ShipDataStatistics.Where(ship_data => all_ship_ids.Contains(ship_data.Key) && ship_data.Value.Rarity == rarity).ToDictionary().Keys.ToList(); } - List all_ships = all_ship_ids.Select(ship_id => CreateShipFromId((uint)ship_id, connection.player.Uid)).ToList(); + List all_ships = all_ship_ids.Select(ship_id => CreateShipFromId((uint)ship_id, connection.player.Uid)).Take(amount).ToList(); all_ships.AddRange(GetDefaultShips(connection.player.Ships)); // add the defaults connection.player.Ships = all_ships; diff --git a/BLHX.Server.Game/Handlers/P11.cs b/BLHX.Server.Game/Handlers/P11.cs index 04e9988..786ed74 100644 --- a/BLHX.Server.Game/Handlers/P11.cs +++ b/BLHX.Server.Game/Handlers/P11.cs @@ -75,18 +75,45 @@ namespace BLHX.Server.Game.Handlers { Exp = connection.player.Exp, Adv = connection.player.Adv, ResourceLists = connection.player.Resources.Select(x => new Resource() { Num = x.Num, Type = x.Id }).ToList(), - Characters = [1], + Characters = connection.player.Characters, + WinCount = connection.player.WinCount, + AttackCount = connection.player.AttackCount, ShipBagMax = connection.player.ShipBagMax, - EquipBagMax = 350, - GmFlag = 1, - Rank = 1, - GuideIndex = 1000000, - ChatRoomId = 1, + EquipBagMax = connection.player.EquipBagMax, + GmFlag = connection.player.GmFlag, + Rank = connection.player.Rank, + PvpAttackCount = connection.player.PvpAttackCount, + PvpWinCount = connection.player.PvpWinCount, + CollectAttackCount = connection.player.CollectAttackCount, + GuideIndex = connection.player.GuideIndex, + BuyOilCount = connection.player.BuyOilCount, + ChatRoomId = connection.player.ChatRoomId, + MaxRank = connection.player.MaxRank, + AccPayLv = connection.player.AccPayLv, + GuildWaitTime = connection.player.GuildWaitTime, + ChatMsgBanTime = connection.player.ChatMsgBanTime, + ThemeUploadNotAllowedTime = connection.player.ThemeUploadNotAllowedTime, + RandomShipMode = connection.player.RandomShipMode, + MarryShip = connection.player.MarryShip, + ChildDisplay = connection.player.ChildDisplay, + StoryLists = connection.player.StoryLists, + FlagLists = connection.player.FlagLists, + MedalIds = connection.player.MedalIds, + CartoonReadMarks = connection.player.CartoonReadMarks, + CartoonCollectMarks = connection.player.CartoonCollectMarks, + RandomShipLists = connection.player.RandomShipLists, + Soundstories = connection.player.Soundstories, + CardLists = connection.player.CardLists, + CdLists = connection.player.CdLists, + IconFrameLists = connection.player.IconFrameLists, + ChatFrameLists = connection.player.ChatFrameLists, + RefundShopInfoLists = connection.player.RefundShopInfoLists, + TakingShipLists = connection.player.TakingShipLists, RegisterTime = (uint)new DateTimeOffset(connection.player.CreatedAt).ToUnixTimeSeconds(), - ShipCount = (uint)connection.player.Ships.Count, - CommanderBagMax = 40, + ShipCount = connection.player.ShipCount, + CommanderBagMax = connection.player.CommanderBagMax, Display = connection.player.DisplayInfo, - Appreciation = new() + Appreciation = connection.player.Appreciation, }); } } diff --git a/BLHX.Server.Game/Handlers/P12.cs b/BLHX.Server.Game/Handlers/P12.cs index bb9c81a..4455544 100644 --- a/BLHX.Server.Game/Handlers/P12.cs +++ b/BLHX.Server.Game/Handlers/P12.cs @@ -28,7 +28,7 @@ namespace BLHX.Server.Game.Handlers { } [PacketHandler(Command.Cs12002, SaveDataAfterRun = true)] - static void UseResourceHandler(Connection connection, Packet packet) { + static void BuildHandler(Connection connection, Packet packet) { var req = packet.Decode(); Logger.c.Log("Id: " + req.Id); @@ -45,7 +45,7 @@ namespace BLHX.Server.Game.Handlers { } [PacketHandler(Command.Cs12008, SaveDataAfterRun = true)] - static void FinishAllBuildHandler(Connection connection, Packet packet) { + static void FinishBuildHandler(Connection connection, Packet packet) { var req = packet.Decode(); connection.Send(new Sc12009() { PosLists = req.PosLists });