feat: initial character data
This commit is contained in:
parent
756031b186
commit
8816fb2944
5 changed files with 23 additions and 1 deletions
|
@ -18,4 +18,5 @@ public class Account
|
||||||
public string Email { get; set; }
|
public string Email { get; set; }
|
||||||
public byte PermissionLevel { get; set; }
|
public byte PermissionLevel { get; set; }
|
||||||
public byte[] Salt { get; set; }
|
public byte[] Salt { get; set; }
|
||||||
|
public ICollection<Character> Characters { get; } = new List<Character>();
|
||||||
}
|
}
|
||||||
|
|
12
Server/DB/Documents/Character.cs
Normal file
12
Server/DB/Documents/Character.cs
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
namespace Server.DB.Documents;
|
||||||
|
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
||||||
|
|
||||||
|
public class Character
|
||||||
|
{
|
||||||
|
public Guid AccountId { get; set; }
|
||||||
|
public Account Account { get; set; } = null!;
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
public ushort MapId { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
}
|
|
@ -17,6 +17,7 @@ public class WonderkingContext : DbContext
|
||||||
}
|
}
|
||||||
|
|
||||||
public DbSet<Account> Accounts { get; set; }
|
public DbSet<Account> Accounts { get; set; }
|
||||||
|
public DbSet<Character> Characters { get; set; }
|
||||||
|
|
||||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) =>
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) =>
|
||||||
optionsBuilder
|
optionsBuilder
|
||||||
|
@ -31,5 +32,11 @@ public class WonderkingContext : DbContext
|
||||||
builder.Property(b => b.Password).HasColumnType("bytea");
|
builder.Property(b => b.Password).HasColumnType("bytea");
|
||||||
builder.Property(b => b.Salt).HasColumnType("bytea");
|
builder.Property(b => b.Salt).HasColumnType("bytea");
|
||||||
builder.HasKey(b => b.Id);
|
builder.HasKey(b => b.Id);
|
||||||
|
builder.HasMany(e => e.Characters).WithOne(e => e.Account).HasForeignKey(e => e.AccountId).IsRequired();
|
||||||
|
}).Entity<Character>(builder =>
|
||||||
|
{
|
||||||
|
builder.HasKey(c => c.Id);
|
||||||
|
builder.HasOne<Account>().WithOne().HasForeignKey("AccountId").IsRequired();
|
||||||
|
builder.Property(c => c.Name).HasColumnType("varchar(20)");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,6 +77,7 @@ public class LoginHandler : IPacketHandler<LoginInfoPacket>
|
||||||
IsGameMaster = true
|
IsGameMaster = true
|
||||||
};
|
};
|
||||||
var sess = session as AuthSession;
|
var sess = session as AuthSession;
|
||||||
|
sess.AccountId = account.Id;
|
||||||
sess.Send(loginResponsePacket);
|
sess.Send(loginResponsePacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.VisualBasic.CompilerServices;
|
using Microsoft.VisualBasic.CompilerServices;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using PacketHandlers;
|
using PacketHandlers;
|
||||||
using Packets;
|
using Packets;
|
||||||
using static DotNext.Metaprogramming.CodeGenerator;
|
using static DotNext.Metaprogramming.CodeGenerator;
|
||||||
|
@ -142,10 +143,10 @@ public class PacketDistributorService : IHostedService
|
||||||
}
|
}
|
||||||
|
|
||||||
var packet = this.deserializationMap[item.OperationCode](item.MessageBody);
|
var packet = this.deserializationMap[item.OperationCode](item.MessageBody);
|
||||||
|
this.logger.LogInformation("Packet data {PacketData}", JsonConvert.SerializeObject(packet));
|
||||||
this.packetHandlersInstantiation[item.OperationCode].GetType().GetMethod("HandleAsync")
|
this.packetHandlersInstantiation[item.OperationCode].GetType().GetMethod("HandleAsync")
|
||||||
?.Invoke(this.packetHandlersInstantiation[item.OperationCode], new object[] { packet, item.Session });
|
?.Invoke(this.packetHandlersInstantiation[item.OperationCode], new object[] { packet, item.Session });
|
||||||
|
|
||||||
//this.logger.LogDebug("Packet data {PacketData}", JsonConvert.SerializeObject(packet));
|
|
||||||
this.logger.LogTrace("[{TempId}] Packet with ID: {MessageOperationCode} has finished",
|
this.logger.LogTrace("[{TempId}] Packet with ID: {MessageOperationCode} has finished",
|
||||||
item.Session.Id,
|
item.Session.Id,
|
||||||
item.OperationCode);
|
item.OperationCode);
|
||||||
|
|
Loading…
Reference in a new issue