mirror of
https://github.com/rafi1212122/BLHX.Server.git
synced 2025-12-12 22:44:36 +01:00
migration testing, manifesto editing
This commit is contained in:
@@ -48,6 +48,8 @@ namespace BLHX.Server.Common.Database
|
||||
{
|
||||
e.Property(b => b.DisplayInfo)
|
||||
.HasJsonConversion();
|
||||
e.Property(b => b.Adv)
|
||||
.HasDefaultValue("");
|
||||
e.HasMany(b => b.Resources)
|
||||
.WithOne(e => e.Player)
|
||||
.HasForeignKey(e => e.PlayerUid)
|
||||
@@ -92,6 +94,8 @@ namespace BLHX.Server.Common.Database
|
||||
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 Level { get; set; }
|
||||
// TODO: Exp add setter to recalculate cap and set level
|
||||
public uint Exp { get; set; }
|
||||
|
||||
207
BLHX.Server.Common/Migrations/Player/20240221064120_AddManifesto.Designer.cs
generated
Normal file
207
BLHX.Server.Common/Migrations/Player/20240221064120_AddManifesto.Designer.cs
generated
Normal file
@@ -0,0 +1,207 @@
|
||||
// <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("20240221064120_AddManifesto")]
|
||||
partial class AddManifesto
|
||||
{
|
||||
/// <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()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("DisplayInfo")
|
||||
.IsRequired()
|
||||
.HasColumnType("jsonb");
|
||||
|
||||
b.Property<uint>("Exp")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BLHX.Server.Common.Migrations.Player
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddManifesto : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "Adv",
|
||||
table: "Players",
|
||||
type: "TEXT",
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Adv",
|
||||
table: "Players");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,10 @@ namespace BLHX.Server.Common.Migrations.Player
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Adv")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
|
||||
@@ -50,14 +50,14 @@ public abstract class Command
|
||||
}
|
||||
}
|
||||
|
||||
protected T Parse<T>(string? value, T fallback = default)
|
||||
protected T Parse<T>(string? value, T fallback = default!)
|
||||
{
|
||||
var tryParseMethod = typeof(T).GetMethod("TryParse", [typeof(string), typeof(T).MakeByRefType()]);
|
||||
|
||||
if (tryParseMethod != null)
|
||||
{
|
||||
var parameters = new object[] { value, null };
|
||||
bool success = (bool)tryParseMethod.Invoke(null, parameters);
|
||||
var parameters = new object[] { value!, null! };
|
||||
bool success = (bool)tryParseMethod.Invoke(null, parameters)!;
|
||||
|
||||
if (success)
|
||||
return (T)parameters[1];
|
||||
@@ -87,10 +87,10 @@ public static class CommandHandler
|
||||
|
||||
foreach (var commandType in commandTypes)
|
||||
{
|
||||
var commandAttribute = (commandHandler)Attribute.GetCustomAttribute(commandType, typeof(commandHandler));
|
||||
var commandAttribute = (commandHandler?)Attribute.GetCustomAttribute(commandType, typeof(commandHandler));
|
||||
if (commandAttribute != null)
|
||||
{
|
||||
var commandInstance = (Command)Activator.CreateInstance(commandType);
|
||||
var commandInstance = (Command)Activator.CreateInstance(commandType)!;
|
||||
commandFunctions[commandAttribute.Name] = commandInstance.Execute;
|
||||
Commands.Add(commandInstance);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using BLHX.Server.Common.Proto;
|
||||
using BLHX.Server.Common.Database;
|
||||
using BLHX.Server.Common.Proto;
|
||||
using BLHX.Server.Common.Proto.p11;
|
||||
|
||||
namespace BLHX.Server.Game.Handlers
|
||||
@@ -17,6 +18,22 @@ namespace BLHX.Server.Game.Handlers
|
||||
});
|
||||
}
|
||||
|
||||
[PacketHandler(Command.Cs11009)]
|
||||
static void ChangeManifestoHandler(Connection connection, Packet packet)
|
||||
{
|
||||
var req = packet.Decode<Cs11009>();
|
||||
connection.player.Adv = req.Adv;
|
||||
DBManager.PlayerContext.SaveChanges();
|
||||
|
||||
connection.Send(new Sc11010());
|
||||
}
|
||||
|
||||
[PacketHandler(Command.Cs11601)]
|
||||
static void GetEmojiInfoHandler(Connection connection, Packet packet)
|
||||
{
|
||||
connection.Send(new Sc11602());
|
||||
}
|
||||
|
||||
[PacketHandler(Command.Cs11603)]
|
||||
static void FetchSecondaryPasswordHandler(Connection connection, Packet packet)
|
||||
{
|
||||
@@ -54,6 +71,7 @@ namespace BLHX.Server.Game.Handlers
|
||||
Name = connection.player.Name,
|
||||
Level = connection.player.Level,
|
||||
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],
|
||||
ShipBagMax = 150,
|
||||
|
||||
@@ -11,6 +11,12 @@ namespace BLHX.Server.Game.Handlers
|
||||
connection.Send(new Sc26102());
|
||||
}
|
||||
|
||||
[PacketHandler(Command.Cs26103)]
|
||||
static void MiniGameOPHandler(Connection connection, Packet packet)
|
||||
{
|
||||
connection.Send(new Sc26104());
|
||||
}
|
||||
|
||||
[PacketHandler(Command.Cs26150)]
|
||||
static void GetMinigameShopHandler(Connection connection, Packet packet)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user