From 3c0c97b3329df39780239e05be616a55065b38b4 Mon Sep 17 00:00:00 2001 From: moreal Date: Tue, 30 Apr 2024 13:36:06 +0900 Subject: [PATCH 1/2] Disable .NET runtime instruments --- NineChronicles.Headless.Executable/Program.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/NineChronicles.Headless.Executable/Program.cs b/NineChronicles.Headless.Executable/Program.cs index 43871c2ad..9fd2fc96e 100644 --- a/NineChronicles.Headless.Executable/Program.cs +++ b/NineChronicles.Headless.Executable/Program.cs @@ -481,8 +481,6 @@ IActionLoader MakeSingleActionLoader() .WithMetrics( builder => builder .AddMeter("NineChronicles") - .AddRuntimeInstrumentation() - .AddAspNetCoreInstrumentation() .AddPrometheusExporter()); // worker From 554b8679a71de2e54c969d8b211c3f19dbfb1b87 Mon Sep 17 00:00:00 2001 From: Yang Chun Ung Date: Wed, 1 May 2024 13:40:53 +0900 Subject: [PATCH 2/2] Fix #2461 --- .../States/Models/AvatarStateTypeTest.cs | 54 +++++++++++++++++++ .../GraphTypes/States/AvatarStateType.cs | 25 ++++++++- 2 files changed, 77 insertions(+), 2 deletions(-) diff --git a/NineChronicles.Headless.Tests/GraphTypes/States/Models/AvatarStateTypeTest.cs b/NineChronicles.Headless.Tests/GraphTypes/States/Models/AvatarStateTypeTest.cs index ddbd69d8d..6bd4125ea 100644 --- a/NineChronicles.Headless.Tests/GraphTypes/States/Models/AvatarStateTypeTest.cs +++ b/NineChronicles.Headless.Tests/GraphTypes/States/Models/AvatarStateTypeTest.cs @@ -94,6 +94,38 @@ public async Task QueryWithCombinationSlotState(AvatarState avatarState, Diction Assert.Equal(expected, data); } + [Theory] + [MemberData(nameof(ActionPointMembers))] + public async Task QueryActionPoint(bool modern, Dictionary expected) + { + const string query = @" + { + actionPoint + dailyRewardReceivedIndex + }"; + IWorld mockWorld = new World(MockWorldState.CreateModern()); + mockWorld = mockWorld.SetAvatarState( + Fixtures.AvatarAddress, + Fixtures.AvatarStateFX, + true, + true, + true, + true); + mockWorld = mockWorld.SetAgentState(Fixtures.UserAddress, Fixtures.AgentStateFx); + if (modern) + { + mockWorld = mockWorld.SetDailyRewardReceivedBlockIndex(Fixtures.AvatarAddress, 1L) + .SetActionPoint(Fixtures.AvatarAddress, 5); + } + var queryResult = await ExecuteQueryAsync( + query, + source: new AvatarStateType.AvatarStateContext( + Fixtures.AvatarStateFX, + mockWorld, + 0, new StateMemoryCache())); + var data = (Dictionary)((ExecutionNode)queryResult.Data!).ToValue()!; + Assert.Equal(expected, data); + } public static IEnumerable Members => new List { new object[] @@ -128,5 +160,27 @@ public async Task QueryWithCombinationSlotState(AvatarState avatarState, Diction } } }; + + public static IEnumerable ActionPointMembers = new List() + { + new object[] + { + false, + new Dictionary + { + ["actionPoint"] = Fixtures.AvatarStateFX.actionPoint, + ["dailyRewardReceivedIndex"] = Fixtures.AvatarStateFX.dailyRewardReceivedIndex, + } + }, + new object[] + { + true, + new Dictionary + { + ["actionPoint"] = 5, + ["dailyRewardReceivedIndex"] = 1L, + } + } + }; } } diff --git a/NineChronicles.Headless/GraphTypes/States/AvatarStateType.cs b/NineChronicles.Headless/GraphTypes/States/AvatarStateType.cs index 8e5e15fe7..eb5211594 100644 --- a/NineChronicles.Headless/GraphTypes/States/AvatarStateType.cs +++ b/NineChronicles.Headless/GraphTypes/States/AvatarStateType.cs @@ -46,7 +46,18 @@ public AvatarStateType() Field>( nameof(AvatarState.dailyRewardReceivedIndex), description: "Block index at the DailyReward execution.", - resolve: context => context.Source.AvatarState.dailyRewardReceivedIndex); + resolve: context => + { + try + { + return context.Source.WorldState.GetDailyRewardReceivedBlockIndex(context.Source.AvatarState + .address); + } + catch (FailedLoadStateException) + { + return context.Source.AvatarState.dailyRewardReceivedIndex; + } + }); Field>( nameof(AvatarState.agentAddress), description: "Address of agent.", @@ -86,7 +97,17 @@ public AvatarStateType() Field>( nameof(AvatarState.actionPoint), description: "Current ActionPoint.", - resolve: context => context.Source.AvatarState.actionPoint); + resolve: context => + { + try + { + return context.Source.WorldState.GetActionPoint(context.Source.AvatarState.address); + } + catch (FailedLoadStateException) + { + return context.Source.AvatarState.actionPoint; + } + }); Field>( nameof(AvatarState.ear), description: "Index of ear color.",