diff --git a/SCHALE.Common/Database/dbs.cs b/SCHALE.Common/Database/dbs.cs index c880230..0ce46d8 100644 --- a/SCHALE.Common/Database/dbs.cs +++ b/SCHALE.Common/Database/dbs.cs @@ -440,13 +440,7 @@ namespace SCHALE.Common.Database public class CafeProductionParcelInfo { - public ParcelKeyPair Key { get; set; } - // new ParcelKeyPair() - //{ - // Id = 1, - // Type = ParcelType.Currency - //}; - + public ParcelKeyPair Key { get; set; } = new() { Id = 1, Type = ParcelType.Currency }; public long Amount { get; set; } } @@ -491,7 +485,7 @@ namespace SCHALE.Common.Database } - public class CampaignMainStageSaveDB + public class CampaignMainStageSaveDB : ContentSaveDB { public ContentType ContentType { get; set; } public CampaignState CampaignState { get; set; } @@ -564,10 +558,13 @@ namespace SCHALE.Common.Database } - public class CharacterDB + public class CharacterDB : ParcelBase { - public ParcelType Type { get; set; } - public IEnumerable ParcelInfos { get; set; } + public override ParcelType Type { get => ParcelType.Character; } + + [JsonIgnore] + public override IEnumerable ParcelInfos { get; } + public long ServerId { get; set; } public long UniqueId { get; set; } public int StarGrade { get; set; } @@ -656,7 +653,7 @@ namespace SCHALE.Common.Database public long RepresentCharacterUniqueId { get; set; } public long RepresentCharacterCostumeId { get; set; } public long AttendanceCount { get; set; } - //public ClanSocialGrade ClanSocialGrade { get; set; } + public ClanSocialGrade ClanSocialGrade { get; set; } public DateTime JoinDate { get; set; } public DateTime SocialGradeUpdateTime { get; set; } public DateTime LastLoginDate { get; set; } @@ -683,7 +680,7 @@ namespace SCHALE.Common.Database public int Level { get; set; } public int SlotNumber { get; set; } public bool HasWeapon { get; set; } - //public SquadType SquadType { get; set; } + public SquadType SquadType { get; set; } public int WeaponStarGrade { get; set; } } @@ -832,13 +829,19 @@ namespace SCHALE.Common.Database } - public class ConsumableItemBaseDB : ParcelBase + public abstract class ConsumableItemBaseDB : ParcelBase { - public ParcelKeyPair Key { get; set; } + [JsonIgnore] + public abstract bool CanConsume { get; } + + [JsonIgnore] + public ParcelKeyPair Key { get; } + public long ServerId { get; set; } + public long UniqueId { get; set; } + public long StackCount { get; set; } - public bool CanConsume { get; set; } } @@ -892,10 +895,14 @@ namespace SCHALE.Common.Database public class CostumeDB : ParcelBase { - public ParcelType Type { get; set; } - public IEnumerable ParcelInfos { get; set; } - public long UniqueId { get; set; } + [JsonIgnore] + public override IEnumerable ParcelInfos { get; } + + public override ParcelType Type { get => ParcelType.Costume; } + public long BoundCharacterServerId { get; set; } + + public long UniqueId { get; set; } } @@ -1069,15 +1076,20 @@ namespace SCHALE.Common.Database public class EquipmentDB : ConsumableItemBaseDB { - public ParcelType Type { get; set; } - public IEnumerable ParcelInfos { get; set; } + public override ParcelType Type { get => ParcelType.Equipment; } + + [JsonIgnore] + public override IEnumerable ParcelInfos { get; } + + [JsonIgnore] + public override bool CanConsume { get => false; } + public int Level { get; set; } public long Exp { get; set; } public int Tier { get; set; } public long BoundCharacterServerId { get; set; } public bool IsNew { get; set; } public bool IsLocked { get; set; } - public bool CanConsume { get; set; } } @@ -1298,7 +1310,7 @@ namespace SCHALE.Common.Database public class EventRewardIncreaseDB { public EventTargetType EventTargetType { get; set; } - //public BasisPoint Multiplier { get; set; } + public BasisPoint Multiplier { get; set; } public DateTime BeginDate { get; set; } public DateTime EndDate { get; set; } } @@ -1355,15 +1367,20 @@ namespace SCHALE.Common.Database public class FurnitureDB : ConsumableItemBaseDB { - public ParcelType Type { get; set; } - public IEnumerable ParcelInfos { get; set; } + public override ParcelType Type { get => ParcelType.Furniture; } + + [JsonIgnore] + public override IEnumerable ParcelInfos { get; } + + [JsonIgnore] + public override bool CanConsume { get => false; } + public FurnitureLocation Location { get; set; } public long CafeDBId { get; set; } public float PositionX { get; set; } public float PositionY { get; set; } public float Rotation { get; set; } public long ItemDeploySequence { get; set; } - public bool CanConsume { get; set; } } @@ -1388,8 +1405,11 @@ namespace SCHALE.Common.Database public class GearDB : ParcelBase { - public ParcelType Type { get; set; } - public IEnumerable ParcelInfos { get; set; } + public override ParcelType Type { get => ParcelType.CharacterGear; } + + [JsonIgnore] + public override IEnumerable ParcelInfos { get; } + public long ServerId { get; set; } public long UniqueId { get; set; } public int Level { get; set; } @@ -1444,11 +1464,16 @@ namespace SCHALE.Common.Database public class ItemDB : ConsumableItemBaseDB { - public ParcelType Type { get; set; } - public IEnumerable ParcelInfos { get; set; } + public override ParcelType Type { get => ParcelType.Item; } + + [JsonIgnore] + public override IEnumerable ParcelInfos { get; } + + [JsonIgnore] + public override bool CanConsume { get; } + public bool IsNew { get; set; } public bool IsLocked { get; set; } - public bool CanConsume { get; set; } } @@ -1469,7 +1494,7 @@ namespace SCHALE.Common.Database { public long ServerId { get; set; } public long AccountServerId { get; set; } - //public MailType Type { get; set; } + public MailType Type { get; set; } public long UniqueId { get; set; } public string Sender { get; set; } public string Comment { get; set; } @@ -1483,13 +1508,15 @@ namespace SCHALE.Common.Database public class MemoryLobbyDB : ParcelBase { - public ParcelType Type { get; set; } - public IEnumerable ParcelInfos { get; set; } + public override ParcelType Type { get => ParcelType.MemoryLobby; } + + [JsonIgnore] + public override IEnumerable ParcelInfos { get; } + public long AccountServerId { get; set; } public long MemoryLobbyUniqueId { get; set; } } - public class MiniGameHistoryDB { public long EventContentId { get; set; } @@ -2023,7 +2050,7 @@ namespace SCHALE.Common.Database public class ShopInfoDB { public long EventContentId { get; set; } - //public ShopCategoryType Category { get; set; } + public ShopCategoryType Category { get; set; } public long? ManualRefreshCount { get; set; } public bool IsRefresh { get; set; } public DateTime? NextAutoRefreshDate { get; set; } @@ -2036,7 +2063,7 @@ namespace SCHALE.Common.Database { public long EventContentId { get; set; } public long ShopExcelId { get; set; } - //public ShopCategoryType Category { get; set; } + public ShopCategoryType Category { get; set; } public long DisplayOrder { get; set; } public long PurchaseCount { get; set; } public bool SoldOut { get; set; } @@ -2087,9 +2114,12 @@ namespace SCHALE.Common.Database public class StickerDB : ParcelBase, IEquatable { - public ParcelType Type { get; set; } + public override ParcelType Type { get => ParcelType.Sticker; } + + [JsonIgnore] + public override IEnumerable ParcelInfos { get; } + public long StickerUniqueId { get; set; } - public IEnumerable ParcelInfos { get; set; } public bool Equals(StickerDB? other) { @@ -2185,8 +2215,11 @@ namespace SCHALE.Common.Database public class WeaponDB : ParcelBase { - public ParcelType Type { get; set; } - public IEnumerable ParcelInfos { get; set; } + public override ParcelType Type { get => ParcelType.CharacterWeapon; } + + [JsonIgnore] + public override IEnumerable ParcelInfos { get; } + public long UniqueId { get; set; } public int Level { get; set; } public long Exp { get; set; } @@ -2199,7 +2232,7 @@ namespace SCHALE.Common.Database public class WeekDungeonSaveDB { public ContentType ContentType { get; set; } - //public WeekDungeonType WeekDungeonType { get; set; } + public WeekDungeonType WeekDungeonType { get; set; } public int Seed { get; set; } public int Sequence { get; set; } } @@ -2209,21 +2242,21 @@ namespace SCHALE.Common.Database { public long AccountServerId { get; set; } public long StageUniqueId { get; set; } - //public Dictionary StarGoalRecord { get; set; } + public Dictionary StarGoalRecord { get; set; } public bool IsCleardEver { get; set; } } public class WorldRaidBossDamageRatio { - //public ContentsChangeType ContentsChangeType { get; set; } - //public BasisPoint DamageRatio { get; set; } + public ContentsChangeType ContentsChangeType { get; set; } + public BasisPoint DamageRatio { get; set; } } public class WorldRaidBossGroup { - //public ContentsChangeType ContentsChangeType { get; set; } + public ContentsChangeType ContentsChangeType { get; set; } public long GroupId { get; set; } public DateTime BossSpawnTime { get; set; } public DateTime EliminateTime { get; set; } diff --git a/SCHALE.Common/FlatData/CurrencyTypes.cs b/SCHALE.Common/FlatData/CurrencyTypes.cs index d05936f..7c11916 100644 --- a/SCHALE.Common/FlatData/CurrencyTypes.cs +++ b/SCHALE.Common/FlatData/CurrencyTypes.cs @@ -34,7 +34,8 @@ public enum CurrencyTypes : int EliminateTicketA = 24, EliminateTicketB = 25, EliminateTicketC = 26, - Max = 27, + EliminateTicketD = 27, + Max = 28, }; diff --git a/SCHALE.Common/NetworkProtocol/protos.cs b/SCHALE.Common/NetworkProtocol/protos.cs index 4411e01..4190ed2 100644 --- a/SCHALE.Common/NetworkProtocol/protos.cs +++ b/SCHALE.Common/NetworkProtocol/protos.cs @@ -24,7 +24,7 @@ namespace SCHALE.Common.NetworkProtocol public bool UpdateRequired { get; set; } public string TTSCdnUri { get; set; } public AccountDB AccountDB { get; set; } - //public IEnumerable AttendanceBookRewards { get; set; } + public IEnumerable AttendanceBookRewards { get; set; } public IEnumerable AttendanceHistoryDBs { get; set; } public IEnumerable OpenConditions { get; set; } public IEnumerable RepurchasableMonthlyProductCountDBs { get; set; } @@ -987,7 +987,7 @@ namespace SCHALE.Common.NetworkProtocol return NetworkProtocol.Protocol.Attendance_Reward; } } - //public List AttendanceBookRewards { get; set; } + public List AttendanceBookRewards { get; set; } public List AttendanceHistoryDBs { get; set; } public ParcelResultDB ParcelResultDB { get; set; } } @@ -1084,7 +1084,7 @@ namespace SCHALE.Common.NetworkProtocol } } public long PurchaseOrderId { get; set; } - //public BillingTransactionEndType EndType { get; set; } = BillingTransactionEndType.Success; + public BillingTransactionEndType EndType { get; set; } = BillingTransactionEndType.Success; } @@ -1290,7 +1290,7 @@ namespace SCHALE.Common.NetworkProtocol public DateTime PurchaseResetDate { get; set; } public long PurchaseOrderId { get; set; } public string MXSeedKey { get; set; } - //public PurchaseServerTag PurchaseServerTag { get; set; } + public PurchaseServerTag PurchaseServerTag { get; set; } } @@ -2683,7 +2683,7 @@ namespace SCHALE.Common.NetworkProtocol } } public long MemberAccountId { get; set; } - //public ClanSocialGrade ConferingGrade { get; set; } + public ClanSocialGrade ConferingGrade { get; set; } } @@ -3025,7 +3025,7 @@ namespace SCHALE.Common.NetworkProtocol } } public string ClanNickName { get; set; } - //public ClanJoinOption ClanJoinOption { get; set; } + public ClanJoinOption ClanJoinOption { get; set; } } @@ -3181,7 +3181,7 @@ namespace SCHALE.Common.NetworkProtocol } public string ChangedClanName { get; set; } public string ChangedNotice { get; set; } - //public ClanJoinOption ClanJoinOption { get; set; } + public ClanJoinOption ClanJoinOption { get; set; } } @@ -3755,7 +3755,7 @@ namespace SCHALE.Common.NetworkProtocol public List ScenarioHistoryDBs { get; set; } public List ScenarioGroupHistoryDBs { get; set; } public List EmblemDBs { get; set; } - //public List AttendanceBookRewards { get; set; } + public List AttendanceBookRewards { get; set; } public List AttendanceHistoryDBs { get; set; } public List StickerDBs { get; set; } public List MemoryLobbyDBs { get; set; } @@ -4669,7 +4669,7 @@ namespace SCHALE.Common.NetworkProtocol public ConsumeRequestDB ConsumeRequestDB { get; set; } public long ConsumeGoldAmount { get; set; } public long SlotId { get; set; } - //public CraftNodeTier CraftNodeType { get; set; } + public CraftNodeTier CraftNodeType { get; set; } } @@ -4723,7 +4723,7 @@ namespace SCHALE.Common.NetworkProtocol return NetworkProtocol.Protocol.EliminateRaid_Lobby; } } - //public RaidSeasonType SeasonType { get; set; } + public RaidSeasonType SeasonType { get; set; } public RaidGiveUpDB RaidGiveUpDB { get; set; } public EliminateRaidLobbyInfoDB RaidLobbyInfoDB { get; set; } public AccountCurrencyDB AccountCurrencyDB { get; set; } @@ -5258,7 +5258,7 @@ namespace SCHALE.Common.NetworkProtocol return NetworkProtocol.Protocol.EliminateRaid_Login; } } - //public RaidSeasonType SeasonType { get; set; } + public RaidSeasonType SeasonType { get; set; } public bool CanReceiveRankingReward { get; set; } public List ReceiveLimitedRewardIds { get; set; } public Dictionary SweepPointByRaidUniqueId { get; set; } @@ -5690,7 +5690,7 @@ namespace SCHALE.Common.NetworkProtocol public long? Score { get; set; } public bool IsUpper { get; set; } public bool IsFirstRequest { get; set; } - //public RankingSearchType SearchType { get; set; } + public RankingSearchType SearchType { get; set; } } @@ -5867,7 +5867,7 @@ namespace SCHALE.Common.NetworkProtocol } } public long EventContentId { get; set; } - //public List CategoryList { get; set; } + public List CategoryList { get; set; } } @@ -6421,7 +6421,7 @@ namespace SCHALE.Common.NetworkProtocol } } public long EventContentId { get; set; } - //public ShopCategoryType ShopCategoryType { get; set; } + public ShopCategoryType ShopCategoryType { get; set; } } @@ -6628,7 +6628,7 @@ namespace SCHALE.Common.NetworkProtocol return NetworkProtocol.Protocol.MiniGame_MissionMultipleReward; } } - //public MissionCategory MissionCategory { get; set; } + public MissionCategory MissionCategory { get; set; } public long EventContentId { get; set; } } @@ -6896,7 +6896,7 @@ namespace SCHALE.Common.NetworkProtocol } } public long EventContentId { get; set; } - //public EventContentDiceRaceResultType DiceRaceResultType { get; set; } + public EventContentDiceRaceResultType DiceRaceResultType { get; set; } } @@ -6935,7 +6935,7 @@ namespace SCHALE.Common.NetworkProtocol { get { - return NetworkProtocol.Protocol.None; + return NetworkProtocol.Protocol.Event_RewardIncrease; } } } @@ -7956,7 +7956,7 @@ namespace SCHALE.Common.NetworkProtocol return NetworkProtocol.Protocol.Notification_EventContentReddotCheck; } } - //public Dictionary> Reddots { get; set; } + public Dictionary> Reddots { get; set; } public Dictionary> EventContentUnlockCGDBs { get; set; } } @@ -8050,7 +8050,7 @@ namespace SCHALE.Common.NetworkProtocol } } public string FriendCode { get; set; } - //public FriendSearchLevelOption LevelOption { get; set; } + public FriendSearchLevelOption LevelOption { get; set; } } @@ -8145,7 +8145,7 @@ namespace SCHALE.Common.NetworkProtocol return NetworkProtocol.Protocol.Raid_Login; } } - //public RaidSeasonType SeasonType { get; set; } + public RaidSeasonType SeasonType { get; set; } public bool CanReceiveRankingReward { get; set; } public long LastSettledRanking { get; set; } public int? LastSettledTier { get; set; } @@ -8445,7 +8445,7 @@ namespace SCHALE.Common.NetworkProtocol return NetworkProtocol.Protocol.OpenCondition_List; } } - //public List ConditionContents { get; set; } + public List ConditionContents { get; set; } } @@ -8710,7 +8710,7 @@ namespace SCHALE.Common.NetworkProtocol return NetworkProtocol.Protocol.Raid_Lobby; } } - //public RaidSeasonType SeasonType { get; set; } + public RaidSeasonType SeasonType { get; set; } public RaidGiveUpDB RaidGiveUpDB { get; set; } //public SingleRaidLobbyInfoDB RaidLobbyInfoDB { get; set; } public AccountCurrencyDB AccountCurrencyDB { get; set; } @@ -8928,7 +8928,7 @@ namespace SCHALE.Common.NetworkProtocol public virtual bool CanReceiveReward(DateTime serverTime) { - return false; + return true; } } @@ -9831,7 +9831,7 @@ namespace SCHALE.Common.NetworkProtocol return NetworkProtocol.Protocol.Mission_MultipleReward; } } - //public MissionCategory MissionCategory { get; set; } + public MissionCategory MissionCategory { get; set; } public long? GuideMissionSeasonId { get; set; } public long? EventContentId { get; set; } } @@ -10157,7 +10157,7 @@ namespace SCHALE.Common.NetworkProtocol return NetworkProtocol.Protocol.Shop_List; } } - //public List CategoryList { get; set; } + public List CategoryList { get; set; } } @@ -10174,7 +10174,7 @@ namespace SCHALE.Common.NetworkProtocol public long? Score { get; set; } public bool IsUpper { get; set; } public bool IsFirstRequest { get; set; } - //public RankingSearchType SearchType { get; set; } + public RankingSearchType SearchType { get; set; } } @@ -10659,7 +10659,7 @@ namespace SCHALE.Common.NetworkProtocol return NetworkProtocol.Protocol.None; } } - //public ShopCategoryType ShopCategoryType { get; set; } + public ShopCategoryType ShopCategoryType { get; set; } } diff --git a/SCHALE.Common/Parcel/parcel.cs b/SCHALE.Common/Parcel/parcel.cs index a66f0e5..43b587b 100644 --- a/SCHALE.Common/Parcel/parcel.cs +++ b/SCHALE.Common/Parcel/parcel.cs @@ -1,6 +1,8 @@  +using Newtonsoft.Json; using SCHALE.Common.Database; using SCHALE.Common.FlatData; +using System.Net.NetworkInformation; namespace SCHALE.Common.Parcel { @@ -68,10 +70,12 @@ namespace SCHALE.Common.Parcel } - public class ParcelBase + public abstract class ParcelBase { - public ParcelType Type { get; set; } - public IEnumerable ParcelInfos { get; set; } + public abstract ParcelType Type { get; } + + [JsonIgnore] + public abstract IEnumerable ParcelInfos { get; } } @@ -85,7 +89,7 @@ namespace SCHALE.Common.Parcel public bool HasCurrency { get; set; } public bool HasItem { get; set; } public IEnumerable ConsumableItemBaseDBs { get; set; } - //public ConsumeCondition ConsumeCondition { get; set; } + public ConsumeCondition ConsumeCondition { get; set; } } @@ -97,45 +101,79 @@ namespace SCHALE.Common.Parcel public ParcelChangeType ParcelChangeType { get; set; } } - public struct BasisPoint : IEquatable, IComparable + [Serializable] + public struct BasisPoint : IEquatable, IComparable { - public long RawValue { get; set; } - - public static readonly double DoubleEpsilon; - - public static readonly BasisPoint Epsilon; + [JsonIgnore] + public long RawValue + { + get + { + return this.rawValue; + } + } private static readonly long Multiplier; - public static readonly BasisPoint One; - - private static readonly double OneOver10_4; - - private long rawValue; + private static readonly double OneOver10_4 = 1.0 / 10000.0; public static readonly BasisPoint Zero; + public static readonly BasisPoint One; + + public static readonly BasisPoint Epsilon; + + public static readonly double DoubleEpsilon; + + [JsonProperty] + private long rawValue; + + public BasisPoint(long rawValue) + { + this.rawValue = rawValue; + } + public bool Equals(BasisPoint other) { - throw new NotImplementedException(); + return this.rawValue == other.rawValue; } public int CompareTo(BasisPoint other) { - throw new NotImplementedException(); + return rawValue.CompareTo(other.rawValue); + } + + public static long operator *(long value, BasisPoint other) + { + return MultiplyLong(value, other); + } + + public static long MultiplyLong(long value, BasisPoint other) + { + double result = OneOver10_4 * ((double)other.rawValue * value); + + if (double.IsInfinity(result)) + return long.MaxValue; + + return (long)result; } } - public class ParcelInfo : IEquatable { - public ParcelKeyPair Key { get; set; } - public long Amount { get; set; } + public ParcelKeyPair Key { get; set; } + public BasisPoint Multiplier { get; set; } - public long MultipliedAmount { get; set; } + public long MultipliedAmount + { + get + { + return Amount * Multiplier; + } + } public BasisPoint Probability { get; set; } @@ -145,10 +183,23 @@ namespace SCHALE.Common.Parcel } } - public class ParcelKeyPair + public class ParcelKeyPair : IEquatable, IComparable { + public static readonly ParcelKeyPair Empty; + public ParcelType Type { get; set; } + public long Id { get; set; } + + public int CompareTo(ParcelKeyPair? other) + { + return Id.CompareTo(other.Id); + } + + public bool Equals(ParcelKeyPair? other) + { + return Id.Equals(other.Id); + } } diff --git a/SCHALE.GameServer/Controllers/Api/GatewayController.cs b/SCHALE.GameServer/Controllers/Api/GatewayController.cs index a396595..b78d879 100644 --- a/SCHALE.GameServer/Controllers/Api/GatewayController.cs +++ b/SCHALE.GameServer/Controllers/Api/GatewayController.cs @@ -7,6 +7,7 @@ using System.Text; using System.Text.Json; using System.Text.Json.Nodes; using Serilog; +using System.Text.Json.Serialization; namespace SCHALE.GameServer.Controllers.Api { @@ -83,7 +84,11 @@ namespace SCHALE.GameServer.Controllers.Api return Results.Json(new { - packet = JsonSerializer.Serialize(rsp), + packet = JsonSerializer.Serialize(rsp, new JsonSerializerOptions() // ignore null or fields not set, if this breaks anything, remove it, idk if it does but it makes the pcap logs look more readable + { + DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingDefault, + }), + protocol = ((BasePacket)rsp).Protocol.ToString() }); diff --git a/SCHALE.GameServer/Controllers/Api/ProtocolHandlers/Account.cs b/SCHALE.GameServer/Controllers/Api/ProtocolHandlers/Account.cs index 1007bbe..07ef737 100644 --- a/SCHALE.GameServer/Controllers/Api/ProtocolHandlers/Account.cs +++ b/SCHALE.GameServer/Controllers/Api/ProtocolHandlers/Account.cs @@ -2,6 +2,8 @@ using SCHALE.Common.NetworkProtocol; using SCHALE.GameServer.Services; using MongoDB.Driver.Linq; +using SCHALE.Common.FlatData; +using Serilog; namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers { @@ -58,6 +60,7 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers { CurrentVersion = req.Version, AccountDB = account, + MissionProgressDBs = [.. context.MissionProgresses.Where(x => x.AccountServerId == account.ServerId)] }; @@ -77,124 +80,8 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers string[] uidToken = req.SessionKey.MxToken.Split(':'); var account = new AccountDB(long.Parse(uidToken[0])); + context.Accounts.Add(account); - context.MissionProgresses.AddRange([ - new MissionProgressDB - { - AccountServerId = account.ServerId, - MissionUniqueId = 1501, - Complete = true, - StartTime = DateTime.Parse("2024-04-26T20:46:44") - }, - new MissionProgressDB - { - AccountServerId = account.ServerId, - MissionUniqueId = 1700, - StartTime = DateTime.Parse("2024-04-26T20:46:44"), - ProgressParameters = new Dictionary { { 0, 1 } } - }, - new MissionProgressDB - { - AccountServerId = account.ServerId, - MissionUniqueId = 1500, - Complete = true, - StartTime = DateTime.Parse("2024-04-26T20:46:44") - }, - new MissionProgressDB - { - AccountServerId = account.ServerId, - MissionUniqueId = 2200, - StartTime = DateTime.Parse("2024-04-26T20:46:44"), - ProgressParameters = new Dictionary { { 0, 1 }, { 1, 5 } } - }, - new MissionProgressDB - { - AccountServerId = account.ServerId, - MissionUniqueId = 300000, - StartTime = DateTime.Parse("2024-04-26T20:46:44"), - ProgressParameters = new Dictionary { { 0, 1 } } - }, - new MissionProgressDB - { - AccountServerId = account.ServerId, - MissionUniqueId = 1000210, - Complete = true, - StartTime = DateTime.Parse("2024-04-26T20:46:44"), - ProgressParameters = new Dictionary { { 0, 1 } } - }, - new MissionProgressDB - { - AccountServerId = account.ServerId, - MissionUniqueId = 1000220, - Complete = true, - StartTime = DateTime.Parse("2024-04-26T20:46:44"), - ProgressParameters = new Dictionary { { 0, 1 } } - }, - new MissionProgressDB - { - AccountServerId = account.ServerId, - MissionUniqueId = 1000230, - Complete = true, - StartTime = DateTime.Parse("2024-04-26T20:46:44"), - ProgressParameters = new Dictionary { { 0, 1 } } - }, - new MissionProgressDB - { - AccountServerId = account.ServerId, - MissionUniqueId = 1000240, - Complete = true, - StartTime = DateTime.Parse("2024-04-26T20:46:44"), - ProgressParameters = new Dictionary { { 0, 1 } } - }, - new MissionProgressDB - { - AccountServerId = account.ServerId, - MissionUniqueId = 1000250, - Complete = true, - StartTime = DateTime.Parse("2024-04-26T20:46:44"), - ProgressParameters = new Dictionary { { 0, 1 } } - }, - new MissionProgressDB - { - AccountServerId = account.ServerId, - MissionUniqueId = 1000260, - Complete = true, - StartTime = DateTime.Parse("2024-04-26T20:46:44"), - ProgressParameters = new Dictionary { { 0, 1 } } - }, - new MissionProgressDB - { - AccountServerId = account.ServerId, - MissionUniqueId = 1000270, - Complete = true, - StartTime = DateTime.Parse("2024-04-26T20:46:44"), - ProgressParameters = new Dictionary { { 0, 1 } } - }, - new MissionProgressDB - { - AccountServerId = account.ServerId, - MissionUniqueId = 1001327, - Complete = true, - StartTime = DateTime.Parse("2024-04-26T20:46:44"), - ProgressParameters = new Dictionary { { 0, 1 } } - }, - new MissionProgressDB - { - AccountServerId = account.ServerId, - MissionUniqueId = 1001357, - Complete = true, - StartTime = DateTime.Parse("2024-04-26T20:46:44"), - ProgressParameters = new Dictionary { { 0, 1 } } - }, - new MissionProgressDB - { - AccountServerId = account.ServerId, - MissionUniqueId = 1001377, - Complete = true, - StartTime = DateTime.Parse("2024-04-26T20:46:44"), - ProgressParameters = new Dictionary { { 0, 1 } } - } - ]); context.SaveChanges(); return new AccountCreateResponse() @@ -223,17 +110,196 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers { return new AccountLoginSyncResponse() { + AccountCurrencySyncResponse = new AccountCurrencySyncResponse() + { + AccountCurrencyDB = new AccountCurrencyDB + { + AccountLevel = 1, + AcademyLocationRankSum = 1, + CurrencyDict = new Dictionary + { + { CurrencyTypes.Gem, long.MaxValue }, // gacha currency 600 + { CurrencyTypes.GemPaid, 0 }, + { CurrencyTypes.GemBonus, 89473598435 }, // default blue gem? + { CurrencyTypes.Gold, long.MaxValue }, // credit 10,000 + { CurrencyTypes.ActionPoint, long.MaxValue }, // energy 24 + { CurrencyTypes.AcademyTicket, 3 }, + { CurrencyTypes.ArenaTicket, 5 }, + { CurrencyTypes.RaidTicket, 3 }, + { CurrencyTypes.WeekDungeonChaserATicket, 0 }, + { CurrencyTypes.WeekDungeonChaserBTicket, 0 }, + { CurrencyTypes.WeekDungeonChaserCTicket, 0 }, + { CurrencyTypes.SchoolDungeonATicket, 0 }, + { CurrencyTypes.SchoolDungeonBTicket, 0 }, + { CurrencyTypes.SchoolDungeonCTicket, 0 }, + { CurrencyTypes.TimeAttackDungeonTicket, 3 }, + { CurrencyTypes.MasterCoin, 0 }, + { CurrencyTypes.WorldRaidTicketA, 40 }, + { CurrencyTypes.WorldRaidTicketB, 40 }, + { CurrencyTypes.WorldRaidTicketC, 40 }, + { CurrencyTypes.ChaserTotalTicket, 6 }, + { CurrencyTypes.SchoolDungeonTotalTicket, 6 }, + { CurrencyTypes.EliminateTicketA, 1 }, + { CurrencyTypes.EliminateTicketB, 1 }, + { CurrencyTypes.EliminateTicketC, 1 }, + { CurrencyTypes.EliminateTicketD, 1 } + }, + UpdateTimeDict = new Dictionary + { + { CurrencyTypes.ActionPoint, DateTime.Parse("2024-04-26T19:29:12") }, + { CurrencyTypes.AcademyTicket, DateTime.Parse("2024-04-26T19:29:12") }, + { CurrencyTypes.ArenaTicket, DateTime.Parse("2024-04-26T19:29:12") }, + { CurrencyTypes.RaidTicket, DateTime.Parse("2024-04-26T19:29:12") }, + { CurrencyTypes.WeekDungeonChaserATicket, DateTime.Parse("2024-04-26T19:29:12") }, + { CurrencyTypes.WeekDungeonChaserBTicket, DateTime.Parse("2024-04-26T19:29:12") }, + { CurrencyTypes.WeekDungeonChaserCTicket, DateTime.Parse("2024-04-26T19:29:12") }, + { CurrencyTypes.SchoolDungeonATicket, DateTime.Parse("2024-04-26T19:29:12") }, + { CurrencyTypes.SchoolDungeonBTicket, DateTime.Parse("2024-04-26T19:29:12") }, + { CurrencyTypes.SchoolDungeonCTicket, DateTime.Parse("2024-04-26T19:29:12") }, + { CurrencyTypes.TimeAttackDungeonTicket, DateTime.Parse("2024-04-26T19:29:12") }, + { CurrencyTypes.MasterCoin, DateTime.Parse("2024-04-26T19:29:12") }, + { CurrencyTypes.WorldRaidTicketA, DateTime.Parse("2024-04-26T19:29:12") }, + { CurrencyTypes.WorldRaidTicketB, DateTime.Parse("2024-04-26T19:29:12") }, + { CurrencyTypes.WorldRaidTicketC, DateTime.Parse("2024-04-26T19:29:12") }, + { CurrencyTypes.ChaserTotalTicket, DateTime.Parse("2024-04-26T19:29:12") }, + { CurrencyTypes.SchoolDungeonTotalTicket, DateTime.Parse("2024-04-26T19:29:12") }, + { CurrencyTypes.EliminateTicketA, DateTime.Parse("2024-04-26T19:29:12") }, + { CurrencyTypes.EliminateTicketB, DateTime.Parse("2024-04-26T19:29:12") }, + { CurrencyTypes.EliminateTicketC, DateTime.Parse("2024-04-26T19:29:12") }, + { CurrencyTypes.EliminateTicketD, DateTime.Parse("2024-04-26T19:29:12") } + } + } + }, + CharacterListResponse = new CharacterListResponse() + { + CharacterDBs = new List + { + new CharacterDB + { + ServerId = 1043998219, + UniqueId = 13003, + StarGrade = 2, + Level = 1, + FavorRank = 1, + PublicSkillLevel = 1, + ExSkillLevel = 1, + PassiveSkillLevel = 1, + ExtraPassiveSkillLevel = 1, + LeaderSkillLevel = 1, + IsNew = true, + IsLocked = true, + EquipmentServerIds = new List { 0, 0, 0 }, + PotentialStats = new Dictionary { { 1, 0 }, { 2, 0 }, { 3, 0 } } + }, + new CharacterDB + { + ServerId = 1043998217, + UniqueId = 13010, + StarGrade = 2, + Level = 1, + FavorRank = 1, + PublicSkillLevel = 1, + ExSkillLevel = 1, + PassiveSkillLevel = 1, + ExtraPassiveSkillLevel = 1, + LeaderSkillLevel = 1, + IsNew = true, + IsLocked = true, + EquipmentServerIds = new List { 0, 0, 0 }, + PotentialStats = new Dictionary { { 1, 0 }, { 2, 0 }, { 3, 0 } } + }, + new CharacterDB + { + ServerId = 1043998218, + UniqueId = 16003, + StarGrade = 1, + Level = 1, + FavorRank = 1, + PublicSkillLevel = 1, + ExSkillLevel = 1, + PassiveSkillLevel = 1, + ExtraPassiveSkillLevel = 1, + LeaderSkillLevel = 1, + IsNew = true, + IsLocked = true, + EquipmentServerIds = new List { 0, 0, 0 }, + PotentialStats = new Dictionary { { 1, 0 }, { 2, 0 }, { 3, 0 } } + }, + new CharacterDB + { + ServerId = 1043998220, + UniqueId = 26000, + StarGrade = 1, + Level = 1, + FavorRank = 1, + PublicSkillLevel = 1, + ExSkillLevel = 1, + PassiveSkillLevel = 1, + ExtraPassiveSkillLevel = 1, + LeaderSkillLevel = 1, + IsNew = true, + IsLocked = true, + EquipmentServerIds = new List { 0, 0, 0 }, + PotentialStats = new Dictionary { { 1, 0 }, { 2, 0 }, { 3, 0 } } + } + }, + TSSCharacterDBs = [], + WeaponDBs = [], + CostumeDBs = [], + }, + EchelonListResponse = new EchelonListResponse() + { + EchelonDBs = [ + new EchelonDB() + { + AccountServerId = req.AccountId, + EchelonType = EchelonType.Adventure, + EchelonNumber = 1, + LeaderServerId = 123, + MainSlotServerIds = [1043998217, 1043998218, 1043998219, 0 ], + SupportSlotServerIds = [ 444, 0], + SkillCardMulliganCharacterIds = [] + } + ] + }, + EventContentPermanentListResponse = new EventContentPermanentListResponse() + { + PermanentDBs = [ + new() { EventContentId = 900801 }, + new() { EventContentId = 900802 }, + new() { EventContentId = 900803 }, + new() { EventContentId = 900804 }, + new() { EventContentId = 900805 }, + new() { EventContentId = 900806 }, + new() { EventContentId = 900808 }, + new() { EventContentId = 900809 }, + new() { EventContentId = 900810 }, + new() { EventContentId = 900812 }, + new() { EventContentId = 900813 }, + new() { EventContentId = 900816 }, + new() { EventContentId = 900701 }, + ], + }, + FriendCode = "SCHALEPS", + + ServerNotification = ServerNotificationFlag.HasUnreadMail, + SessionKey = new() + { + AccountServerId = req.AccountId, + MxToken = req.SessionKey.MxToken, + }, }; } [ProtocolHandler(Protocol.Account_GetTutorial)] public ResponsePacket GetTutorialHandler(AccountGetTutorialRequest req) { - return new AccountGetTutorialResponse() { - +#if DEBUG + TutorialIds = [1, 2] +#endif }; } @@ -248,19 +314,8 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers } // others handlers, move to different handler group later - [ProtocolHandler(Protocol.Item_List)] - public ResponsePacket Item_ListRequestHandler(ItemListRequest req) - { - return new ItemListResponse() - { - ItemDBs = [], - ExpiryItemDBs = [], - ServerNotification = ServerNotificationFlag.HasUnreadMail, - }; - } - [ProtocolHandler(Protocol.NetworkTime_Sync)] - public ResponsePacket NetworkTime_Sync(NetworkTimeSyncRequest req) + public ResponsePacket NetworkTime_SyncHandler(NetworkTimeSyncRequest req) { long received_tick = DateTimeOffset.Now.Ticks; @@ -272,7 +327,7 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers } [ProtocolHandler(Protocol.ContentSave_Get)] - public ResponsePacket ContentSave_Get(ContentSaveGetRequest req) + public ResponsePacket ContentSave_GetHandler(ContentSaveGetRequest req) { return new ContentSaveGetResponse() { @@ -280,19 +335,6 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers }; } - [ProtocolHandler(Protocol.Shop_BeforehandGachaGet)] - public ResponsePacket Shop_BeforehandGachaGet(ShopBeforehandGachaGetRequest req) - { - return new ShopBeforehandGachaGetResponse() - { - SessionKey = new() - { - MxToken = req.SessionKey.MxToken, - AccountServerId = req.SessionKey.AccountServerId, - } - }; - } - [ProtocolHandler(Protocol.Toast_List)] public ResponsePacket ToastListHandler(ToastListRequest req) { @@ -303,11 +345,51 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers }; } - [ProtocolHandler(Protocol.EventContent_CollectionList)] - public ResponsePacket EventContent_CollectionListHandler(EventContentCollectionListRequest req) + [ProtocolHandler(Protocol.ContentLog_UIOpenStatistics)] + public ResponsePacket ContentLog_UIOpenStatisticsHandler(ContentLogUIOpenStatisticsRequest req) { - return new EventContentCollectionListResponse() + return new ContentLogUIOpenStatisticsResponse() + { + + }; + } + + [ProtocolHandler(Protocol.Event_RewardIncrease)] + public ResponsePacket Event_RewardIncreaseHandler(EventRewardIncreaseRequest req) + { + + return new EventRewardIncreaseResponse() + { + + }; + } + + [ProtocolHandler(Protocol.OpenCondition_EventList)] + public ResponsePacket OpenCondition_EventListHandler(OpenConditionEventListRequest req) + { + + return new OpenConditionEventListResponse() + { + + }; + } + + [ProtocolHandler(Protocol.Notification_EventContentReddotCheck)] + public ResponsePacket Notification_EventContentReddotCheckHandler(NotificationEventContentReddotRequest req) + { + + return new NotificationEventContentReddotResponse() + { + + }; + } + + [ProtocolHandler(Protocol.Billing_PurchaseListByYostar)] + public ResponsePacket Billing_PurchaseListByYostarHandler(BillingPurchaseListByYostarRequest req) + { + + return new BillingPurchaseListByYostarResponse() { }; diff --git a/SCHALE.GameServer/Controllers/Api/ProtocolHandlers/Campaign.cs b/SCHALE.GameServer/Controllers/Api/ProtocolHandlers/Campaign.cs new file mode 100644 index 0000000..31bd905 --- /dev/null +++ b/SCHALE.GameServer/Controllers/Api/ProtocolHandlers/Campaign.cs @@ -0,0 +1,49 @@ +using SCHALE.Common.Database; +using SCHALE.Common.FlatData; +using SCHALE.Common.NetworkProtocol; +using SCHALE.GameServer.Services; + +namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers +{ + public class Campaign : ProtocolHandlerBase + { + private ISessionKeyService sessionKeyService; + private SCHALEContext context; + + public Campaign(IProtocolHandlerFactory protocolHandlerFactory, ISessionKeyService _sessionKeyService, SCHALEContext _context) : base(protocolHandlerFactory) + { + sessionKeyService = _sessionKeyService; + context = _context; + } + + [ProtocolHandler(Protocol.Campaign_List)] + public ResponsePacket ListHandler(CampaignListRequest req) + { + + return new CampaignListResponse() + { + + }; + } + + [ProtocolHandler(Protocol.Campaign_EnterMainStage)] + public ResponsePacket EnterMainStageHandler(CampaignEnterMainStageRequest req) + { + return new CampaignEnterMainStageResponse() + { + SaveDataDB = new CampaignMainStageSaveDB() + { + ContentType = ContentType.CampaignMainStage, + LastEnemyEntityId = 10010, + + ActivatedHexaEventsAndConditions = new() { { 0, [0] } }, + HexaEventDelayedExecutions = [], + CreateTime = DateTime.Parse("2024-04-22T18:33:21"), + StageUniqueId = 1011101, + StageEntranceFee = [], + EnemyKillCountByUniqueId = [] + } + }; + } + } +} diff --git a/SCHALE.GameServer/Controllers/Api/ProtocolHandlers/Clan.cs b/SCHALE.GameServer/Controllers/Api/ProtocolHandlers/Clan.cs new file mode 100644 index 0000000..9a17c8c --- /dev/null +++ b/SCHALE.GameServer/Controllers/Api/ProtocolHandlers/Clan.cs @@ -0,0 +1,19 @@ +using SCHALE.Common.NetworkProtocol; + +namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers +{ + public class Clan : ProtocolHandlerBase + { + public Clan(IProtocolHandlerFactory protocolHandlerFactory) : base(protocolHandlerFactory) { } + + [ProtocolHandler(Protocol.Clan_Check)] + public ResponsePacket CheckHandler(ClanCheckRequest req) + { + + return new ClanCheckResponse() + { + + }; + } + } +} diff --git a/SCHALE.GameServer/Controllers/Api/ProtocolHandlers/EventContent.cs b/SCHALE.GameServer/Controllers/Api/ProtocolHandlers/EventContent.cs new file mode 100644 index 0000000..bfb5a7d --- /dev/null +++ b/SCHALE.GameServer/Controllers/Api/ProtocolHandlers/EventContent.cs @@ -0,0 +1,28 @@ +using SCHALE.Common.Database; +using SCHALE.Common.NetworkProtocol; +using SCHALE.GameServer.Services; + +namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers +{ + public class EventContent : ProtocolHandlerBase + { + private ISessionKeyService sessionKeyService; + private SCHALEContext context; + + public EventContent(IProtocolHandlerFactory protocolHandlerFactory, ISessionKeyService _sessionKeyService, SCHALEContext _context) : base(protocolHandlerFactory) + { + sessionKeyService = _sessionKeyService; + context = _context; + } + + [ProtocolHandler(Protocol.EventContent_CollectionList)] + public ResponsePacket CollectionListHandler(EventContentCollectionListRequest req) + { + + return new EventContentCollectionListResponse() + { + + }; + } + } +} diff --git a/SCHALE.GameServer/Controllers/Api/ProtocolHandlers/Friend.cs b/SCHALE.GameServer/Controllers/Api/ProtocolHandlers/Friend.cs new file mode 100644 index 0000000..0412366 --- /dev/null +++ b/SCHALE.GameServer/Controllers/Api/ProtocolHandlers/Friend.cs @@ -0,0 +1,19 @@ +using SCHALE.Common.NetworkProtocol; + +namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers +{ + public class Friend : ProtocolHandlerBase + { + public Friend(IProtocolHandlerFactory protocolHandlerFactory) : base(protocolHandlerFactory) { } + + [ProtocolHandler(Protocol.Friend_Check)] + public ResponsePacket CheckHandler(FriendCheckRequest req) + { + + return new FriendCheckResponse() + { + + }; + } + } +} diff --git a/SCHALE.GameServer/Controllers/Api/ProtocolHandlers/Item.cs b/SCHALE.GameServer/Controllers/Api/ProtocolHandlers/Item.cs new file mode 100644 index 0000000..fb590be --- /dev/null +++ b/SCHALE.GameServer/Controllers/Api/ProtocolHandlers/Item.cs @@ -0,0 +1,29 @@ +using SCHALE.Common.Database; +using SCHALE.Common.NetworkProtocol; +using SCHALE.GameServer.Services; + +namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers +{ + public class Item : ProtocolHandlerBase + { + private ISessionKeyService sessionKeyService; + private SCHALEContext context; + + public Item(IProtocolHandlerFactory protocolHandlerFactory, ISessionKeyService _sessionKeyService, SCHALEContext _context) : base(protocolHandlerFactory) + { + sessionKeyService = _sessionKeyService; + context = _context; + } + + [ProtocolHandler(Protocol.Item_List)] + public ResponsePacket ListHandler(ItemListRequest req) + { + return new ItemListResponse() + { + ItemDBs = [], + ExpiryItemDBs = [], + ServerNotification = ServerNotificationFlag.HasUnreadMail, + }; + } + } +} diff --git a/SCHALE.GameServer/Controllers/Api/ProtocolHandlers/Mail.cs b/SCHALE.GameServer/Controllers/Api/ProtocolHandlers/Mail.cs new file mode 100644 index 0000000..4b6b976 --- /dev/null +++ b/SCHALE.GameServer/Controllers/Api/ProtocolHandlers/Mail.cs @@ -0,0 +1,21 @@ +using SCHALE.Common.NetworkProtocol; + +namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers +{ + public class Mail : ProtocolHandlerBase + { + public Mail(IProtocolHandlerFactory protocolHandlerFactory) : base(protocolHandlerFactory) { } + + [ProtocolHandler(Protocol.Mail_Check)] + public ResponsePacket CheckHandler(MailCheckRequest req) + { + + return new MailCheckResponse() + { + + }; + } + + + } +} diff --git a/SCHALE.GameServer/Controllers/Api/ProtocolHandlers/ProtocolHandlerFactory.cs b/SCHALE.GameServer/Controllers/Api/ProtocolHandlers/ProtocolHandlerFactory.cs index 1c897b0..68d1532 100644 --- a/SCHALE.GameServer/Controllers/Api/ProtocolHandlers/ProtocolHandlerFactory.cs +++ b/SCHALE.GameServer/Controllers/Api/ProtocolHandlers/ProtocolHandlerFactory.cs @@ -119,5 +119,10 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers { services.AddHostedService(); } + + public static void AddProtocolHandlerGroupByType(this IServiceCollection services, Type type) + { + services.AddTransient(typeof(IHostedService), type); + } } } diff --git a/SCHALE.GameServer/Controllers/Api/ProtocolHandlers/Shop.cs b/SCHALE.GameServer/Controllers/Api/ProtocolHandlers/Shop.cs new file mode 100644 index 0000000..5cc8d84 --- /dev/null +++ b/SCHALE.GameServer/Controllers/Api/ProtocolHandlers/Shop.cs @@ -0,0 +1,97 @@ +using SCHALE.Common.Database; +using SCHALE.Common.NetworkProtocol; +using SCHALE.GameServer.Services; +using Serilog; + +namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers +{ + public class Shop : ProtocolHandlerBase + { + private ISessionKeyService sessionKeyService; + private SCHALEContext context; + + public List SavedGachaResults { get; set; } // temp storage until gacha management + + public Shop(IProtocolHandlerFactory protocolHandlerFactory, ISessionKeyService _sessionKeyService, SCHALEContext _context) : base(protocolHandlerFactory) + { + sessionKeyService = _sessionKeyService; + context = _context; + } + + [ProtocolHandler(Protocol.Shop_BeforehandGachaGet)] + public ResponsePacket BeforehandGachaGetHandler(ShopBeforehandGachaGetRequest req) + { + return new ShopBeforehandGachaGetResponse() + { + SessionKey = new() + { + MxToken = req.SessionKey.MxToken, + AccountServerId = req.SessionKey.AccountServerId, + } + }; + } + + [ProtocolHandler(Protocol.Shop_BeforehandGachaRun)] + public ResponsePacket BeforehandGachaRunHandler(ShopBeforehandGachaRunRequest req) + { + // character ids here, just some limited 3 stars for now for fun + SavedGachaResults = [10059, 20007, 10033, 10074, 10045, 10053, 10054, 10021, 20022, 10057]; + + return new ShopBeforehandGachaRunResponse() + { + SelectGachaSnapshot = new BeforehandGachaSnapshotDB() + { + ShopUniqueId = 3, + GoodsId = 1, + LastResults = SavedGachaResults + } + }; + } + + [ProtocolHandler(Protocol.Shop_BeforehandGachaSave)] + public ResponsePacket BeforehandGachaPickHandler(ShopBeforehandGachaSaveRequest req) + { + return new ShopBeforehandGachaSaveResponse() + { + + }; + } + + [ProtocolHandler(Protocol.Shop_BeforehandGachaPick)] + public ResponsePacket BeforehandGachaPickHandler(ShopBeforehandGachaPickRequest req) + { + var account = sessionKeyService.GetAccount(req.SessionKey); + var GachaResults = new List(); + + foreach (var charId in SavedGachaResults) + { + GachaResults.Add(new GachaResult(charId) // hardcode until table + { + Character = new() + { + ServerId = account.ServerId, + UniqueId = charId, + StarGrade = 3, + Level = 1, + FavorRank = 1, + PublicSkillLevel = 1, + ExSkillLevel = 1, + PassiveSkillLevel = 1, + ExtraPassiveSkillLevel = 1, + LeaderSkillLevel = 1, + IsNew = true, + IsLocked = true + } + }); + } + + + return new ShopBeforehandGachaPickResponse() + { + GachaResults = GachaResults + }; + } + + + } +} diff --git a/SCHALE.GameServer/GameServer.cs b/SCHALE.GameServer/GameServer.cs index 9516061..e5ac829 100644 --- a/SCHALE.GameServer/GameServer.cs +++ b/SCHALE.GameServer/GameServer.cs @@ -48,12 +48,12 @@ namespace SCHALE.GameServer builder.Services.AddMongoDBProvider(config.GetConnectionString("MongoDB") ?? throw new ArgumentNullException("ConnectionStrings/MongoDB in appsettings is missing")); builder.Services.AddProtocolHandlerFactory(); builder.Services.AddMemorySessionKeyService(); - builder.Services.AddProtocolHandlerGroup(); - builder.Services.AddProtocolHandlerGroup(); - builder.Services.AddProtocolHandlerGroup(); - builder.Services.AddProtocolHandlerGroup(); - builder.Services.AddProtocolHandlerGroup(); - builder.Services.AddProtocolHandlerGroup(); + + // Add all Handler Groups + var handlerGroups = Assembly.GetExecutingAssembly().GetTypes().Where(t => t.IsSubclassOf(typeof(ProtocolHandlerBase))); + + foreach (var handlerGroup in handlerGroups) + builder.Services.AddProtocolHandlerGroupByType(handlerGroup); var app = builder.Build();