diff --git a/AscNet.Common/AscNet.Common.csproj b/AscNet.Common/AscNet.Common.csproj
index f2442b77..cf41343f 100644
--- a/AscNet.Common/AscNet.Common.csproj
+++ b/AscNet.Common/AscNet.Common.csproj
@@ -11,11 +11,10 @@
+
-
+
diff --git a/AscNet.Common/Common.cs b/AscNet.Common/Common.cs
index 1ca30dc0..019767c9 100644
--- a/AscNet.Common/Common.cs
+++ b/AscNet.Common/Common.cs
@@ -1,5 +1,7 @@
-using MongoDB.Driver;
+using System.Reflection;
+using MongoDB.Driver;
using Config.Net;
+using Newtonsoft.Json;
namespace AscNet.Common
{
@@ -21,5 +23,35 @@ namespace AscNet.Common
);
db = mongoClient.GetDatabase(config.Database.Name);
}
+
+ public static void DumpTables()
+ {
+ IEnumerable tableTypes = Assembly.GetAssembly(typeof(Table.client.activity.ActivityGroupTable))!.GetTypes().Where(t => t.BaseType?.Name == "TableReader`2");
+ string baseSavePath = "/PGR_Data/";
+
+ foreach (Type type in tableTypes)
+ {
+ try
+ {
+ object? readerInstance = Activator.CreateInstance(type);
+ readerInstance?.GetType().GetMethod("Load", BindingFlags.Instance | BindingFlags.Public)?.Invoke(readerInstance, null);
+ object? values = type.GetProperty("All", BindingFlags.Instance | BindingFlags.Public)?.GetValue(readerInstance);
+ if (values is not null)
+ {
+ // this will create the folder on ur drive root sorry
+ string savePath = baseSavePath + string.Join("/", type.FullName!.Split(".").Skip(2));
+ if (!Directory.Exists(Path.GetDirectoryName(savePath)))
+ Directory.CreateDirectory(Path.GetDirectoryName(savePath)!);
+ File.WriteAllText(new string(savePath.Take(savePath.Length - 11).ToArray()) + ".json", JsonConvert.SerializeObject(values, Formatting.Indented));
+ Console.WriteLine(type.FullName);
+ }
+
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"{type.FullName} failed!, {ex.Message}");
+ }
+ }
+ }
}
}
diff --git a/AscNet.Common/Database/Character.cs b/AscNet.Common/Database/Character.cs
new file mode 100644
index 00000000..f5571e49
--- /dev/null
+++ b/AscNet.Common/Database/Character.cs
@@ -0,0 +1,81 @@
+using MongoDB.Bson;
+using MongoDB.Bson.Serialization.Attributes;
+using MongoDB.Driver;
+using AscNet.Table.share.character;
+using AscNet.Table.share.character.skill;
+using AscNet.Common.MsgPack;
+
+namespace AscNet.Common.Database
+{
+#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
+ public class Character
+ {
+ public static readonly IMongoCollection collection = Common.db.GetCollection("characters");
+
+ public static Character FromUid(long uid)
+ {
+ return collection.AsQueryable().FirstOrDefault(x => x.Uid == uid) ?? Create(uid);
+ }
+
+ private static Character Create(long uid)
+ {
+ Character character = new()
+ {
+ Uid = uid,
+ Characters = new()
+ };
+ character.AddCharacter(1021001);
+
+ collection.InsertOne(character);
+
+ return character;
+ }
+
+ public void AddCharacter(uint id)
+ {
+ CharacterTable? character = CharacterTableReader.Instance.FromId((int)id);
+ CharacterSkillTable? characterSkill = CharacterSkillTableReader.Instance.FromCharacterId((int)id);
+ if (character is null || characterSkill is null)
+ throw new ArgumentException("Invlid character id!", nameof(id));
+ NotifyCharacterDataList.NotifyCharacterDataListCharacterData characterData = new()
+ {
+ Id = (uint)character.Id,
+ Level = 1,
+ Exp = 0,
+ Quality = 1,
+ InitQuality = 1,
+ Star = 0,
+ Grade = 1,
+ FashionId = (uint)character.DefaultNpcFashtionId,
+ CreateTime = DateTimeOffset.Now.ToUnixTimeSeconds(),
+ TrustLv = 1,
+ TrustExp = 0,
+ Ability = 0,
+ LiberateLv = 1,
+ CharacterHeadInfo = new()
+ {
+ HeadFashionId = (uint)character.DefaultNpcFashtionId,
+ HeadFashionType = 0
+ }
+ };
+ characterData.SkillList.AddRange(characterSkill.SkillGroupId.Take(8).Select(x => new NotifyCharacterDataList.NotifyCharacterDataListCharacterData.NotifyCharacterDataListCharacterDataSkill()
+ {
+ Id = uint.Parse(x.ToString().Take(6).ToArray()),
+ Level = 1
+ }));
+
+ Characters.Add(characterData);
+ }
+
+ [BsonId]
+ public ObjectId Id { get; set; }
+
+ [BsonElement("uid")]
+ [BsonRequired]
+ public long Uid { get; set; }
+
+ [BsonElement("uid")]
+ [BsonRequired]
+ public List Characters { get; set; }
+ }
+}
diff --git a/AscNet.Common/MsgPack/Types.cs b/AscNet.Common/MsgPack/Types.cs
index 001474db..cab56c41 100644
--- a/AscNet.Common/MsgPack/Types.cs
+++ b/AscNet.Common/MsgPack/Types.cs
@@ -54,8 +54,8 @@ namespace AscNet.Common.MsgPack
[MessagePackObject(true)]
public partial class BaseEquipLoginData
{
- public object[] BaseEquipList { get; set; }
- public object[] DressedList { get; set; }
+ public List BaseEquipList { get; set; } = new();
+ public List DressedList { get; set; } = new();
}
@@ -75,8 +75,8 @@ namespace AscNet.Common.MsgPack
public long InitQuality { get; set; }
public long Star { get; set; }
public long Grade { get; set; }
- public SkillList[] SkillList { get; set; }
- public object[] EnhanceSkillList { get; set; }
+ public List SkillList { get; set; } = new();
+ public List EnhanceSkillList { get; set; } = new();
public long FashionId { get; set; }
public long CreateTime { get; set; }
public long TrustLv { get; set; }
@@ -109,9 +109,9 @@ namespace AscNet.Common.MsgPack
public long Level { get; set; }
public long Exp { get; set; }
public long Breakthrough { get; set; }
- public ResonanceInfo[] ResonanceInfo { get; set; }
- public object[] UnconfirmedResonanceInfo { get; set; }
- public object[] AwakeSlotList { get; set; }
+ public List ResonanceInfo { get; set; } = new();
+ public List