added all params to player database

This commit is contained in:
raphaeIl
2024-04-05 01:35:08 -04:00
parent d9602a58f3
commit bbe0d7ab11
9 changed files with 1437 additions and 22 deletions

View File

@@ -74,6 +74,8 @@ namespace BLHX.Server.Common.Database {
modelBuilder.Entity<Player>(e => {
e.Property(b => b.DisplayInfo)
.HasJsonConversion();
e.Property(b => b.Appreciation)
.HasJsonConversion();
e.Property(b => b.Fleets)
.HasJsonConversion()
.HasDefaultValue(new List<Groupinfo>() {
@@ -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<PlayerShip>(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<Groupinfo> Fleets { get; set; } = null!;
public List<Idtimeinfo> ShipSkins { get; set; } = null!;
public List<uint> Characters { get; set; } = [1];
public List<uint> StoryLists { get; set; } = [];
public List<uint> FlagLists { get; set; } = [];
public List<uint> MedalIds { get; set; } = [];
public List<uint> CartoonReadMarks { get; set; } = [];
public List<uint> CartoonCollectMarks { get; set; } = [];
public List<uint> RandomShipLists { get; set; } = [];
public List<uint> Soundstories { get; set; } = [];
public virtual List<Proto.p11.Cardinfo> CardLists { get; set; } = [];
public virtual List<Proto.p11.Cooldown> CdLists { get; set; } = [];
public virtual List<Idtimeinfo> IconFrameLists { get; set; } = [];
public virtual List<Idtimeinfo> ChatFrameLists { get; set; } = [];
public virtual List<RefundShopinfo> RefundShopInfoLists { get; set; } = [];
public virtual List<Proto.p11.ShipTakingData> TakingShipLists { get; set; } = [];
//
public string Token { get; set; }
public uint? CurrentChapter { get; set; }
public List<Groupinfo> Fleets { get; set; } = null!;
public List<Idtimeinfo> ShipSkins { get; set; } = null!;
public virtual ICollection<PlayerResource> Resources { get; set; } = [];
public virtual ICollection<ResourceField> ResourceFields { get; set; } = [];
public virtual ICollection<PlayerShip> Ships { get; set; } = [];
public virtual ICollection<ChapterInfo> 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) {

View File

@@ -17,7 +17,6 @@ namespace BLHX.Server.Common.Migrations.Player {
Name = table.Column<string>(type: "TEXT", nullable: false),
Level = table.Column<uint>(type: "INTEGER", nullable: false),
Exp = table.Column<uint>(type: "INTEGER", nullable: false),
ShipBagMax = table.Column<uint>(type: "INTEGER", nullable: false),
DisplayInfo = table.Column<string>(type: "jsonb", nullable: false),
CreatedAt = table.Column<DateTime>(type: "TEXT", nullable: false)
},

View File

@@ -0,0 +1,583 @@
// <auto-generated />
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
{
/// <inheritdoc />
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<uint>("Id")
.HasColumnType("INTEGER");
b.Property<uint>("PlayerUid")
.HasColumnType("INTEGER");
b.Property<string>("AiLists")
.IsRequired()
.HasColumnType("jsonb");
b.Property<string>("BattleStatistics")
.IsRequired()
.HasColumnType("jsonb");
b.Property<string>("BuffLists")
.IsRequired()
.HasColumnType("jsonb");
b.Property<string>("CellFlagLists")
.IsRequired()
.HasColumnType("jsonb");
b.Property<string>("CellLists")
.IsRequired()
.HasColumnType("jsonb");
b.Property<uint>("ChapterHp")
.HasColumnType("INTEGER");
b.Property<string>("ChapterStrategyLists")
.IsRequired()
.HasColumnType("jsonb");
b.Property<uint>("ContinuousKillCount")
.HasColumnType("INTEGER");
b.Property<string>("EscortLists")
.IsRequired()
.HasColumnType("jsonb");
b.Property<string>("ExtraFlagLists")
.IsRequired()
.HasColumnType("jsonb");
b.Property<string>("FleetDuties")
.IsRequired()
.HasColumnType("jsonb");
b.Property<string>("GroupLists")
.IsRequired()
.HasColumnType("jsonb");
b.Property<uint>("InitShipCount")
.HasColumnType("INTEGER");
b.Property<bool>("IsSubmarineAutoAttack")
.HasColumnType("INTEGER");
b.Property<uint>("KillCount")
.HasColumnType("INTEGER");
b.Property<uint>("LoopFlag")
.HasColumnType("INTEGER");
b.Property<uint>("ModelActCount")
.HasColumnType("INTEGER");
b.Property<uint>("MoveStepCount")
.HasColumnType("INTEGER");
b.Property<string>("OperationBuffs")
.IsRequired()
.HasColumnType("jsonb");
b.Property<uint>("Round")
.HasColumnType("INTEGER");
b.Property<DateTime>("Time")
.HasColumnType("TEXT");
b.HasKey("Id", "PlayerUid");
b.HasIndex("PlayerUid");
b.ToTable("ChapterInfoes");
});
modelBuilder.Entity("BLHX.Server.Common.Database.Player", b =>
{
b.Property<uint>("Uid")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<uint>("AccPayLv")
.HasColumnType("INTEGER");
b.Property<string>("Adv")
.IsRequired()
.ValueGeneratedOnAdd()
.HasColumnType("TEXT")
.HasDefaultValue("");
b.Property<string>("Appreciation")
.IsRequired()
.HasColumnType("jsonb");
b.Property<uint>("AttackCount")
.HasColumnType("INTEGER");
b.Property<uint>("BuyOilCount")
.HasColumnType("INTEGER");
b.Property<string>("CartoonCollectMarks")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("CartoonReadMarks")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Characters")
.IsRequired()
.HasColumnType("TEXT");
b.Property<uint>("ChatMsgBanTime")
.HasColumnType("INTEGER");
b.Property<uint>("ChatRoomId")
.HasColumnType("INTEGER");
b.Property<uint>("ChildDisplay")
.HasColumnType("INTEGER");
b.Property<uint>("CollectAttackCount")
.HasColumnType("INTEGER");
b.Property<uint>("CommanderBagMax")
.HasColumnType("INTEGER");
b.Property<DateTime>("CreatedAt")
.HasColumnType("TEXT");
b.Property<uint?>("CurrentChapter")
.HasColumnType("INTEGER");
b.Property<string>("DisplayInfo")
.IsRequired()
.HasColumnType("jsonb");
b.Property<uint>("EquipBagMax")
.HasColumnType("INTEGER");
b.Property<uint>("Exp")
.HasColumnType("INTEGER");
b.Property<string>("FlagLists")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("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<uint>("GmFlag")
.HasColumnType("INTEGER");
b.Property<uint>("GuideIndex")
.HasColumnType("INTEGER");
b.Property<uint>("GuildWaitTime")
.HasColumnType("INTEGER");
b.Property<uint>("Level")
.HasColumnType("INTEGER");
b.Property<uint>("MarryShip")
.HasColumnType("INTEGER");
b.Property<uint>("MaxRank")
.HasColumnType("INTEGER");
b.Property<string>("MedalIds")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<uint>("PvpAttackCount")
.HasColumnType("INTEGER");
b.Property<uint>("PvpWinCount")
.HasColumnType("INTEGER");
b.Property<string>("RandomShipLists")
.IsRequired()
.HasColumnType("TEXT");
b.Property<uint>("RandomShipMode")
.HasColumnType("INTEGER");
b.Property<uint>("Rank")
.HasColumnType("INTEGER");
b.Property<uint>("Rmb")
.HasColumnType("INTEGER");
b.Property<uint>("ShipBagMax")
.HasColumnType("INTEGER");
b.Property<string>("ShipSkins")
.IsRequired()
.ValueGeneratedOnAdd()
.HasColumnType("jsonb")
.HasDefaultValue("[]");
b.Property<string>("Soundstories")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("StoryLists")
.IsRequired()
.HasColumnType("TEXT");
b.Property<uint>("ThemeUploadNotAllowedTime")
.HasColumnType("INTEGER");
b.Property<string>("Token")
.IsRequired()
.HasColumnType("TEXT");
b.Property<uint>("WinCount")
.HasColumnType("INTEGER");
b.HasKey("Uid");
b.HasIndex("Token")
.IsUnique();
b.ToTable("Players");
});
modelBuilder.Entity("BLHX.Server.Common.Database.PlayerResource", b =>
{
b.Property<uint>("Id")
.HasColumnType("INTEGER");
b.Property<uint>("PlayerUid")
.HasColumnType("INTEGER");
b.Property<uint>("Num")
.HasColumnType("INTEGER");
b.HasKey("Id", "PlayerUid");
b.HasIndex("PlayerUid");
b.ToTable("Resources");
});
modelBuilder.Entity("BLHX.Server.Common.Database.PlayerShip", b =>
{
b.Property<uint>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<uint>("ActivityNpc")
.HasColumnType("INTEGER");
b.Property<uint>("BluePrintFlag")
.HasColumnType("INTEGER");
b.Property<uint>("CommanderId")
.HasColumnType("INTEGER");
b.Property<uint?>("CommonFlag")
.HasColumnType("INTEGER");
b.Property<string>("CoreLists")
.IsRequired()
.HasColumnType("jsonb");
b.Property<DateTime>("CreatedAt")
.HasColumnType("TEXT");
b.Property<uint>("Energy")
.HasColumnType("INTEGER");
b.Property<string>("EquipInfoLists")
.IsRequired()
.HasColumnType("jsonb");
b.Property<uint>("Exp")
.HasColumnType("INTEGER");
b.Property<uint>("Intimacy")
.HasColumnType("INTEGER");
b.Property<bool>("IsLocked")
.HasColumnType("INTEGER");
b.Property<DateTime?>("LastChangeName")
.HasColumnType("TEXT");
b.Property<uint>("Level")
.HasColumnType("INTEGER");
b.Property<string>("MetaRepairLists")
.IsRequired()
.HasColumnType("jsonb");
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<uint>("PlayerUid")
.HasColumnType("INTEGER");
b.Property<uint>("Proficiency")
.HasColumnType("INTEGER");
b.Property<uint>("Propose")
.HasColumnType("INTEGER");
b.Property<string>("SkillIdLists")
.IsRequired()
.HasColumnType("jsonb");
b.Property<uint>("SkinId")
.HasColumnType("INTEGER");
b.Property<string>("State")
.IsRequired()
.HasColumnType("jsonb");
b.Property<string>("StrengthLists")
.IsRequired()
.HasColumnType("jsonb");
b.Property<uint>("TemplateId")
.HasColumnType("INTEGER");
b.Property<string>("TransformLists")
.IsRequired()
.HasColumnType("jsonb");
b.HasKey("Id");
b.HasIndex("PlayerUid");
b.ToTable("Ships");
});
modelBuilder.Entity("BLHX.Server.Common.Database.ResourceField", b =>
{
b.Property<int>("Type")
.HasColumnType("INTEGER");
b.Property<uint>("PlayerUid")
.HasColumnType("INTEGER");
b.Property<DateTime>("LastHarvestTime")
.HasColumnType("TEXT");
b.Property<uint>("Level")
.HasColumnType("INTEGER");
b.Property<DateTime>("UpgradeTime")
.HasColumnType("TEXT");
b.HasKey("Type", "PlayerUid");
b.HasIndex("PlayerUid");
b.ToTable("ResourceFields");
});
modelBuilder.Entity("BLHX.Server.Common.Proto.common.Idtimeinfo", b =>
{
b.Property<uint>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<uint?>("PlayerUid")
.HasColumnType("INTEGER");
b.Property<uint?>("PlayerUid1")
.HasColumnType("INTEGER");
b.Property<uint>("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<BLHX.Server.Common.Proto.common.RefundShopinfo>", "RefundShopInfoLists", b1 =>
{
b1.Property<uint>("PlayerUid")
.HasColumnType("INTEGER");
b1.Property<int>("Capacity")
.HasColumnType("INTEGER");
b1.HasKey("PlayerUid");
b1.ToTable("Players");
b1.WithOwner()
.HasForeignKey("PlayerUid");
});
b.OwnsOne("System.Collections.Generic.List<BLHX.Server.Common.Proto.p11.Cardinfo>", "CardLists", b1 =>
{
b1.Property<uint>("PlayerUid")
.HasColumnType("INTEGER");
b1.Property<int>("Capacity")
.HasColumnType("INTEGER");
b1.HasKey("PlayerUid");
b1.ToTable("Players");
b1.WithOwner()
.HasForeignKey("PlayerUid");
});
b.OwnsOne("System.Collections.Generic.List<BLHX.Server.Common.Proto.p11.Cooldown>", "CdLists", b1 =>
{
b1.Property<uint>("PlayerUid")
.HasColumnType("INTEGER");
b1.Property<int>("Capacity")
.HasColumnType("INTEGER");
b1.HasKey("PlayerUid");
b1.ToTable("Players");
b1.WithOwner()
.HasForeignKey("PlayerUid");
});
b.OwnsOne("System.Collections.Generic.List<BLHX.Server.Common.Proto.p11.ShipTakingData>", "TakingShipLists", b1 =>
{
b1.Property<uint>("PlayerUid")
.HasColumnType("INTEGER");
b1.Property<int>("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
}
}
}

View File

@@ -0,0 +1,441 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BLHX.Server.Common.Migrations.Player
{
/// <inheritdoc />
public partial class Players_AddParams : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<uint>(
name: "AccPayLv",
table: "Players",
type: "INTEGER",
nullable: false,
defaultValue: 0u);
migrationBuilder.AddColumn<string>(
name: "Appreciation",
table: "Players",
type: "jsonb",
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<uint>(
name: "AttackCount",
table: "Players",
type: "INTEGER",
nullable: false,
defaultValue: 0u);
migrationBuilder.AddColumn<uint>(
name: "BuyOilCount",
table: "Players",
type: "INTEGER",
nullable: false,
defaultValue: 0u);
migrationBuilder.AddColumn<int>(
name: "CardLists_Capacity",
table: "Players",
type: "INTEGER",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<string>(
name: "CartoonCollectMarks",
table: "Players",
type: "TEXT",
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<string>(
name: "CartoonReadMarks",
table: "Players",
type: "TEXT",
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<int>(
name: "CdLists_Capacity",
table: "Players",
type: "INTEGER",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<string>(
name: "Characters",
table: "Players",
type: "TEXT",
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<uint>(
name: "ChatMsgBanTime",
table: "Players",
type: "INTEGER",
nullable: false,
defaultValue: 0u);
migrationBuilder.AddColumn<uint>(
name: "ChatRoomId",
table: "Players",
type: "INTEGER",
nullable: false,
defaultValue: 0u);
migrationBuilder.AddColumn<uint>(
name: "ChildDisplay",
table: "Players",
type: "INTEGER",
nullable: false,
defaultValue: 0u);
migrationBuilder.AddColumn<uint>(
name: "CollectAttackCount",
table: "Players",
type: "INTEGER",
nullable: false,
defaultValue: 0u);
migrationBuilder.AddColumn<uint>(
name: "CommanderBagMax",
table: "Players",
type: "INTEGER",
nullable: false,
defaultValue: 0u);
migrationBuilder.AddColumn<uint>(
name: "EquipBagMax",
table: "Players",
type: "INTEGER",
nullable: false,
defaultValue: 0u);
migrationBuilder.AddColumn<string>(
name: "FlagLists",
table: "Players",
type: "TEXT",
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<uint>(
name: "GmFlag",
table: "Players",
type: "INTEGER",
nullable: false,
defaultValue: 0u);
migrationBuilder.AddColumn<uint>(
name: "GuideIndex",
table: "Players",
type: "INTEGER",
nullable: false,
defaultValue: 0u);
migrationBuilder.AddColumn<uint>(
name: "GuildWaitTime",
table: "Players",
type: "INTEGER",
nullable: false,
defaultValue: 0u);
migrationBuilder.AddColumn<uint>(
name: "MarryShip",
table: "Players",
type: "INTEGER",
nullable: false,
defaultValue: 0u);
migrationBuilder.AddColumn<uint>(
name: "MaxRank",
table: "Players",
type: "INTEGER",
nullable: false,
defaultValue: 0u);
migrationBuilder.AddColumn<string>(
name: "MedalIds",
table: "Players",
type: "TEXT",
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<uint>(
name: "PvpAttackCount",
table: "Players",
type: "INTEGER",
nullable: false,
defaultValue: 0u);
migrationBuilder.AddColumn<uint>(
name: "PvpWinCount",
table: "Players",
type: "INTEGER",
nullable: false,
defaultValue: 0u);
migrationBuilder.AddColumn<string>(
name: "RandomShipLists",
table: "Players",
type: "TEXT",
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<uint>(
name: "RandomShipMode",
table: "Players",
type: "INTEGER",
nullable: false,
defaultValue: 0u);
migrationBuilder.AddColumn<uint>(
name: "Rank",
table: "Players",
type: "INTEGER",
nullable: false,
defaultValue: 0u);
migrationBuilder.AddColumn<int>(
name: "RefundShopInfoLists_Capacity",
table: "Players",
type: "INTEGER",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<uint>(
name: "Rmb",
table: "Players",
type: "INTEGER",
nullable: false,
defaultValue: 0u);
migrationBuilder.AddColumn<uint>(
name: "ShipBagMax",
table: "Players",
type: "INTEGER",
nullable: false,
defaultValue: 0u);
migrationBuilder.AddColumn<string>(
name: "Soundstories",
table: "Players",
type: "TEXT",
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<string>(
name: "StoryLists",
table: "Players",
type: "TEXT",
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<int>(
name: "TakingShipLists_Capacity",
table: "Players",
type: "INTEGER",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<uint>(
name: "ThemeUploadNotAllowedTime",
table: "Players",
type: "INTEGER",
nullable: false,
defaultValue: 0u);
migrationBuilder.AddColumn<uint>(
name: "WinCount",
table: "Players",
type: "INTEGER",
nullable: false,
defaultValue: 0u);
migrationBuilder.CreateTable(
name: "Idtimeinfo",
columns: table => new
{
Id = table.Column<uint>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Time = table.Column<uint>(type: "INTEGER", nullable: false),
PlayerUid = table.Column<uint>(type: "INTEGER", nullable: true),
PlayerUid1 = table.Column<uint>(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");
}
/// <inheritdoc />
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");
}
}
}

View File

@@ -116,12 +116,52 @@ namespace BLHX.Server.Common.Migrations.Player
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<uint>("AccPayLv")
.HasColumnType("INTEGER");
b.Property<string>("Adv")
.IsRequired()
.ValueGeneratedOnAdd()
.HasColumnType("TEXT")
.HasDefaultValue("");
b.Property<string>("Appreciation")
.IsRequired()
.HasColumnType("jsonb");
b.Property<uint>("AttackCount")
.HasColumnType("INTEGER");
b.Property<uint>("BuyOilCount")
.HasColumnType("INTEGER");
b.Property<string>("CartoonCollectMarks")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("CartoonReadMarks")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Characters")
.IsRequired()
.HasColumnType("TEXT");
b.Property<uint>("ChatMsgBanTime")
.HasColumnType("INTEGER");
b.Property<uint>("ChatRoomId")
.HasColumnType("INTEGER");
b.Property<uint>("ChildDisplay")
.HasColumnType("INTEGER");
b.Property<uint>("CollectAttackCount")
.HasColumnType("INTEGER");
b.Property<uint>("CommanderBagMax")
.HasColumnType("INTEGER");
b.Property<DateTime>("CreatedAt")
.HasColumnType("TEXT");
@@ -132,32 +172,94 @@ namespace BLHX.Server.Common.Migrations.Player
.IsRequired()
.HasColumnType("jsonb");
b.Property<uint>("EquipBagMax")
.HasColumnType("INTEGER");
b.Property<uint>("Exp")
.HasColumnType("INTEGER");
b.Property<string>("FlagLists")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("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<uint>("GmFlag")
.HasColumnType("INTEGER");
b.Property<uint>("GuideIndex")
.HasColumnType("INTEGER");
b.Property<uint>("GuildWaitTime")
.HasColumnType("INTEGER");
b.Property<uint>("Level")
.HasColumnType("INTEGER");
b.Property<uint>("MarryShip")
.HasColumnType("INTEGER");
b.Property<uint>("MaxRank")
.HasColumnType("INTEGER");
b.Property<string>("MedalIds")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<uint>("PvpAttackCount")
.HasColumnType("INTEGER");
b.Property<uint>("PvpWinCount")
.HasColumnType("INTEGER");
b.Property<string>("RandomShipLists")
.IsRequired()
.HasColumnType("TEXT");
b.Property<uint>("RandomShipMode")
.HasColumnType("INTEGER");
b.Property<uint>("Rank")
.HasColumnType("INTEGER");
b.Property<uint>("Rmb")
.HasColumnType("INTEGER");
b.Property<uint>("ShipBagMax")
.HasColumnType("INTEGER");
b.Property<string>("ShipSkins")
.IsRequired()
.ValueGeneratedOnAdd()
.HasColumnType("jsonb")
.HasDefaultValue("[]");
b.Property<string>("Soundstories")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("StoryLists")
.IsRequired()
.HasColumnType("TEXT");
b.Property<uint>("ThemeUploadNotAllowedTime")
.HasColumnType("INTEGER");
b.Property<string>("Token")
.IsRequired()
.HasColumnType("TEXT");
b.Property<uint>("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<uint>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<uint?>("PlayerUid")
.HasColumnType("INTEGER");
b.Property<uint?>("PlayerUid1")
.HasColumnType("INTEGER");
b.Property<uint>("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<BLHX.Server.Common.Proto.common.RefundShopinfo>", "RefundShopInfoLists", b1 =>
{
b1.Property<uint>("PlayerUid")
.HasColumnType("INTEGER");
b1.Property<int>("Capacity")
.HasColumnType("INTEGER");
b1.HasKey("PlayerUid");
b1.ToTable("Players");
b1.WithOwner()
.HasForeignKey("PlayerUid");
});
b.OwnsOne("System.Collections.Generic.List<BLHX.Server.Common.Proto.p11.Cardinfo>", "CardLists", b1 =>
{
b1.Property<uint>("PlayerUid")
.HasColumnType("INTEGER");
b1.Property<int>("Capacity")
.HasColumnType("INTEGER");
b1.HasKey("PlayerUid");
b1.ToTable("Players");
b1.WithOwner()
.HasForeignKey("PlayerUid");
});
b.OwnsOne("System.Collections.Generic.List<BLHX.Server.Common.Proto.p11.Cooldown>", "CdLists", b1 =>
{
b1.Property<uint>("PlayerUid")
.HasColumnType("INTEGER");
b1.Property<int>("Capacity")
.HasColumnType("INTEGER");
b1.HasKey("PlayerUid");
b1.ToTable("Players");
b1.WithOwner()
.HasForeignKey("PlayerUid");
});
b.OwnsOne("System.Collections.Generic.List<BLHX.Server.Common.Proto.p11.ShipTakingData>", "TakingShipLists", b1 =>
{
b1.Property<uint>("PlayerUid")
.HasColumnType("INTEGER");
b1.Property<int>("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");

View File

@@ -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<string, string> args, Connection connection) {
base.Execute(args);
if (Property is null || Value is null) {
connection.SendSystemMsg($"Usage: /spd property=<Level|Name|Exp|ShipBagMax|...> 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}");
}
}

View File

@@ -17,7 +17,7 @@ namespace BLHX.Server.Game.Commands {
base.Execute(args);
if (Unlock is null) {
Logger.c.Log($"Usage: /ship unlock=<all|clear|shipId> rarity=1-6");
connection.SendSystemMsg($"Usage: /ship unlock=<all|clear|shipId> 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<PlayerShip> all_ships = all_ship_ids.Select(ship_id => CreateShipFromId((uint)ship_id, connection.player.Uid)).ToList();
List<PlayerShip> 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;

View File

@@ -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,
});
}
}

View File

@@ -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<Cs12002>();
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<Cs12008>();
connection.Send(new Sc12009() { PosLists = req.PosLists });