From 67875160e712f160a94302046a791f0ae9f8ef42 Mon Sep 17 00:00:00 2001 From: hyeon Date: Fri, 18 Oct 2024 11:29:41 +0900 Subject: [PATCH 1/2] Introduce new GQL: lastClearedStage --- .../States/Models/World/ClearedStageType.cs | 12 ++++++++++++ .../States/Models/World/WorldInformationType.cs | 15 +++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 NineChronicles.Headless/GraphTypes/States/Models/World/ClearedStageType.cs diff --git a/NineChronicles.Headless/GraphTypes/States/Models/World/ClearedStageType.cs b/NineChronicles.Headless/GraphTypes/States/Models/World/ClearedStageType.cs new file mode 100644 index 000000000..ad47bc798 --- /dev/null +++ b/NineChronicles.Headless/GraphTypes/States/Models/World/ClearedStageType.cs @@ -0,0 +1,12 @@ +using GraphQL.Types; + +namespace NineChronicles.Headless.GraphTypes.States.Models.World; + +public class ClearedStageType : ObjectGraphType<(int, int)> +{ + public ClearedStageType() + { + Field>("worldId", resolve: context => context.Source.Item1); + Field>("stageId", resolve: context => context.Source.Item2); + } +} diff --git a/NineChronicles.Headless/GraphTypes/States/Models/World/WorldInformationType.cs b/NineChronicles.Headless/GraphTypes/States/Models/World/WorldInformationType.cs index 23f6b0196..d6cdd7f0d 100644 --- a/NineChronicles.Headless/GraphTypes/States/Models/World/WorldInformationType.cs +++ b/NineChronicles.Headless/GraphTypes/States/Models/World/WorldInformationType.cs @@ -40,6 +40,21 @@ public WorldInformationType() ? world : throw new ExecutionError($"Failed to fetch world {worldId}."); }); + + Field>( + "lastClearedStage", + resolve: context => + { + var found = context.Source.TryGetLastClearedStageId(out var stageId); + if (!found) + { + stageId = 0; + } + + var worldFound = context.Source.TryGetWorldByStageId(stageId, out var world); + return (worldFound ? world.Id : 0, stageId); + } + ); } } } From e76f686b96fefe00e3d27f71beb2337b5ad1c973 Mon Sep 17 00:00:00 2001 From: "ulismoon (hyeon)" Date: Mon, 21 Oct 2024 14:35:46 +0900 Subject: [PATCH 2/2] Update NineChronicles.Headless/GraphTypes/States/Models/World/ClearedStageType.cs Co-authored-by: Lee Dogeon --- .../GraphTypes/States/Models/World/ClearedStageType.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/NineChronicles.Headless/GraphTypes/States/Models/World/ClearedStageType.cs b/NineChronicles.Headless/GraphTypes/States/Models/World/ClearedStageType.cs index ad47bc798..24b8a58e8 100644 --- a/NineChronicles.Headless/GraphTypes/States/Models/World/ClearedStageType.cs +++ b/NineChronicles.Headless/GraphTypes/States/Models/World/ClearedStageType.cs @@ -2,11 +2,11 @@ namespace NineChronicles.Headless.GraphTypes.States.Models.World; -public class ClearedStageType : ObjectGraphType<(int, int)> +public class ClearedStageType : ObjectGraphType<(int WorldId, int StageId)> { public ClearedStageType() { - Field>("worldId", resolve: context => context.Source.Item1); - Field>("stageId", resolve: context => context.Source.Item2); + Field>("worldId", resolve: context => context.Source.WorldId); + Field>("stageId", resolve: context => context.Source.StageId); } }