diff --git a/Common/Common.csproj b/Common/Common.csproj
index 4ccc41d..0c81582 100644
--- a/Common/Common.csproj
+++ b/Common/Common.csproj
@@ -13,4 +13,10 @@
+
+
+ PreserveNewest
+
+
+
diff --git a/Common/Database/Avatar.cs b/Common/Database/Avatar.cs
new file mode 100644
index 0000000..6d2f624
--- /dev/null
+++ b/Common/Database/Avatar.cs
@@ -0,0 +1,75 @@
+using Common.Resources.Proto;
+using Common.Utils.ExcelReader;
+using MongoDB.Bson;
+using MongoDB.Driver;
+
+namespace Common.Database
+{
+ public class Avatar
+ {
+ public static readonly IMongoCollection collection = Global.db.GetCollection("Avatars");
+
+ public static AvatarScheme[] AvatarsFromUid(uint uid)
+ {
+ return collection.AsQueryable().Where(collection=> collection.OwnerUid == uid).ToArray();
+ }
+
+ public static AvatarScheme Create(int avatarId, uint uid, EquipmentScheme equipment)
+ {
+ AvatarScheme? tryAvatar = collection.AsQueryable().Where(collection => collection.AvatarId == avatarId && collection.OwnerUid == uid).FirstOrDefault();
+ if (tryAvatar != null) { return tryAvatar; }
+
+ AvatarDataExcel? avatarData = AvatarData.GetInstance().FromId(avatarId);
+ if(avatarData == null) { throw new ArgumentException("Invalid avatarId"); }
+
+ Weapon weapon = equipment.AddWeapon(avatarData.InitialWeapon);
+
+ AvatarScheme avatar = new()
+ {
+ OwnerUid = uid,
+ AvatarId = (uint)avatarData.AvatarId,
+ DressId = (uint)avatarData.DefaultDressId,
+ DressLists = new[] { (uint)avatarData.DefaultDressId },
+ Exp = 0,
+ Fragment = 0,
+ Level = 1,
+ Star = (uint)avatarData.UnlockStar,
+ StigmataUniqueId1 = 0,
+ StigmataUniqueId2 = 0,
+ StigmataUniqueId3 = 0,
+ SubStar = 0,
+ TouchGoodfeel = 0,
+ TodayHasAddGoodfeel = 0,
+ WeaponUniqueId = weapon.UniqueId
+ };
+
+ if(avatarData.AvatarId == 101)
+ {
+ Stigmata defaultStigmata1 = equipment.AddStigmata(30007);
+ Stigmata defaultStigmata2 = equipment.AddStigmata(30060);
+ Stigmata defaultStigmata3 = equipment.AddStigmata(30113);
+
+ avatar.StigmataUniqueId1 = defaultStigmata1.UniqueId;
+ avatar.StigmataUniqueId2 = defaultStigmata2.UniqueId;
+ avatar.StigmataUniqueId3 = defaultStigmata3.UniqueId;
+ }
+
+ avatar.SkillLists.AddRange(avatarData.SkillList.Select(skillId => new AvatarSkill { SkillId = (uint)skillId }));
+
+ collection.InsertOne(avatar);
+
+ return avatar;
+ }
+
+ }
+ public class AvatarScheme : Resources.Proto.Avatar
+ {
+ public ObjectId Id { get; set; }
+ public uint OwnerUid { get; set; }
+
+ public void Save()
+ {
+ Avatar.collection.ReplaceOne(Builders.Filter.Eq(avatar => avatar.Id, Id), this);
+ }
+ }
+}
diff --git a/Common/Database/Equipment.cs b/Common/Database/Equipment.cs
new file mode 100644
index 0000000..4771275
--- /dev/null
+++ b/Common/Database/Equipment.cs
@@ -0,0 +1,116 @@
+using Common.Resources.Proto;
+using Common.Utils.ExcelReader;
+using MongoDB.Bson;
+using MongoDB.Driver;
+
+namespace Common.Database
+{
+ public class Equipment
+ {
+ public static readonly IMongoCollection collection = Global.db.GetCollection("Equipments");
+
+ public static EquipmentScheme FromUid(uint uid)
+ {
+ return collection.AsQueryable().Where(collection => collection.OwnerUid == uid).FirstOrDefault() ?? Create(uid);
+ }
+
+ public static EquipmentScheme Create(uint uid)
+ {
+ EquipmentScheme? tryEquipment = collection.AsQueryable().Where(collection => collection.OwnerUid == uid).FirstOrDefault();
+ if (tryEquipment != null) { return tryEquipment; }
+
+ EquipmentScheme Equipment = new()
+ {
+ OwnerUid = uid,
+ MaterialList = Array.Empty(),
+ WeaponList = Array.Empty(),
+ StigmataList = Array.Empty(),
+ MechaList = Array.Empty(),
+ };
+
+ collection.InsertOne(Equipment);
+
+ return Equipment;
+ }
+ }
+
+#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
+ public class EquipmentScheme
+ {
+ public ObjectId Id { get; set; }
+ public uint OwnerUid { get; set; }
+ public Resources.Proto.Material[] MaterialList { get; set; }
+ public Mecha[] MechaList { get; set; }
+ public Stigmata[] StigmataList { get; set; }
+ public Weapon[] WeaponList { get; set; }
+
+ public Weapon AddWeapon(int weaponId)
+ {
+ WeaponDataExcel? weaponData = WeaponData.GetInstance().FromId(weaponId);
+ if (weaponData == null) { throw new ArgumentException("Invalid weaponId"); }
+
+ Weapon weapon = new()
+ {
+ UniqueId = (uint)AutoIncrement.GetNextNumber("Weapon", 100),
+ Id = (uint)weaponData.Id,
+ Level = 1,
+ Exp = 0,
+ IsExtracted = false,
+ IsProtected = false
+ };
+
+ WeaponList = WeaponList.Append(weapon).ToArray();
+ return weapon;
+ }
+
+ public Stigmata AddStigmata(int stigmataId)
+ {
+ StigmataDataExcel? stigmataData = StigmataData.GetInstance().FromId(stigmataId);
+ if (stigmataData == null) { throw new ArgumentException("Invalid stigmataId"); }
+
+ Stigmata stigmata = new()
+ {
+ UniqueId = (uint)AutoIncrement.GetNextNumber("Stigmata", 100),
+ Id = (uint)stigmataData.Id,
+ Level = 1,
+ Exp = 0,
+ IsProtected = false,
+ SlotNum = 0,
+ RefineValue = 0,
+ PromoteTimes = 0
+ };
+
+ StigmataList = StigmataList.Append(stigmata).ToArray();
+ return stigmata;
+ }
+
+ public Resources.Proto.Material AddMaterial(int materialId, int num = 1)
+ {
+ int MaterialIndex = Array.FindIndex(MaterialList, material => material.Id == materialId);
+
+ if(MaterialIndex == -1)
+ {
+ MaterialList = MaterialList.Append(new() { Id = (uint)materialId, Num = num < 0 ? 0 : (uint)num }).ToArray();
+ }
+ else
+ {
+ if (num < 0)
+ {
+ MaterialList[MaterialIndex].Num -= (uint)Math.Abs(num);
+ }
+ else
+ {
+ MaterialList[MaterialIndex].Num += (uint)num;
+ }
+ }
+
+ return MaterialList.Where(material => material.Id == materialId).First();
+ }
+
+ public void Save()
+ {
+ Equipment.collection.ReplaceOne(Builders.Filter.Eq(equipment => equipment.Id, Id), this);
+ }
+ }
+#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
+}
diff --git a/Common/Database/User.cs b/Common/Database/User.cs
index 4deb060..711ff49 100644
--- a/Common/Database/User.cs
+++ b/Common/Database/User.cs
@@ -8,8 +8,11 @@ namespace Common.Database
{
public static readonly IMongoCollection collection = Global.db.GetCollection("Users");
- public static UserScheme CreateUser(string name)
+ public static UserScheme Create(string name)
{
+ UserScheme? tryUser = collection.AsQueryable().Where(d => d.Name == name).FirstOrDefault();
+ if (tryUser != null) { return tryUser; }
+
UserScheme user = new()
{
Name = name,
@@ -41,7 +44,7 @@ namespace Common.Database
public static UserScheme FromName(string name)
{
UserScheme? user = collection.AsQueryable().Where(d => d.Name == name).FirstOrDefault();
- return user ?? CreateUser(name);
+ return user ?? Create(name);
}
public static UserScheme? FromToken(string token)
@@ -50,27 +53,33 @@ namespace Common.Database
return user;
}
-#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
- public class UserScheme
- {
- public ObjectId Id { get; set; }
- public string Name { get; set; }
- public uint Uid { get; set; }
- public string Nick { get; set; }
- public int Exp { get; set; }
- public int Hcoin { get; set; }
- public int Stamina { get; set; }
- public string SelfDesc { get; set; }
- public bool IsFirstLogin { get; set; }
- public string Token { get; set; }
- public int WarshipId { get; set; }
- public WarshipAvatarData WarshipAvatar { get; set; }
- public int AssistantAvatarId { get; set; }
- public int BirthDate { get; set; }
- public List AvatarTeamList { get; set; }
- public List CustomAvatarTeamList { get; set; }
- }
-#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
}
+
+#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
+ public class UserScheme
+ {
+ public ObjectId Id { get; set; }
+ public string Name { get; set; }
+ public uint Uid { get; set; }
+ public string Nick { get; set; }
+ public int Exp { get; set; }
+ public int Hcoin { get; set; }
+ public int Stamina { get; set; }
+ public string SelfDesc { get; set; }
+ public bool IsFirstLogin { get; set; }
+ public string Token { get; set; }
+ public int WarshipId { get; set; }
+ public WarshipAvatarData WarshipAvatar { get; set; }
+ public int AssistantAvatarId { get; set; }
+ public int BirthDate { get; set; }
+ public List AvatarTeamList { get; set; }
+ public List CustomAvatarTeamList { get; set; }
+
+ public void Save()
+ {
+ User.collection.ReplaceOne(Builders.Filter.Eq(user => user.Id, Id), this);
+ }
+ }
+#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
}
diff --git a/Common/Program.cs b/Common/Program.cs
index dc40575..d15260f 100644
--- a/Common/Program.cs
+++ b/Common/Program.cs
@@ -17,7 +17,7 @@ namespace Common
public interface IConfig
{
[Option(DefaultValue = VerboseLevel.Normal)]
- VerboseLevel VerboseLevel { get; }
+ VerboseLevel VerboseLevel { get; set; }
[Option(DefaultValue = false)]
bool UseLocalCache { get; }
diff --git a/Common/Utils/ExcelReader/AvatarData.cs b/Common/Utils/ExcelReader/AvatarData.cs
new file mode 100644
index 0000000..ead45f1
--- /dev/null
+++ b/Common/Utils/ExcelReader/AvatarData.cs
@@ -0,0 +1,187 @@
+using Newtonsoft.Json;
+
+namespace Common.Utils.ExcelReader
+{
+ public class AvatarData : BaseExcelReader
+ {
+ public override string FileName { get { return "AvatarData.json"; } }
+
+ public AvatarDataExcel? FromId(int id)
+ {
+ return All.Where(avatar => avatar.AvatarId == id).FirstOrDefault();
+ }
+ }
+
+#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
+ public partial class AvatarDataExcel
+ {
+ [JsonProperty("classID")]
+ public int ClassId { get; set; }
+
+ [JsonProperty("roleID")]
+ public int RoleId { get; set; }
+
+ [JsonProperty("avatarType")]
+ public int AvatarType { get; set; }
+
+ [JsonProperty("fullName")]
+ public HashName FullName { get; set; }
+
+ [JsonProperty("shortName")]
+ public HashName ShortName { get; set; }
+
+ [JsonProperty("RomaName")]
+ public HashName RomaName { get; set; }
+
+ [JsonProperty("desc")]
+ public HashName Desc { get; set; }
+
+ [JsonProperty("avatarRegistryKey")]
+ public string AvatarRegistryKey { get; set; }
+
+ [JsonProperty("weaponBaseTypeList")]
+ public int[] WeaponBaseTypeList { get; set; }
+
+ [JsonProperty("unlockStar")]
+ public int UnlockStar { get; set; }
+
+ [JsonProperty("skillList")]
+ public int[] SkillList { get; set; }
+
+ [JsonProperty("attribute")]
+ public int Attribute { get; set; }
+
+ [JsonProperty("initialWeapon")]
+ public int InitialWeapon { get; set; }
+
+ [JsonProperty("avatarCardID")]
+ public int AvatarCardId { get; set; }
+
+ [JsonProperty("avatarFragmentID")]
+ public int AvatarFragmentId { get; set; }
+
+ [JsonProperty("artifactFragmentID")]
+ public int ArtifactFragmentId { get; set; }
+
+ [JsonProperty("ultraSkillID")]
+ public int UltraSkillId { get; set; }
+
+ [JsonProperty("captainSkillID")]
+ public int CaptainSkillId { get; set; }
+
+ [JsonProperty("SKL01SP")]
+ public double Skl01Sp { get; set; }
+
+ [JsonProperty("SKL01SPNeed")]
+ public double Skl01SpNeed { get; set; }
+
+ [JsonProperty("SKL01Charges")]
+ public double Skl01Charges { get; set; }
+
+ [JsonProperty("SKL01CD")]
+ public double Skl01Cd { get; set; }
+
+ [JsonProperty("SKL02SP")]
+ public double Skl02Sp { get; set; }
+
+ [JsonProperty("SKL02SPNeed")]
+ public double Skl02SpNeed { get; set; }
+
+ [JsonProperty("SKL02Charges")]
+ public double Skl02Charges { get; set; }
+
+ [JsonProperty("SKL02CD")]
+ public double Skl02Cd { get; set; }
+
+ [JsonProperty("SKL03SP")]
+ public double Skl03Sp { get; set; }
+
+ [JsonProperty("SKL03SPNeed")]
+ public double Skl03SpNeed { get; set; }
+
+ [JsonProperty("SKL03Charges")]
+ public double Skl03Charges { get; set; }
+
+ [JsonProperty("SKL03CD")]
+ public double Skl03Cd { get; set; }
+
+ [JsonProperty("SKL02ArtifactCD")]
+ public double Skl02ArtifactCd { get; set; }
+
+ [JsonProperty("SKL02ArtifactSP")]
+ public double Skl02ArtifactSp { get; set; }
+
+ [JsonProperty("SKL02ArtifactSPNeed")]
+ public double Skl02ArtifactSpNeed { get; set; }
+
+ [JsonProperty("baseAvatarID")]
+ public int BaseAvatarId { get; set; }
+
+ [JsonProperty("firstName")]
+ public HashName FirstName { get; set; }
+
+ [JsonProperty("lastName")]
+ public HashName LastName { get; set; }
+
+ [JsonProperty("enFirstName")]
+ public HashName EnFirstName { get; set; }
+
+ [JsonProperty("enLastName")]
+ public HashName EnLastName { get; set; }
+
+ [JsonProperty("UISelectVoice")]
+ public string UiSelectVoice { get; set; }
+
+ [JsonProperty("UILevelUpVoice")]
+ public string UiLevelUpVoice { get; set; }
+
+ [JsonProperty("DA_Name")]
+ public string DaName { get; set; }
+
+ [JsonProperty("DA_Type")]
+ public string DaType { get; set; }
+
+ [JsonProperty("ArtifactID")]
+ public int ArtifactId { get; set; }
+
+ [JsonProperty("isEasterner")]
+ public bool IsEasterner { get; set; }
+
+ [JsonProperty("FaceAnimationGroupName")]
+ public string FaceAnimationGroupName { get; set; }
+
+ [JsonProperty("AvatarEffects")]
+ public object[] AvatarEffects { get; set; }
+
+ [JsonProperty("TagUnlockList")]
+ public int[] TagUnlockList { get; set; }
+
+ [JsonProperty("DefaultDressId")]
+ public int DefaultDressId { get; set; }
+
+ [JsonProperty("avatarStarUpType")]
+ public int AvatarStarUpType { get; set; }
+
+ [JsonProperty("avatarStarSourceID")]
+ public object[] AvatarStarSourceId { get; set; }
+
+ [JsonProperty("IsCollaboration")]
+ public bool IsCollaboration { get; set; }
+
+ [JsonProperty("StarUpBG")]
+ public string StarUpBg { get; set; }
+
+ [JsonProperty("DataImpl")]
+ public object DataImpl { get; set; }
+
+ [JsonProperty("avatarID")]
+ public int AvatarId { get; set; }
+ }
+
+ public partial class HashName
+ {
+ [JsonProperty("hash")]
+ public long Hash { get; set; }
+ }
+#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
+}
diff --git a/Common/Utils/ExcelReader/ExcelBase.cs b/Common/Utils/ExcelReader/ExcelBase.cs
new file mode 100644
index 0000000..3f89769
--- /dev/null
+++ b/Common/Utils/ExcelReader/ExcelBase.cs
@@ -0,0 +1,33 @@
+using Newtonsoft.Json;
+
+namespace Common.Utils.ExcelReader
+{
+#pragma warning disable CS8618, CS8602 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
+ public abstract class BaseExcelReader
+ {
+ public Scheme[] All { get; set; }
+ private readonly Logger c = new("Factory", ConsoleColor.Yellow);
+ public abstract string FileName { get; }
+ private static Self Instance;
+
+ public static Self GetInstance()
+ {
+ Instance ??= Activator.CreateInstance();
+
+ if ((Instance as BaseExcelReader).All == null)
+ {
+ (Instance as BaseExcelReader).Load();
+ if((int)Global.config.VerboseLevel > 1)
+ (Instance as BaseExcelReader).c.Log($"{typeof(Self).Name} Excel Loaded From {(Instance as BaseExcelReader).FileName}");
+ }
+
+ return Instance;
+ }
+
+ public void Load()
+ {
+ All = JsonConvert.DeserializeObject(File.ReadAllText($"Resources\\ExcelOutputAsset\\{FileName}")) ?? Array.Empty();
+ }
+#pragma warning restore CS8618, CS8602 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
+ }
+}
diff --git a/Common/Utils/ExcelReader/StageData.cs b/Common/Utils/ExcelReader/StageData.cs
new file mode 100644
index 0000000..974951e
--- /dev/null
+++ b/Common/Utils/ExcelReader/StageData.cs
@@ -0,0 +1,250 @@
+using Newtonsoft.Json;
+
+namespace Common.Utils.ExcelReader
+{
+ public class StageData : BaseExcelReader
+ {
+ public override string FileName { get { return "StageData_Main.json"; } }
+
+ public StageDataExcel? FromId(int id)
+ {
+ return All.Where(stage => stage.LevelId == id).FirstOrDefault();
+ }
+ }
+
+#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
+ public partial class StageDataExcel
+ {
+ [JsonProperty("name")]
+ public HashName Name { get; set; }
+
+ [JsonProperty("chapterId")]
+ public int ChapterId { get; set; }
+
+ [JsonProperty("actId")]
+ public int ActId { get; set; }
+
+ [JsonProperty("sectionId")]
+ public int SectionId { get; set; }
+
+ [JsonProperty("difficulty")]
+ public int Difficulty { get; set; }
+
+ [JsonProperty("type")]
+ public int Type { get; set; }
+
+ [JsonProperty("tag")]
+ public int[] Tag { get; set; }
+
+ [JsonProperty("battleType")]
+ public int BattleType { get; set; }
+
+ [JsonProperty("enterTimes")]
+ public int EnterTimes { get; set; }
+
+ [JsonProperty("resetType")]
+ public int ResetType { get; set; }
+
+ [JsonProperty("resetCoinID")]
+ public int ResetCoinId { get; set; }
+
+ [JsonProperty("resetCostType")]
+ public int ResetCostType { get; set; }
+
+ [JsonProperty("resetTimes")]
+ public int ResetTimes { get; set; }
+
+ [JsonProperty("staminaCost")]
+ public int StaminaCost { get; set; }
+
+ [JsonProperty("avatarExpReward")]
+ public int AvatarExpReward { get; set; }
+
+ [JsonProperty("avatarExpInside")]
+ public int AvatarExpInside { get; set; }
+
+ [JsonProperty("scoinReward")]
+ public int ScoinReward { get; set; }
+
+ [JsonProperty("scoinInside")]
+ public double ScoinInside { get; set; }
+
+ [JsonProperty("maxScoinReward")]
+ public int MaxScoinReward { get; set; }
+
+ [JsonProperty("maxProgress")]
+ public int MaxProgress { get; set; }
+
+ [JsonProperty("HighlightDisplayDropIdList")]
+ public int[] HighlightDisplayDropIdList { get; set; }
+
+ [JsonProperty("dropList")]
+ public int[] DropList { get; set; }
+
+ [JsonProperty("recommendPlayerLevel")]
+ public int RecommendPlayerLevel { get; set; }
+
+ [JsonProperty("unlockPlayerLevel")]
+ public int UnlockPlayerLevel { get; set; }
+
+ [JsonProperty("unlockStarNum")]
+ public int UnlockStarNum { get; set; }
+
+ [JsonProperty("preLevelID")]
+ public int[] PreLevelId { get; set; }
+
+ [JsonProperty("displayTitle")]
+ public HashName DisplayTitle { get; set; }
+
+ [JsonProperty("displayDetail")]
+ public HashName DisplayDetail { get; set; }
+
+ [JsonProperty("briefPicPath")]
+ public string BriefPicPath { get; set; }
+
+ [JsonProperty("detailPicPath")]
+ public string DetailPicPath { get; set; }
+
+ [JsonProperty("luaFile")]
+ public string LuaFile { get; set; }
+
+ [JsonProperty("challengeList")]
+ public ChallengeList[] ChallengeList { get; set; }
+
+ [JsonProperty("IsActChallenge")]
+ public bool IsActChallenge { get; set; }
+
+ [JsonProperty("fastBonusTime")]
+ public int FastBonusTime { get; set; }
+
+ [JsonProperty("sonicBonusTime")]
+ public int SonicBonusTime { get; set; }
+
+ [JsonProperty("hardLevel")]
+ public int HardLevel { get; set; }
+
+ [JsonProperty("hardLevelGroup")]
+ public int HardLevelGroup { get; set; }
+
+ [JsonProperty("reviveTimes")]
+ public int ReviveTimes { get; set; }
+
+ [JsonProperty("reviveCostType")]
+ public int ReviveCostType { get; set; }
+
+ [JsonProperty("ReviveUseTypeList")]
+ public int[] ReviveUseTypeList { get; set; }
+
+ [JsonProperty("teamNum")]
+ public int TeamNum { get; set; }
+
+ [JsonProperty("maxNumList")]
+ public int[] MaxNumList { get; set; }
+
+ [JsonProperty("restrictList")]
+ public int[] RestrictList { get; set; }
+
+ [JsonProperty("loseDescList")]
+ public HashName[] LoseDescList { get; set; }
+
+ [JsonProperty("RecordLevelType")]
+ public int RecordLevelType { get; set; }
+
+ [JsonProperty("UseDynamicHardLv")]
+ public int UseDynamicHardLv { get; set; }
+
+ [JsonProperty("isTrunk")]
+ public bool IsTrunk { get; set; }
+
+ [JsonProperty("MonsterAttrShow")]
+ public int[] MonsterAttrShow { get; set; }
+
+ [JsonProperty("playerGetAllDrops")]
+ public bool PlayerGetAllDrops { get; set; }
+
+ [JsonProperty("HardCoeff")]
+ public int HardCoeff { get; set; }
+
+ [JsonProperty("enterTimesType")]
+ public int EnterTimesType { get; set; }
+
+ [JsonProperty("isEnterWithElf")]
+ public int IsEnterWithElf { get; set; }
+
+ [JsonProperty("PreMissionList")]
+ public int[] PreMissionList { get; set; }
+
+ [JsonProperty("LockedText")]
+ public HashName LockedText { get; set; }
+
+ [JsonProperty("PreMissionLink")]
+ public int PreMissionLink { get; set; }
+
+ [JsonProperty("PreMissionLinkParams")]
+ public int[] PreMissionLinkParams { get; set; }
+
+ [JsonProperty("PreMissionLinkParamStr")]
+ public string PreMissionLinkParamStr { get; set; }
+
+ [JsonProperty("UnlockedText")]
+ public HashName UnlockedText { get; set; }
+
+ [JsonProperty("UnlockedLink")]
+ public int UnlockedLink { get; set; }
+
+ [JsonProperty("UnlockedLinkParams")]
+ public int[] UnlockedLinkParams { get; set; }
+
+ [JsonProperty("UnlockedLinkParamStr")]
+ public string UnlockedLinkParamStr { get; set; }
+
+ [JsonProperty("costMaterialId")]
+ public int CostMaterialId { get; set; }
+
+ [JsonProperty("costMaterialNum")]
+ public int CostMaterialNum { get; set; }
+
+ [JsonProperty("firstCostMaterialNum")]
+ public int FirstCostMaterialNum { get; set; }
+
+ [JsonProperty("BalanceModeType")]
+ public int BalanceModeType { get; set; }
+
+ [JsonProperty("StageEntryNameList")]
+ public string[] StageEntryNameList { get; set; }
+
+ [JsonProperty("FloatDrop")]
+ public FloatDrop[] FloatDrop { get; set; }
+
+ [JsonProperty("IsBattleYLevel")]
+ public bool IsBattleYLevel { get; set; }
+
+ [JsonProperty("DataImpl")]
+ public object DataImpl { get; set; }
+
+ [JsonProperty("levelId")]
+ public int LevelId { get; set; }
+ }
+
+ public partial class ChallengeList
+ {
+ [JsonProperty("challengeId")]
+ public int ChallengeId { get; set; }
+
+ [JsonProperty("rewardId")]
+ public int RewardId { get; set; }
+ }
+
+ public partial class FloatDrop
+ {
+ [JsonProperty("materialId")]
+ public long MaterialId { get; set; }
+
+ [JsonProperty("maxNum")]
+ public long MaxNum { get; set; }
+
+ [JsonProperty("minNum")]
+ public long MinNum { get; set; }
+ }
+#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
+}
diff --git a/Common/Utils/ExcelReader/StigmataData.cs b/Common/Utils/ExcelReader/StigmataData.cs
new file mode 100644
index 0000000..e97636c
--- /dev/null
+++ b/Common/Utils/ExcelReader/StigmataData.cs
@@ -0,0 +1,255 @@
+using Newtonsoft.Json;
+
+namespace Common.Utils.ExcelReader
+{
+ public class StigmataData : BaseExcelReader
+ {
+ public override string FileName { get { return "StigmataData.json"; } }
+ public StigmataDataExcel? FromId(int id)
+ {
+ return All.Where(stigmata => stigmata.Id == id).FirstOrDefault();
+ }
+ }
+
+#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
+ public partial class StigmataDataExcel
+ {
+ [JsonProperty("rarity")]
+ public int Rarity { get; set; }
+
+ [JsonProperty("maxRarity")]
+ public int MaxRarity { get; set; }
+
+ [JsonProperty("subRarity")]
+ public int SubRarity { get; set; }
+
+ [JsonProperty("subMaxRarity")]
+ public int SubMaxRarity { get; set; }
+
+ [JsonProperty("cost")]
+ public int Cost { get; set; }
+
+ [JsonProperty("powerType")]
+ public int PowerType { get; set; }
+
+ [JsonProperty("maxLv")]
+ public int MaxLv { get; set; }
+
+ [JsonProperty("expType")]
+ public int ExpType { get; set; }
+
+ [JsonProperty("sellPriceBase")]
+ public int SellPriceBase { get; set; }
+
+ [JsonProperty("sellPriceAdd")]
+ public int SellPriceAdd { get; set; }
+
+ [JsonProperty("gearExpProvideBase")]
+ public int GearExpProvideBase { get; set; }
+
+ [JsonProperty("gearExpPorvideAdd")]
+ public int GearExpPorvideAdd { get; set; }
+
+ [JsonProperty("baseType")]
+ public int BaseType { get; set; }
+
+ [JsonProperty("LabelPath")]
+ public string LabelPath { get; set; }
+
+ [JsonProperty("displayTitle")]
+ public HashName DisplayTitle { get; set; }
+
+ [JsonProperty("displayDescription")]
+ public HashName DisplayDescription { get; set; }
+
+ [JsonProperty("displayNumber")]
+ public int DisplayNumber { get; set; }
+
+ [JsonProperty("iconPath")]
+ public string IconPath { get; set; }
+
+ [JsonProperty("imagePath")]
+ public string ImagePath { get; set; }
+
+ [JsonProperty("HPBase")]
+ public double HpBase { get; set; }
+
+ [JsonProperty("HPAdd")]
+ public double HpAdd { get; set; }
+
+ [JsonProperty("SPBase")]
+ public double SpBase { get; set; }
+
+ [JsonProperty("SPAdd")]
+ public double SpAdd { get; set; }
+
+ [JsonProperty("attackBase")]
+ public double AttackBase { get; set; }
+
+ [JsonProperty("attackAdd")]
+ public double AttackAdd { get; set; }
+
+ [JsonProperty("defenceBase")]
+ public double DefenceBase { get; set; }
+
+ [JsonProperty("defenceAdd")]
+ public double DefenceAdd { get; set; }
+
+ [JsonProperty("criticalBase")]
+ public double CriticalBase { get; set; }
+
+ [JsonProperty("criticalAdd")]
+ public double CriticalAdd { get; set; }
+
+ [JsonProperty("durabilityMax")]
+ public int DurabilityMax { get; set; }
+
+ [JsonProperty("evoMaterial")]
+ public Material[] EvoMaterial { get; set; }
+
+ [JsonProperty("evoID")]
+ public int EvoId { get; set; }
+
+ [JsonProperty("prop1ID")]
+ public double Prop1Id { get; set; }
+
+ [JsonProperty("prop1Param1")]
+ public double Prop1Param1 { get; set; }
+
+ [JsonProperty("prop1Param2")]
+ public double Prop1Param2 { get; set; }
+
+ [JsonProperty("prop1Param3")]
+ public double Prop1Param3 { get; set; }
+
+ [JsonProperty("prop1Param1Add")]
+ public double Prop1Param1Add { get; set; }
+
+ [JsonProperty("prop1Param2Add")]
+ public double Prop1Param2Add { get; set; }
+
+ [JsonProperty("prop1Param3Add")]
+ public double Prop1Param3Add { get; set; }
+
+ [JsonProperty("prop2ID")]
+ public double Prop2Id { get; set; }
+
+ [JsonProperty("prop2Param1")]
+ public double Prop2Param1 { get; set; }
+
+ [JsonProperty("prop2Param2")]
+ public double Prop2Param2 { get; set; }
+
+ [JsonProperty("prop2Param3")]
+ public double Prop2Param3 { get; set; }
+
+ [JsonProperty("prop2Param1Add")]
+ public double Prop2Param1Add { get; set; }
+
+ [JsonProperty("prop2Param2Add")]
+ public double Prop2Param2Add { get; set; }
+
+ [JsonProperty("prop2Param3Add")]
+ public double Prop2Param3Add { get; set; }
+
+ [JsonProperty("prop3ID")]
+ public double Prop3Id { get; set; }
+
+ [JsonProperty("prop3Param1")]
+ public double Prop3Param1 { get; set; }
+
+ [JsonProperty("prop3Param2")]
+ public double Prop3Param2 { get; set; }
+
+ [JsonProperty("prop3Param3")]
+ public double Prop3Param3 { get; set; }
+
+ [JsonProperty("prop3Param1Add")]
+ public double Prop3Param1Add { get; set; }
+
+ [JsonProperty("prop3Param2Add")]
+ public double Prop3Param2Add { get; set; }
+
+ [JsonProperty("prop3Param3Add")]
+ public double Prop3Param3Add { get; set; }
+
+ [JsonProperty("protect")]
+ public bool Protect { get; set; }
+
+ [JsonProperty("setID")]
+ public int SetId { get; set; }
+
+ [JsonProperty("smallIcon")]
+ public string SmallIcon { get; set; }
+
+ [JsonProperty("tattooPath")]
+ public string TattooPath { get; set; }
+
+ [JsonProperty("offsetX")]
+ public int OffsetX { get; set; }
+
+ [JsonProperty("offsetY")]
+ public int OffsetY { get; set; }
+
+ [JsonProperty("scale")]
+ public double Scale { get; set; }
+
+ [JsonProperty("affixTreeId")]
+ public int AffixTreeId { get; set; }
+
+ [JsonProperty("canRefine")]
+ public bool CanRefine { get; set; }
+
+ [JsonProperty("recycleID")]
+ public int RecycleId { get; set; }
+
+ [JsonProperty("disjoinScoinCost")]
+ public int DisjoinScoinCost { get; set; }
+
+ [JsonProperty("disjoinAddMaterial")]
+ public Material[] DisjoinAddMaterial { get; set; }
+
+ [JsonProperty("LinkIDList")]
+ public int[] LinkIdList { get; set; }
+
+ [JsonProperty("quality")]
+ public int Quality { get; set; }
+
+ [JsonProperty("stigmataMainID")]
+ public int StigmataMainId { get; set; }
+
+ [JsonProperty("ShortName")]
+ public HashName ShortName { get; set; }
+
+ [JsonProperty("SellPriceID")]
+ public int SellPriceId { get; set; }
+
+ [JsonProperty("Transcendent")]
+ public bool Transcendent { get; set; }
+
+ [JsonProperty("Target")]
+ public int Target { get; set; }
+
+ [JsonProperty("isSecurityProtect")]
+ public bool IsSecurityProtect { get; set; }
+
+ [JsonProperty("GachaMainDropDisplayConfig")]
+ public double[] GachaMainDropDisplayConfig { get; set; }
+
+ [JsonProperty("GachaGiftDropDisplayConfig")]
+ public double[] GachaGiftDropDisplayConfig { get; set; }
+
+ [JsonProperty("StigmataFilterList")]
+ public int[] StigmataFilterList { get; set; }
+
+ [JsonProperty("CollaborationSetID")]
+ public int CollaborationSetId { get; set; }
+
+ [JsonProperty("DataImpl")]
+ public object DataImpl { get; set; }
+
+ [JsonProperty("ID")]
+ public int Id { get; set; }
+ }
+#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
+}
diff --git a/Common/Utils/ExcelReader/WeaponData.cs b/Common/Utils/ExcelReader/WeaponData.cs
new file mode 100644
index 0000000..d942c40
--- /dev/null
+++ b/Common/Utils/ExcelReader/WeaponData.cs
@@ -0,0 +1,246 @@
+using Newtonsoft.Json;
+
+namespace Common.Utils.ExcelReader
+{
+ public class WeaponData : BaseExcelReader
+ {
+ public override string FileName { get { return "WeaponData.json"; } }
+ public WeaponDataExcel? FromId(int id)
+ {
+ return All.Where(weapon => weapon.Id == id).FirstOrDefault();
+ }
+ }
+
+#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
+ public partial class WeaponDataExcel
+ {
+ [JsonProperty("rarity")]
+ public int Rarity { get; set; }
+
+ [JsonProperty("maxRarity")]
+ public int MaxRarity { get; set; }
+
+ [JsonProperty("subRarity")]
+ public int SubRarity { get; set; }
+
+ [JsonProperty("subMaxRarity")]
+ public int SubMaxRarity { get; set; }
+
+ [JsonProperty("cost")]
+ public int Cost { get; set; }
+
+ [JsonProperty("powerType")]
+ public int PowerType { get; set; }
+
+ [JsonProperty("maxLv")]
+ public int MaxLv { get; set; }
+
+ [JsonProperty("expType")]
+ public int ExpType { get; set; }
+
+ [JsonProperty("sellPriceBase")]
+ public int SellPriceBase { get; set; }
+
+ [JsonProperty("sellPriceAdd")]
+ public int SellPriceAdd { get; set; }
+
+ [JsonProperty("gearExpProvideBase")]
+ public int GearExpProvideBase { get; set; }
+
+ [JsonProperty("gearExpPorvideAdd")]
+ public int GearExpPorvideAdd { get; set; }
+
+ [JsonProperty("baseType")]
+ public int BaseType { get; set; }
+
+ [JsonProperty("bodyMod")]
+ public string BodyMod { get; set; }
+
+ [JsonProperty("displayTitle")]
+ public HashName DisplayTitle { get; set; }
+
+ [JsonProperty("displayDescription")]
+ public HashName DisplayDescription { get; set; }
+
+ [JsonProperty("iconPath")]
+ public string IconPath { get; set; }
+
+ [JsonProperty("imagePath")]
+ public string ImagePath { get; set; }
+
+ [JsonProperty("HPBase")]
+ public double HpBase { get; set; }
+
+ [JsonProperty("HPAdd")]
+ public double HpAdd { get; set; }
+
+ [JsonProperty("SPBase")]
+ public double SpBase { get; set; }
+
+ [JsonProperty("SPAdd")]
+ public double SpAdd { get; set; }
+
+ [JsonProperty("attackBase")]
+ public double AttackBase { get; set; }
+
+ [JsonProperty("attackAdd")]
+ public double AttackAdd { get; set; }
+
+ [JsonProperty("defenceBase")]
+ public double DefenceBase { get; set; }
+
+ [JsonProperty("defenceAdd")]
+ public double DefenceAdd { get; set; }
+
+ [JsonProperty("criticalBase")]
+ public double CriticalBase { get; set; }
+
+ [JsonProperty("criticalAdd")]
+ public double CriticalAdd { get; set; }
+
+ [JsonProperty("ResistanceBase")]
+ public double ResistanceBase { get; set; }
+
+ [JsonProperty("ResistanceAdd")]
+ public double ResistanceAdd { get; set; }
+
+ [JsonProperty("evoMaterial")]
+ public Material[] EvoMaterial { get; set; }
+
+ [JsonProperty("evoPlayerLevel")]
+ public int EvoPlayerLevel { get; set; }
+
+ [JsonProperty("evoID")]
+ public int EvoId { get; set; }
+
+ [JsonProperty("prop1ID")]
+ public double Prop1Id { get; set; }
+
+ [JsonProperty("prop1Param1")]
+ public double Prop1Param1 { get; set; }
+
+ [JsonProperty("prop1Param2")]
+ public double Prop1Param2 { get; set; }
+
+ [JsonProperty("prop1Param3")]
+ public double Prop1Param3 { get; set; }
+
+ [JsonProperty("prop1Param1Add")]
+ public double Prop1Param1Add { get; set; }
+
+ [JsonProperty("prop1Param2Add")]
+ public double Prop1Param2Add { get; set; }
+
+ [JsonProperty("prop1Param3Add")]
+ public double Prop1Param3Add { get; set; }
+
+ [JsonProperty("prop2ID")]
+ public double Prop2Id { get; set; }
+
+ [JsonProperty("prop2Param1")]
+ public double Prop2Param1 { get; set; }
+
+ [JsonProperty("prop2Param2")]
+ public double Prop2Param2 { get; set; }
+
+ [JsonProperty("prop2Param3")]
+ public double Prop2Param3 { get; set; }
+
+ [JsonProperty("prop2Param1Add")]
+ public double Prop2Param1Add { get; set; }
+
+ [JsonProperty("prop2Param2Add")]
+ public double Prop2Param2Add { get; set; }
+
+ [JsonProperty("prop2Param3Add")]
+ public double Prop2Param3Add { get; set; }
+
+ [JsonProperty("prop3ID")]
+ public double Prop3Id { get; set; }
+
+ [JsonProperty("prop3Param1")]
+ public double Prop3Param1 { get; set; }
+
+ [JsonProperty("prop3Param2")]
+ public double Prop3Param2 { get; set; }
+
+ [JsonProperty("prop3Param3")]
+ public double Prop3Param3 { get; set; }
+
+ [JsonProperty("prop3Param1Add")]
+ public double Prop3Param1Add { get; set; }
+
+ [JsonProperty("prop3Param2Add")]
+ public double Prop3Param2Add { get; set; }
+
+ [JsonProperty("prop3Param3Add")]
+ public double Prop3Param3Add { get; set; }
+
+ [JsonProperty("protect")]
+ public bool Protect { get; set; }
+
+ [JsonProperty("ExDisjoinCurrencyCost")]
+ public int ExDisjoinCurrencyCost { get; set; }
+
+ [JsonProperty("ExDisjoinAddMaterial")]
+ public object[] ExDisjoinAddMaterial { get; set; }
+
+ [JsonProperty("disjoinScoinCost")]
+ public int DisjoinScoinCost { get; set; }
+
+ [JsonProperty("disjoinAddMaterial")]
+ public Material[] DisjoinAddMaterial { get; set; }
+
+ [JsonProperty("weaponMainID")]
+ public int WeaponMainId { get; set; }
+
+ [JsonProperty("LinkIDList")]
+ public int[] LinkIdList { get; set; }
+
+ [JsonProperty("weaponQuality")]
+ public int WeaponQuality { get; set; }
+
+ [JsonProperty("SellPriceID")]
+ public int SellPriceId { get; set; }
+
+ [JsonProperty("Transcendent")]
+ public bool Transcendent { get; set; }
+
+ [JsonProperty("Target")]
+ public int Target { get; set; }
+
+ [JsonProperty("GachaMainDropDisplayConfig")]
+ public double[] GachaMainDropDisplayConfig { get; set; }
+
+ [JsonProperty("GachaGiftDropDisplayConfig")]
+ public double[] GachaGiftDropDisplayConfig { get; set; }
+
+ [JsonProperty("PreloadEffectFolderPath")]
+ public string PreloadEffectFolderPath { get; set; }
+
+ [JsonProperty("WeaponFilterList")]
+ public int[] WeaponFilterList { get; set; }
+
+ [JsonProperty("CollaborationWeaponID")]
+ public int CollaborationWeaponId { get; set; }
+
+ [JsonProperty("AvatarCustomDisplayID")]
+ public int AvatarCustomDisplayId { get; set; }
+
+ [JsonProperty("DataImpl")]
+ public object DataImpl { get; set; }
+
+ [JsonProperty("ID")]
+ public int Id { get; set; }
+ }
+
+ public partial class Material
+ {
+ [JsonProperty("ID")]
+ public int Id { get; set; }
+
+ [JsonProperty("Num")]
+ public int Num { get; set; }
+ }
+#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
+}
diff --git a/GameServer/Game/Player.cs b/GameServer/Game/Player.cs
index 3933e45..12809f9 100644
--- a/GameServer/Game/Player.cs
+++ b/GameServer/Game/Player.cs
@@ -4,11 +4,26 @@ namespace PemukulPaku.GameServer.Game
{
public class Player
{
- public User.UserScheme User;
+ public UserScheme User;
+ public AvatarScheme[] AvatarList;
+ public EquipmentScheme Equipment;
- public Player(User.UserScheme user)
+ public Player(UserScheme user)
{
User = user;
+ Equipment = Common.Database.Equipment.FromUid(user.Uid);
+ AvatarList = Avatar.AvatarsFromUid(user.Uid);
+ }
+
+ public void SaveAll()
+ {
+ User.Save();
+ Equipment.Save();
+
+ foreach (AvatarScheme Avatar in AvatarList)
+ {
+ Avatar.Save();
+ }
}
}
}
diff --git a/GameServer/Handlers/GetAvatarDataReqHandler.cs b/GameServer/Handlers/GetAvatarDataReqHandler.cs
new file mode 100644
index 0000000..b368cd9
--- /dev/null
+++ b/GameServer/Handlers/GetAvatarDataReqHandler.cs
@@ -0,0 +1,86 @@
+using Common.Resources.Proto;
+
+namespace PemukulPaku.GameServer.Handlers
+{
+ [PacketCmdId(CmdId.GetAvatarDataReq)]
+ internal class GetAvatarDataReqHandler : IPacketHandler
+ {
+ public void Handle(Session session, Packet packet)
+ {
+ GetAvatarDataReq Packet = packet.GetDecodedBody();
+
+ GetAvatarDataRsp Rsp = new()
+ {
+ retcode = GetAvatarDataRsp.Retcode.Succ
+ };
+
+ if (Packet.AvatarIdLists.Contains((uint)0))
+ {
+ IEnumerable Avatars = session.Player.AvatarList.Select(avatar =>
+ {
+ Avatar a = new()
+ {
+ AvatarId = avatar.AvatarId,
+ AvatarArtifact = avatar.AvatarArtifact,
+ DressId = avatar.DressId,
+ DressLists = avatar.DressLists,
+ Level = avatar.Level,
+ Exp = avatar.Exp,
+ Fragment = avatar.Fragment,
+ Mode = avatar.Mode,
+ StageGoodfeel = avatar.StageGoodfeel,
+ Star = avatar.Star,
+ StigmataUniqueId1 = avatar.StigmataUniqueId1,
+ StigmataUniqueId2 = avatar.StigmataUniqueId2,
+ StigmataUniqueId3 = avatar.StigmataUniqueId3,
+ SubStar = avatar.SubStar,
+ TodayHasAddGoodfeel = avatar.TodayHasAddGoodfeel,
+ TouchGoodfeel = avatar.TouchGoodfeel,
+ WeaponUniqueId = avatar.WeaponUniqueId
+ };
+ a.SkillLists.AddRange(avatar.SkillLists);
+
+ return a;
+ });
+
+ Rsp.IsAll = true;
+ Rsp.AvatarLists.AddRange(Avatars);
+ }
+ else
+ {
+ IEnumerable Avatars = session.Player.AvatarList.Where(avatar => Packet.AvatarIdLists.Contains(avatar.AvatarId)).Select(avatar =>
+ {
+ Avatar a = new()
+ {
+ AvatarId = avatar.AvatarId,
+ AvatarArtifact = avatar.AvatarArtifact,
+ DressId = avatar.DressId,
+ DressLists = avatar.DressLists,
+ Level = avatar.Level,
+ Exp = avatar.Exp,
+ Fragment = avatar.Fragment,
+ Mode = avatar.Mode,
+ StageGoodfeel = avatar.StageGoodfeel,
+ Star = avatar.Star,
+ StigmataUniqueId1 = avatar.StigmataUniqueId1,
+ StigmataUniqueId2 = avatar.StigmataUniqueId2,
+ StigmataUniqueId3 = avatar.StigmataUniqueId3,
+ SubStar = avatar.SubStar,
+ TodayHasAddGoodfeel = avatar.TodayHasAddGoodfeel,
+ TouchGoodfeel = avatar.TouchGoodfeel,
+ WeaponUniqueId = avatar.WeaponUniqueId
+ };
+ a.SkillLists.AddRange(avatar.SkillLists);
+
+ return a;
+ });
+
+ Rsp.AvatarLists.AddRange(Avatars);
+
+ Rsp.IsAll = false;
+ }
+
+ session.Send(GameServer.Packet.FromProto(Rsp, CmdId.GetAvatarDataRsp));
+ }
+ }
+}
diff --git a/GameServer/Handlers/GetAvatarTeamDataReqHandler.cs b/GameServer/Handlers/GetAvatarTeamDataReqHandler.cs
index 509ccfd..50787ff 100644
--- a/GameServer/Handlers/GetAvatarTeamDataReqHandler.cs
+++ b/GameServer/Handlers/GetAvatarTeamDataReqHandler.cs
@@ -1,5 +1,4 @@
using Common.Resources.Proto;
-using Newtonsoft.Json;
namespace PemukulPaku.GameServer.Handlers
{
diff --git a/GameServer/Handlers/GetConfigReqHandler.cs b/GameServer/Handlers/GetConfigReqHandler.cs
new file mode 100644
index 0000000..6f0dac4
--- /dev/null
+++ b/GameServer/Handlers/GetConfigReqHandler.cs
@@ -0,0 +1,20 @@
+using Common;
+using Common.Resources.Proto;
+
+namespace PemukulPaku.GameServer.Handlers
+{
+ [PacketCmdId(CmdId.GetConfigReq)]
+ internal class GetConfigReqHandler : IPacketHandler
+ {
+ public void Handle(Session session, Packet packet)
+ {
+ GetConfigRsp Rsp = new()
+ {
+ retcode = GetConfigRsp.Retcode.Succ,
+ ServerCurTime = (uint)Global.GetUnixInSeconds(),
+ };
+
+ session.Send(Packet.FromProto(Rsp, CmdId.GetConfigRsp));
+ }
+ }
+}
diff --git a/GameServer/Handlers/GetEquipmentDataReqHandler.cs b/GameServer/Handlers/GetEquipmentDataReqHandler.cs
new file mode 100644
index 0000000..e6e5d6a
--- /dev/null
+++ b/GameServer/Handlers/GetEquipmentDataReqHandler.cs
@@ -0,0 +1,29 @@
+using Common.Database;
+using Common.Resources.Proto;
+using MongoDB.Driver;
+
+namespace PemukulPaku.GameServer.Handlers
+{
+ [PacketCmdId(CmdId.GetEquipmentDataReq)]
+ internal class GetEquipmentDataReqHandler : IPacketHandler
+ {
+ public void Handle(Session session, Packet packet)
+ {
+ EquipmentScheme Equipment = session.Player.Equipment;
+
+ GetEquipmentDataRsp Rsp = new()
+ {
+ retcode = GetEquipmentDataRsp.Retcode.Succ,
+ VitalityValue = 0,
+ IsAll = true
+ };
+
+ Rsp.MaterialLists.AddRange(Equipment.MaterialList.ToList());
+ Rsp.MechaLists.AddRange(Equipment.MechaList.ToList());
+ Rsp.StigmataLists.AddRange(Equipment.StigmataList.ToList());
+ Rsp.WeaponLists.AddRange(Equipment.WeaponList.ToList());
+
+ session.Send(Packet.FromProto(Rsp, CmdId.GetEquipmentDataRsp));
+ }
+ }
+}
diff --git a/GameServer/Handlers/GetMainDataReqHandler.cs b/GameServer/Handlers/GetMainDataReqHandler.cs
new file mode 100644
index 0000000..ce961d7
--- /dev/null
+++ b/GameServer/Handlers/GetMainDataReqHandler.cs
@@ -0,0 +1,29 @@
+using Common.Database;
+using Common.Resources.Proto;
+
+namespace PemukulPaku.GameServer.Handlers
+{
+ [PacketCmdId(CmdId.GetMainDataReq)]
+ internal class GetMainDataReqHandler : IPacketHandler
+ {
+ public void Handle(Session session, Packet packet)
+ {
+ UserScheme User = session.Player.User;
+
+ GetMainDataRsp Rsp = new()
+ {
+ retcode = GetMainDataRsp.Retcode.Succ,
+ AssistantAvatarId = (uint)User.AssistantAvatarId,
+ Birthday = (uint)User.BirthDate,
+ Nickname = User.Nick,
+ Level = 4,
+ Exp = (uint)User.Exp,
+ FreeHcoin = (uint)User.Hcoin,
+ Hcoin = (uint)User.Hcoin,
+ CustomHeadId = 161001
+ };
+
+ session.Send(Packet.FromProto(Rsp, CmdId.GetMainDataRsp));
+ }
+ }
+}
diff --git a/GameServer/Handlers/GetPlayerTokenReqHandler.cs b/GameServer/Handlers/GetPlayerTokenReqHandler.cs
index 7ae8ba9..f6ce68a 100644
--- a/GameServer/Handlers/GetPlayerTokenReqHandler.cs
+++ b/GameServer/Handlers/GetPlayerTokenReqHandler.cs
@@ -1,5 +1,6 @@
using Common.Resources.Proto;
using Common.Database;
+using Common;
namespace PemukulPaku.GameServer.Handlers
{
@@ -10,7 +11,7 @@ namespace PemukulPaku.GameServer.Handlers
{
GetPlayerTokenReq Packet = _packet.GetDecodedBody();
GetPlayerTokenRsp Rsp = new () { };
- User.UserScheme? CurrentUser = User.FromToken(Packet.AccountToken);
+ UserScheme? CurrentUser = User.FromToken(Packet.AccountToken);
if (CurrentUser == null || CurrentUser.Uid != uint.Parse(Packet.AccountUid))
{
@@ -21,6 +22,13 @@ namespace PemukulPaku.GameServer.Handlers
{
session.Player = new Game.Player(CurrentUser);
+ if(session.Player.User.IsFirstLogin)
+ {
+ AvatarScheme avatar = Common.Database.Avatar.Create(101, session.Player.User.Uid, session.Player.Equipment);
+ if ((int)Global.config.VerboseLevel > 0)
+ session.c.Log($"Automatically created avatar with id: {avatar.AvatarId}");
+ }
+
Rsp = new()
{
retcode = GetPlayerTokenRsp.Retcode.Succ,
diff --git a/GameServer/Handlers/PlayerLoginReqHandler.cs b/GameServer/Handlers/PlayerLoginReqHandler.cs
index 09c55c2..3af58ce 100644
--- a/GameServer/Handlers/PlayerLoginReqHandler.cs
+++ b/GameServer/Handlers/PlayerLoginReqHandler.cs
@@ -1,7 +1,6 @@
using Common;
using Common.Database;
using Common.Resources.Proto;
-using Newtonsoft.Json;
namespace PemukulPaku.GameServer.Handlers
{
@@ -10,7 +9,7 @@ namespace PemukulPaku.GameServer.Handlers
{
public void Handle(Session session, Packet packet)
{
- User.UserScheme User = session.Player.User;
+ UserScheme User = session.Player.User;
PlayerLoginRsp Rsp = new()
{
diff --git a/GameServer/Handlers/StageBeginReqHandler.cs b/GameServer/Handlers/StageBeginReqHandler.cs
new file mode 100644
index 0000000..74162f8
--- /dev/null
+++ b/GameServer/Handlers/StageBeginReqHandler.cs
@@ -0,0 +1,23 @@
+using Common.Resources.Proto;
+
+namespace PemukulPaku.GameServer.Handlers
+{
+ [PacketCmdId(CmdId.StageBeginReq)]
+ internal class StageBeginReqHandler : IPacketHandler
+ {
+ public void Handle(Session session, Packet packet)
+ {
+ StageBeginReq Data = packet.GetDecodedBody();
+
+ StageBeginRsp Rsp = new()
+ {
+ retcode = StageBeginRsp.Retcode.Succ,
+ StageId = Data.StageId,
+ Progress = 0,
+ IsCollectCheatData = false
+ };
+
+ session.Send(Packet.FromProto(Rsp, CmdId.StageBeginRsp));
+ }
+ }
+}
diff --git a/GameServer/Handlers/StageEndReqHandler.cs b/GameServer/Handlers/StageEndReqHandler.cs
new file mode 100644
index 0000000..5d6e6c0
--- /dev/null
+++ b/GameServer/Handlers/StageEndReqHandler.cs
@@ -0,0 +1,59 @@
+using Common.Database;
+using Common.Resources.Proto;
+using Common.Utils.ExcelReader;
+using ProtoBuf;
+
+namespace PemukulPaku.GameServer.Handlers
+{
+ [PacketCmdId(CmdId.StageEndReq)]
+ internal class StageEndReqHandler : IPacketHandler
+ {
+ public void Handle(Session session, Packet packet)
+ {
+ StageEndReq Data = packet.GetDecodedBody();
+ StageEndReqBody DecodedBody = Serializer.Deserialize(Data.Body.AsSpan());
+ StageDataExcel? StageData = Common.Utils.ExcelReader.StageData.GetInstance().FromId((int)DecodedBody.StageId);
+
+ if(StageData == null)
+ {
+ session.c.Error("StageData Excel Is Bad Please Fix");
+ session.Send(Packet.FromProto(new StageEndRsp() { retcode = StageEndRsp.Retcode.StageError }, CmdId.StageEndRsp));
+ return;
+ }
+ else if(StageData.LevelId == 10101)
+ {
+ session.Player.User.IsFirstLogin = false;
+ }
+
+ StageEndRsp Rsp = new()
+ {
+ retcode = StageEndRsp.Retcode.Succ,
+ StageId = DecodedBody.StageId,
+ EndStatus = DecodedBody.EndStatus
+ };
+
+ if(DecodedBody.EndStatus == StageEndStatus.StageWin)
+ {
+ EquipmentScheme Equipment = session.Player.Equipment;
+
+ foreach (DropItem DropItem in DecodedBody.DropItemLists)
+ {
+ Equipment.AddMaterial((int)DropItem.ItemId, (int)DropItem.Num);
+ }
+
+ session.Player.User.Hcoin += DecodedBody.ChallengeIndexLists.Length * 5;
+
+ session.ProcessPacket(Packet.FromProto(new GetEquipmentDataReq() { }, CmdId.GetEquipmentDataReq));
+ session.ProcessPacket(Packet.FromProto(new GetWorldMapDataReq() { }, CmdId.GetWorldMapDataReq));
+ session.ProcessPacket(Packet.FromProto(new ChapterGroupGetDataReq() { }, CmdId.ChapterGroupGetDataReq));
+
+ Rsp.PlayerExpReward = 100;
+ Rsp.AvatarExpReward = DecodedBody.AvatarExpReward;
+ Rsp.ScoinReward = DecodedBody.ScoinReward;
+ Rsp.ChallengeLists.AddRange(DecodedBody.ChallengeIndexLists.Select(challengeIndex => new StageChallengeData() { ChallengeIndex = challengeIndex, Reward = new() { Hcoin = 5 } }));
+ }
+
+ session.Send(Packet.FromProto(Rsp, CmdId.StageEndRsp));
+ }
+ }
+}
diff --git a/GameServer/Packet.cs b/GameServer/Packet.cs
index 0c3580b..b62c323 100644
--- a/GameServer/Packet.cs
+++ b/GameServer/Packet.cs
@@ -123,8 +123,9 @@ namespace PemukulPaku.GameServer
select (t, attr))
{
Handlers.Add(attr.Id, (IPacketHandler)Activator.CreateInstance(t)!);
-
+#if DEBUG
c.Log($"Loaded PacketHandler {t.Name} for Packet Type {attr.Id}");
+#endif
}
c.Log("Finished Loading Packet Handlers");
diff --git a/GameServer/Session.cs b/GameServer/Session.cs
index ff817eb..9826d03 100644
--- a/GameServer/Session.cs
+++ b/GameServer/Session.cs
@@ -1,7 +1,4 @@
-using System.Data.SqlTypes;
-using System;
-using System.IO;
-using System.Net.Sockets;
+using System.Net.Sockets;
using Common;
using Common.Resources.Proto;
using Common.Utils;
@@ -67,7 +64,7 @@ namespace PemukulPaku.GameServer
{
if (Packet.IsValid(packet))
{
- ProcessPacket(packet);
+ ProcessPacket(new Packet(packet));
}
else
{
@@ -77,16 +74,13 @@ namespace PemukulPaku.GameServer
}
}
- c.Debug("ClientLoop ends");
- Server.GetInstance().LogClients();
-
c.Warn($"{Id} disconnected");
Server.GetInstance().Sessions.Remove(Id);
+ Server.GetInstance().LogClients();
}
- public void ProcessPacket(byte[] packet)
+ public void ProcessPacket(Packet _packet)
{
- Packet _packet = new(packet);
string PacketName = Enum.GetName(typeof(CmdId), _packet.CmdId)!;
try
{
diff --git a/HttpServer/Controllers/AccountController.cs b/HttpServer/Controllers/AccountController.cs
index ec28b64..f31c90f 100644
--- a/HttpServer/Controllers/AccountController.cs
+++ b/HttpServer/Controllers/AccountController.cs
@@ -58,7 +58,7 @@ namespace HttpServer.Controllers
{
StreamReader Reader = new(ctx.Request.Body);
ShieldVerifyBody Data = JsonConvert.DeserializeObject(Reader.ReadToEndAsync().Result);
- User.UserScheme? user = User.FromToken(Data.Token);
+ UserScheme? user = User.FromToken(Data.Token);
ShieldLoginResponse rsp = new()
{
@@ -118,7 +118,7 @@ namespace HttpServer.Controllers
StreamReader Reader = new(ctx.Request.Body);
ShieldLoginBody Data = JsonConvert.DeserializeObject(Reader.ReadToEndAsync().Result);
- User.UserScheme user = User.FromName(Data.Account);
+ UserScheme user = User.FromName(Data.Account);
ShieldLoginResponse rsp = new()
{
diff --git a/Program.cs b/Program.cs
index 9d06f89..9503bce 100644
--- a/Program.cs
+++ b/Program.cs
@@ -1,7 +1,8 @@
-using Common.Resources.Proto;
-using Common;
+using Common;
using System.Net.NetworkInformation;
using PemukulPaku.GameServer;
+using Common.Database;
+using PemukulPaku.GameServer.Game;
namespace PemukulPaku
{
@@ -9,19 +10,19 @@ namespace PemukulPaku
{
public static void Main()
{
+#if DEBUG
+ Global.config.VerboseLevel = VerboseLevel.Debug;
+#endif
Global.c.Log("Starting...");
Global.config.Gameserver.Host = NetworkInterface.GetAllNetworkInterfaces().Where(i => i.NetworkInterfaceType != NetworkInterfaceType.Loopback && i.OperationalStatus == OperationalStatus.Up).First().GetIPProperties().UnicastAddresses.Where(a => a.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork).First().Address.ToString();
- GetPlayerTokenRsp getPlayerTokenRsp = new()
- {
- Msg = "Hello!"
- };
-
- new Thread(HttpServer.Program.Main).Start();
PacketFactory.LoadPacketHandlers();
+ new Thread(HttpServer.Program.Main).Start();
_ = Server.GetInstance();
+ Player Player = new(User.FromName("test"));
+
Console.Read();
}
}