From 793e55f9de7081366bb4b6583ad0080644b8b5c9 Mon Sep 17 00:00:00 2001 From: User958568 Date: Sun, 14 Sep 2025 18:50:49 +0300 Subject: [PATCH] soda! (#53) * Add files via upload * Add files via upload * Add files via upload --- EpinelPS/Data/GameData.cs | 13 +++ EpinelPS/Data/JsonStaticData.cs | 85 +++++++++++++++++++ .../Minigame/PlaySoda/GetChallengeEnter.cs | 25 ++++++ .../PlaySoda/GetChallengeFinishCatchCoin.cs | 39 +++++++++ .../PlaySoda/GetChallengeFinishClimbing.cs | 39 +++++++++ .../PlaySoda/GetChallengeFinishRunning.cs | 39 +++++++++ .../PlaySoda/GetChallengeFinishSmash.cs | 39 +++++++++ .../PlaySoda/GetChallengeFinishStackUp.cs | 39 +++++++++ .../Minigame/PlaySoda/GetChallengeInfo.cs | 50 +++++++---- .../PlaySoda/GetChallengeObtainPointReward.cs | 50 +++++++++++ .../Minigame/PlaySoda/GetEnterlog.cs | 15 ++++ EpinelPS/Models/UserModel.cs | 1 + 12 files changed, 417 insertions(+), 17 deletions(-) create mode 100644 EpinelPS/LobbyServer/Minigame/PlaySoda/GetChallengeEnter.cs create mode 100644 EpinelPS/LobbyServer/Minigame/PlaySoda/GetChallengeFinishCatchCoin.cs create mode 100644 EpinelPS/LobbyServer/Minigame/PlaySoda/GetChallengeFinishClimbing.cs create mode 100644 EpinelPS/LobbyServer/Minigame/PlaySoda/GetChallengeFinishRunning.cs create mode 100644 EpinelPS/LobbyServer/Minigame/PlaySoda/GetChallengeFinishSmash.cs create mode 100644 EpinelPS/LobbyServer/Minigame/PlaySoda/GetChallengeFinishStackUp.cs create mode 100644 EpinelPS/LobbyServer/Minigame/PlaySoda/GetChallengeObtainPointReward.cs create mode 100644 EpinelPS/LobbyServer/Minigame/PlaySoda/GetEnterlog.cs diff --git a/EpinelPS/Data/GameData.cs b/EpinelPS/Data/GameData.cs index 66935c1..0cd6ced 100644 --- a/EpinelPS/Data/GameData.cs +++ b/EpinelPS/Data/GameData.cs @@ -229,6 +229,19 @@ namespace EpinelPS.Data [LoadRecord("FavoriteItemQuestStageTable.json", "id")] public readonly Dictionary FavoriteItemQuestStageTable = []; + // Tables related to PlaySoda Arcade's event. + + [LoadRecord("EventPlaySodaManagerTable.json", "id")] + public readonly Dictionary EventPlaySodaManagerTable = []; + + [LoadRecord("EventPlaySodaStoryModeTable.json", "id")] + public readonly Dictionary EventPlaySodaStoryModeTable = []; + + [LoadRecord("EventPlaySodaChallengeModeTable.json", "id")] + public readonly Dictionary EventPlaySodaChallengeModeTable = []; + + [LoadRecord("EventPlaySodaPointRewardTable.json", "id")] + public readonly Dictionary EventPlaySodaPointRewardTable = []; static async Task BuildAsync() { diff --git a/EpinelPS/Data/JsonStaticData.cs b/EpinelPS/Data/JsonStaticData.cs index b0fa471..0c55a93 100644 --- a/EpinelPS/Data/JsonStaticData.cs +++ b/EpinelPS/Data/JsonStaticData.cs @@ -1090,4 +1090,89 @@ namespace EpinelPS.Data public int spawn_condition_favoriteitem_quest_stage_id; public int enter_condition_favoriteitem_quest_stage_id; } + + [MemoryPackable] + public partial class EventPlaySodaManagerRecord + { + public int id; + public int event_id; + public int daily_reward_id; + public int challenge_group_id; + public int play_helptip_id; + public int story_group_id; + public int total_point_reward_group_id; + public int ingame_pause_second; + public MiniGameSystemType minigame_type; + public string ui_prefab_keyword = ""; + } + + public enum MiniGameSystemType + { + Normal, + Archive, + Arcade + } + + [MemoryPackable] + public partial class EventPlaySodaStoryModeRecord + { + public int id; + public int group_id; + public int stage_data_id; + public int stage_helptip_id; + public string stage_image = ""; + public int order; + public EventDungeonOpenCondition open_condition_type; + public int open_condition_value; + public string game_title = ""; + public EventPlaySodaGameType game_type; + public string short_name = ""; + public int clear_reward_id; + public string enter_scenario = ""; + public string exit_scenario = ""; + } + + [MemoryPackable] + public partial class EventPlaySodaChallengeModeRecord + { + public int id; + public int group_id; + public int stage_data_id; + public int stage_helptip_id; + public string stage_image = ""; + public int order; + public EventDungeonOpenCondition open_condition_type; + public int open_condition_value; + public string game_title = ""; + public string game_title_en = ""; + public EventPlaySodaGameType game_type; + public string game_mode_resource = ""; + } + + public enum EventPlaySodaGameType + { + Running = 2001, + Smash = 2002, + CatchCoin = 2003, + StackUp = 2004, + Climbing = 2005 + } + + public enum EventDungeonOpenCondition + { + None, + EventDungeonStageClear, + EventDay + } + + [MemoryPackable] + public partial class EventPlaySodaPointRewardRecord + { + public int id; + public int group_id; + public int point_value; + public EventPlaySodaGameType game_type; + public int step; + public int reward_id; + } } diff --git a/EpinelPS/LobbyServer/Minigame/PlaySoda/GetChallengeEnter.cs b/EpinelPS/LobbyServer/Minigame/PlaySoda/GetChallengeEnter.cs new file mode 100644 index 0000000..7203d1b --- /dev/null +++ b/EpinelPS/LobbyServer/Minigame/PlaySoda/GetChallengeEnter.cs @@ -0,0 +1,25 @@ +using EpinelPS.Database; +using EpinelPS.Utils; + +namespace EpinelPS.LobbyServer.Minigame.PlaySoda +{ + [PacketPath("/arcade/play-soda/challenge/enter")] + public class GetChallengeEnter : LobbyMsgHandler + { + protected override async Task HandleAsync() + { + var request = await ReadData(); + + var user = GetUser(); + + ResEnterArcadePlaySodaChallengeStage response = new() + { + UserMaxScore = user.ArcadePlaySodaInfoList.First(i => i.ChallengeStageId == request.ChallengeStageId).UserRank + }; + + await WriteDataAsync(response); + + JsonDb.Save(); + } + } +} diff --git a/EpinelPS/LobbyServer/Minigame/PlaySoda/GetChallengeFinishCatchCoin.cs b/EpinelPS/LobbyServer/Minigame/PlaySoda/GetChallengeFinishCatchCoin.cs new file mode 100644 index 0000000..615b217 --- /dev/null +++ b/EpinelPS/LobbyServer/Minigame/PlaySoda/GetChallengeFinishCatchCoin.cs @@ -0,0 +1,39 @@ +using EpinelPS.Data; +using EpinelPS.Database; +using EpinelPS.Utils; + +namespace EpinelPS.LobbyServer.Minigame.PlaySoda +{ + [PacketPath("/arcade/play-soda/challenge/finish/catchcoin")] + public class GetChallengeFinishCatchCoin : LobbyMsgHandler + { + protected override async Task HandleAsync() + { + var request = await ReadData(); + + var user = GetUser(); + + var challengeStageId = GameData.Instance.EventPlaySodaChallengeModeTable.First(i => i.Value.game_type == EventPlaySodaGameType.CatchCoin).Key; + + var arcadePlaySodaInfo = user.ArcadePlaySodaInfoList.First(i => i.ChallengeStageId == challengeStageId); + + if (arcadePlaySodaInfo.UserRank < request.Score) + { + arcadePlaySodaInfo.UserRank = request.Score; + } + + arcadePlaySodaInfo.AccumulatedScore += request.Score; + + var pointValues = GetChallengeObtainPointReward.GetPointValues(arcadePlaySodaInfo.ChallengeStageId); + + if (pointValues.Length > arcadePlaySodaInfo.LastRewardStep && arcadePlaySodaInfo.AccumulatedScore >= pointValues[arcadePlaySodaInfo.LastRewardStep]) + { + arcadePlaySodaInfo.CanReceivePointReward = true; + } + + await WriteDataAsync(new ResFinishArcadePlaySodaCatchCoinChallenge()); + + JsonDb.Save(); + } + } +} diff --git a/EpinelPS/LobbyServer/Minigame/PlaySoda/GetChallengeFinishClimbing.cs b/EpinelPS/LobbyServer/Minigame/PlaySoda/GetChallengeFinishClimbing.cs new file mode 100644 index 0000000..718cefd --- /dev/null +++ b/EpinelPS/LobbyServer/Minigame/PlaySoda/GetChallengeFinishClimbing.cs @@ -0,0 +1,39 @@ +using EpinelPS.Data; +using EpinelPS.Database; +using EpinelPS.Utils; + +namespace EpinelPS.LobbyServer.Minigame.PlaySoda +{ + [PacketPath("/arcade/play-soda/challenge/finish/climbing")] + public class GetChallengeFinishClimbing : LobbyMsgHandler + { + protected override async Task HandleAsync() + { + var request = await ReadData(); + + var user = GetUser(); + + var challengeStageId = GameData.Instance.EventPlaySodaChallengeModeTable.First(i => i.Value.game_type == EventPlaySodaGameType.Climbing).Key; + + var arcadePlaySodaInfo = user.ArcadePlaySodaInfoList.First(i => i.ChallengeStageId == challengeStageId); + + if (arcadePlaySodaInfo.UserRank < request.Score) + { + arcadePlaySodaInfo.UserRank = request.Score; + } + + arcadePlaySodaInfo.AccumulatedScore += request.Score; + + var pointValues = GetChallengeObtainPointReward.GetPointValues(arcadePlaySodaInfo.ChallengeStageId); + + if (pointValues.Length > arcadePlaySodaInfo.LastRewardStep && arcadePlaySodaInfo.AccumulatedScore >= pointValues[arcadePlaySodaInfo.LastRewardStep]) + { + arcadePlaySodaInfo.CanReceivePointReward = true; + } + + await WriteDataAsync(new ResFinishArcadePlaySodaClimbingChallenge()); + + JsonDb.Save(); + } + } +} diff --git a/EpinelPS/LobbyServer/Minigame/PlaySoda/GetChallengeFinishRunning.cs b/EpinelPS/LobbyServer/Minigame/PlaySoda/GetChallengeFinishRunning.cs new file mode 100644 index 0000000..5973cc7 --- /dev/null +++ b/EpinelPS/LobbyServer/Minigame/PlaySoda/GetChallengeFinishRunning.cs @@ -0,0 +1,39 @@ +using EpinelPS.Data; +using EpinelPS.Database; +using EpinelPS.Utils; + +namespace EpinelPS.LobbyServer.Minigame.PlaySoda +{ + [PacketPath("/arcade/play-soda/challenge/finish/running")] + public class GetChallengeFinishRunning : LobbyMsgHandler + { + protected override async Task HandleAsync() + { + var request = await ReadData(); + + var user = GetUser(); + + var challengeStageId = GameData.Instance.EventPlaySodaChallengeModeTable.First(i => i.Value.game_type == EventPlaySodaGameType.Running).Key; + + var arcadePlaySodaInfo = user.ArcadePlaySodaInfoList.First(i => i.ChallengeStageId == challengeStageId); + + if (arcadePlaySodaInfo.UserRank < request.Score) + { + arcadePlaySodaInfo.UserRank = request.Score; + } + + arcadePlaySodaInfo.AccumulatedScore += request.Score; + + var pointValues = GetChallengeObtainPointReward.GetPointValues(arcadePlaySodaInfo.ChallengeStageId); + + if (pointValues.Length > arcadePlaySodaInfo.LastRewardStep && arcadePlaySodaInfo.AccumulatedScore >= pointValues[arcadePlaySodaInfo.LastRewardStep]) + { + arcadePlaySodaInfo.CanReceivePointReward = true; + } + + await WriteDataAsync(new ResFinishArcadePlaySodaRunningChallenge()); + + JsonDb.Save(); + } + } +} diff --git a/EpinelPS/LobbyServer/Minigame/PlaySoda/GetChallengeFinishSmash.cs b/EpinelPS/LobbyServer/Minigame/PlaySoda/GetChallengeFinishSmash.cs new file mode 100644 index 0000000..ab3c409 --- /dev/null +++ b/EpinelPS/LobbyServer/Minigame/PlaySoda/GetChallengeFinishSmash.cs @@ -0,0 +1,39 @@ +using EpinelPS.Data; +using EpinelPS.Database; +using EpinelPS.Utils; + +namespace EpinelPS.LobbyServer.Minigame.PlaySoda +{ + [PacketPath("/arcade/play-soda/challenge/finish/smash")] + public class GetChallengeFinishSmash : LobbyMsgHandler + { + protected override async Task HandleAsync() + { + var request = await ReadData(); + + var user = GetUser(); + + var challengeStageId = GameData.Instance.EventPlaySodaChallengeModeTable.First(i => i.Value.game_type == EventPlaySodaGameType.Smash).Key; + + var arcadePlaySodaInfo = user.ArcadePlaySodaInfoList.First(i => i.ChallengeStageId == challengeStageId); + + if (arcadePlaySodaInfo.UserRank < request.Score) + { + arcadePlaySodaInfo.UserRank = request.Score; + } + + arcadePlaySodaInfo.AccumulatedScore += request.Score; + + var pointValues = GetChallengeObtainPointReward.GetPointValues(arcadePlaySodaInfo.ChallengeStageId); + + if (pointValues.Length > arcadePlaySodaInfo.LastRewardStep && arcadePlaySodaInfo.AccumulatedScore >= pointValues[arcadePlaySodaInfo.LastRewardStep]) + { + arcadePlaySodaInfo.CanReceivePointReward = true; + } + + await WriteDataAsync(new ResFinishArcadePlaySodaSmashChallenge()); + + JsonDb.Save(); + } + } +} diff --git a/EpinelPS/LobbyServer/Minigame/PlaySoda/GetChallengeFinishStackUp.cs b/EpinelPS/LobbyServer/Minigame/PlaySoda/GetChallengeFinishStackUp.cs new file mode 100644 index 0000000..bc9c9b6 --- /dev/null +++ b/EpinelPS/LobbyServer/Minigame/PlaySoda/GetChallengeFinishStackUp.cs @@ -0,0 +1,39 @@ +using EpinelPS.Data; +using EpinelPS.Database; +using EpinelPS.Utils; + +namespace EpinelPS.LobbyServer.Minigame.PlaySoda +{ + [PacketPath("/arcade/play-soda/challenge/finish/stackup")] + public class GetChallengeFinishStackUp : LobbyMsgHandler + { + protected override async Task HandleAsync() + { + var request = await ReadData(); + + var user = GetUser(); + + var challengeStageId = GameData.Instance.EventPlaySodaChallengeModeTable.First(i => i.Value.game_type == EventPlaySodaGameType.StackUp).Key; + + var arcadePlaySodaInfo = user.ArcadePlaySodaInfoList.First(i => i.ChallengeStageId == challengeStageId); + + if (arcadePlaySodaInfo.UserRank < request.Score) + { + arcadePlaySodaInfo.UserRank = request.Score; + } + + arcadePlaySodaInfo.AccumulatedScore += request.Score; + + var pointValues = GetChallengeObtainPointReward.GetPointValues(arcadePlaySodaInfo.ChallengeStageId); + + if (pointValues.Length > arcadePlaySodaInfo.LastRewardStep && arcadePlaySodaInfo.AccumulatedScore >= pointValues[arcadePlaySodaInfo.LastRewardStep]) + { + arcadePlaySodaInfo.CanReceivePointReward = true; + } + + await WriteDataAsync(new ResFinishArcadePlaySodaStackUpChallenge()); + + JsonDb.Save(); + } + } +} diff --git a/EpinelPS/LobbyServer/Minigame/PlaySoda/GetChallengeInfo.cs b/EpinelPS/LobbyServer/Minigame/PlaySoda/GetChallengeInfo.cs index 3a5fd77..e2e6b39 100644 --- a/EpinelPS/LobbyServer/Minigame/PlaySoda/GetChallengeInfo.cs +++ b/EpinelPS/LobbyServer/Minigame/PlaySoda/GetChallengeInfo.cs @@ -1,17 +1,33 @@ -using EpinelPS.Utils; - -namespace EpinelPS.LobbyServer.Minigame.PlaySoda -{ - [PacketPath("/event/minigame/playsoda/challenge/getinfo")] - public class GetChallengeInfo : LobbyMsgHandler - { - protected override async Task HandleAsync() - { - ReqGetPlaySodaChallengeModeInfo req = await ReadData(); - - ResGetPlaySodaChallengeModeInfo response = new(); - // TODO - await WriteDataAsync(response); - } - } -} +using EpinelPS.Data; +using EpinelPS.Database; +using EpinelPS.Utils; + +namespace EpinelPS.LobbyServer.Minigame.PlaySoda +{ + [PacketPath("/arcade/play-soda/challenge/info")] + public class GetChallengeInfo : LobbyMsgHandler + { + protected override async Task HandleAsync() + { + var request = await ReadData(); + + var user = GetUser(); + + ResGetArcadePlaySodaChallengeModeInfo response = new() { WholeUser = LobbyHandler.CreateWholeUserDataFromDbUser(user) }; + + for (int i = 0; i < GameData.Instance.EventPlaySodaChallengeModeTable.Count; i++) + { + if (user.ArcadePlaySodaInfoList.Count < GameData.Instance.EventPlaySodaChallengeModeTable.Count) + { + user.ArcadePlaySodaInfoList.Add(new() { AccumulatedScore = 0, CanReceivePointReward = false, ChallengeStageId = GameData.Instance.EventPlaySodaChallengeModeTable.Keys.ElementAt(i), LastRewardStep = 0, IsInGuild = false, UserRank = 0, UserMaxScoreInUnion = 0 /* TODO UNIONS */ }); + } + + response.ArcadePlaySodaEachGameInfoList.Add(user.ArcadePlaySodaInfoList[i]); + } + + await WriteDataAsync(response); + + JsonDb.Save(); + } + } +} diff --git a/EpinelPS/LobbyServer/Minigame/PlaySoda/GetChallengeObtainPointReward.cs b/EpinelPS/LobbyServer/Minigame/PlaySoda/GetChallengeObtainPointReward.cs new file mode 100644 index 0000000..2a1ef62 --- /dev/null +++ b/EpinelPS/LobbyServer/Minigame/PlaySoda/GetChallengeObtainPointReward.cs @@ -0,0 +1,50 @@ +using EpinelPS.Data; +using EpinelPS.Database; +using EpinelPS.Utils; + +namespace EpinelPS.LobbyServer.Minigame.PlaySoda +{ + [PacketPath("/arcade/play-soda/challenge/obtain-point-reward")] + public class GetChallengeObtainPointReward : LobbyMsgHandler + { + protected override async Task HandleAsync() + { + var request = await ReadData(); + + var user = GetUser(); + + var arcadePlaySodaInfo = user.ArcadePlaySodaInfoList.First(i => i.ChallengeStageId == request.ChallengeStageId); + + arcadePlaySodaInfo.CanReceivePointReward = false; + + List rewards = []; + + var pointValues = GetPointValues(arcadePlaySodaInfo.ChallengeStageId); + + while (pointValues.Length > arcadePlaySodaInfo.LastRewardStep && arcadePlaySodaInfo.AccumulatedScore >= pointValues[arcadePlaySodaInfo.LastRewardStep]) + { + arcadePlaySodaInfo.LastRewardStep++; + rewards.Add(RewardUtils.RegisterRewardsForUser(user, GameData.Instance.EventPlaySodaPointRewardTable.First(r => (int)r.Value.game_type == arcadePlaySodaInfo.ChallengeStageId && r.Value.step == arcadePlaySodaInfo.LastRewardStep && r.Value.point_value == pointValues[arcadePlaySodaInfo.LastRewardStep - 1]).Value.reward_id)); + } + + await WriteDataAsync(new ResObtainArcadePlaySodaPointReward() { LastRewardStep = arcadePlaySodaInfo.LastRewardStep, Reward = NetUtils.MergeRewards(rewards, user) }); + + JsonDb.Save(); + } + + public static int[] GetPointValues(int challengeStageId) + { + var s = (int)EventPlaySodaGameType.Smash; + if (challengeStageId == (int)EventPlaySodaGameType.CatchCoin) + { + return [300000, 600000, 1000000]; + } + else if (challengeStageId == (int)EventPlaySodaGameType.Smash) + { + return [120000, 240000, 400000]; + } + + return [360000, 720000, 1200000]; + } + } +} diff --git a/EpinelPS/LobbyServer/Minigame/PlaySoda/GetEnterlog.cs b/EpinelPS/LobbyServer/Minigame/PlaySoda/GetEnterlog.cs new file mode 100644 index 0000000..50d511e --- /dev/null +++ b/EpinelPS/LobbyServer/Minigame/PlaySoda/GetEnterlog.cs @@ -0,0 +1,15 @@ +using EpinelPS.Utils; + +namespace EpinelPS.LobbyServer.Minigame.PlaySoda +{ + [PacketPath("/arcade/enterlog")] + public class GetEnterArcadeLog : LobbyMsgHandler + { + protected override async Task HandleAsync() + { + var request = await ReadData(); + + await WriteDataAsync(new ResEnterArcadeLog()); + } + } +} diff --git a/EpinelPS/Models/UserModel.cs b/EpinelPS/Models/UserModel.cs index 6376a23..ca1a6ab 100644 --- a/EpinelPS/Models/UserModel.cs +++ b/EpinelPS/Models/UserModel.cs @@ -102,6 +102,7 @@ public class User // Event data public Dictionary EventInfo = []; public MogMinigameInfo MogInfo = new(); + public List ArcadePlaySodaInfoList = []; public TriggerModel AddTrigger(TriggerType type, int value, int conditionId = 0) {