This commit is contained in:
rfi
2024-02-22 06:50:42 +07:00
parent b232088f4d
commit 5d39e1c6be
6 changed files with 306 additions and 9 deletions

View File

@@ -1,4 +1,5 @@
using BLHX.Server.Common.Proto.common; using BLHX.Server.Common.Proto.common;
using BLHX.Server.Common.Proto.p12;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
@@ -48,6 +49,14 @@ namespace BLHX.Server.Common.Database
{ {
e.Property(b => b.DisplayInfo) e.Property(b => b.DisplayInfo)
.HasJsonConversion(); .HasJsonConversion();
e.Property(b => b.Fleets)
.HasJsonConversion()
.HasDefaultValue(new List<Groupinfo>() {
new() { Id = 1, ShipLists = [1, 2] },
new() { Id = 2 },
new() { Id = 11 },
new() { Id = 12 }
});
e.Property(b => b.Adv) e.Property(b => b.Adv)
.HasDefaultValue(""); .HasDefaultValue("");
e.HasMany(b => b.Resources) e.HasMany(b => b.Resources)
@@ -102,6 +111,8 @@ namespace BLHX.Server.Common.Database
public Displayinfo DisplayInfo { get; set; } public Displayinfo DisplayInfo { get; set; }
public DateTime CreatedAt { get; set; } public DateTime CreatedAt { get; set; }
public List<Groupinfo> Fleets { get; set; } = null!;
public virtual ICollection<PlayerResource> Resources { get; set; } = []; public virtual ICollection<PlayerResource> Resources { get; set; } = [];
public virtual ICollection<PlayerShip> Ships { get; set; } = []; public virtual ICollection<PlayerShip> Ships { get; set; } = [];

View File

@@ -0,0 +1,215 @@
// <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("20240221233630_FleetsDB")]
partial class FleetsDB
{
/// <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.Player", b =>
{
b.Property<uint>("Uid")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Adv")
.IsRequired()
.ValueGeneratedOnAdd()
.HasColumnType("TEXT")
.HasDefaultValue("");
b.Property<DateTime>("CreatedAt")
.HasColumnType("TEXT");
b.Property<string>("DisplayInfo")
.IsRequired()
.HasColumnType("jsonb");
b.Property<uint>("Exp")
.HasColumnType("INTEGER");
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>("Level")
.HasColumnType("INTEGER");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Token")
.IsRequired()
.HasColumnType("TEXT");
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.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.Player", b =>
{
b.Navigation("Resources");
b.Navigation("Ships");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,47 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BLHX.Server.Common.Migrations.Player
{
/// <inheritdoc />
public partial class FleetsDB : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "Adv",
table: "Players",
type: "TEXT",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "TEXT");
migrationBuilder.AddColumn<string>(
name: "Fleets",
table: "Players",
type: "jsonb",
nullable: false,
defaultValue: "[{\"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\":[]}]");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Fleets",
table: "Players");
migrationBuilder.AlterColumn<string>(
name: "Adv",
table: "Players",
type: "TEXT",
nullable: false,
oldClrType: typeof(string),
oldType: "TEXT",
oldDefaultValue: "");
}
}
}

View File

@@ -29,7 +29,9 @@ namespace BLHX.Server.Common.Migrations.Player
b.Property<string>("Adv") b.Property<string>("Adv")
.IsRequired() .IsRequired()
.HasColumnType("TEXT"); .ValueGeneratedOnAdd()
.HasColumnType("TEXT")
.HasDefaultValue("");
b.Property<DateTime>("CreatedAt") b.Property<DateTime>("CreatedAt")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
@@ -41,6 +43,12 @@ namespace BLHX.Server.Common.Migrations.Player
b.Property<uint>("Exp") b.Property<uint>("Exp")
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
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>("Level") b.Property<uint>("Level")
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");

View File

@@ -1,9 +1,23 @@
using BLHX.Server.Common.Proto.p12; using BLHX.Server.Common.Proto;
using BLHX.Server.Common.Proto.p12;
namespace BLHX.Server.Game.Handlers namespace BLHX.Server.Game.Handlers
{ {
internal static class P12 internal static class P12
{ {
[PacketHandler(Command.Cs12102, SaveDataAfterRun = true)]
static void UpdateFleetHandler(Connection connection, Packet packet)
{
var fleet = packet.Decode<Cs12102>();
var toUpdate = connection.player.Fleets.Find(x => x.Id == fleet.Id);
if (toUpdate is not null)
toUpdate.ShipLists = fleet.ShipLists;
else
connection.player.Fleets.Add(new() { Id = fleet.Id, ShipLists = fleet.ShipLists });
connection.Send(new Sc12103());
}
} }
static class P12ConnectionNotifyExtensions static class P12ConnectionNotifyExtensions
@@ -30,12 +44,7 @@ namespace BLHX.Server.Game.Handlers
{ {
connection.Send(new Sc12101() connection.Send(new Sc12101()
{ {
GroupLists = [ GroupLists = connection.player.Fleets
new Groupinfo() { Id = 1, ShipLists = [1, 2] },
new Groupinfo() { Id = 2 },
new Groupinfo() { Id = 11 },
new Groupinfo() { Id = 12 }
]
}); });
} }
} }

View File

@@ -8,7 +8,14 @@ namespace BLHX.Server.Game.Handlers
[PacketHandler(Command.Cs24020)] [PacketHandler(Command.Cs24020)]
static void LimitChallengeHandler(Connection connection, Packet packet) static void LimitChallengeHandler(Connection connection, Packet packet)
{ {
connection.Send(new Sc24021()); connection.Send(new Sc24021()
{
Awards = [
new() { Key = 10025, Value = 0 },
new() { Key = 10026, Value = 0 },
new() { Key = 10027, Value = 0 }
]
});
} }
} }
} }