From 74bdd0160f3531519749fe97f54d0a952bd288bb Mon Sep 17 00:00:00 2001 From: Yang Chun Ung Date: Mon, 4 Dec 2023 16:52:48 +0900 Subject: [PATCH 1/2] Bump lib9c --- Lib9c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib9c b/Lib9c index d6d629e80..1dc61aa5f 160000 --- a/Lib9c +++ b/Lib9c @@ -1 +1 @@ -Subproject commit d6d629e8089d41432d525c5a58a12e5cf832ba17 +Subproject commit 1dc61aa5f4844a0112ba9dad79bc9dbdc732a54e From 5753c16791e9ae448f97b118b760a0639f259177 Mon Sep 17 00:00:00 2001 From: Yang Chun Ung Date: Wed, 29 Nov 2023 21:57:35 +0900 Subject: [PATCH 2/2] Introdcue RuneSummon action query --- .../GraphTypes/ActionQueryTest.cs | 29 +++++++++++++++ .../GraphTypes/ActionQueryFields/Summon.cs | 35 +++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/NineChronicles.Headless.Tests/GraphTypes/ActionQueryTest.cs b/NineChronicles.Headless.Tests/GraphTypes/ActionQueryTest.cs index 99db860d0..457fbc1cb 100644 --- a/NineChronicles.Headless.Tests/GraphTypes/ActionQueryTest.cs +++ b/NineChronicles.Headless.Tests/GraphTypes/ActionQueryTest.cs @@ -1490,5 +1490,34 @@ public async Task ClaimItems(int claimDataCount, bool hasMemo) Assert.Null(action.Memo); } } + + [Fact] + public async Task RuneSummon() + { + var random = new Random(); + var avatarAddress = new PrivateKey().Address; + var groupId = random.Next(20001, 20002 + 1); + // FIXME: Change 10 to AuraSummon.SummonLimit + var summonCount = random.Next(1, 10 + 1); + + var query = $@"{{ + runeSummon( + avatarAddress: ""{avatarAddress}"", + groupId: {groupId}, + summonCount: {summonCount} + ) + }}"; + + var queryResult = await ExecuteQueryAsync(query, standaloneContext: _standaloneContext); + var data = (Dictionary)((ExecutionNode)queryResult.Data!).ToValue()!; + var plainValue = _codec.Decode(ByteUtil.ParseHex((string)data["runeSummon"])); + Assert.IsType(plainValue); + var actionBase = DeserializeNCAction(plainValue); + var action = Assert.IsType(actionBase); + + Assert.Equal(avatarAddress, action.AvatarAddress); + Assert.Equal(groupId, action.GroupId); + Assert.Equal(summonCount, action.SummonCount); + } } } diff --git a/NineChronicles.Headless/GraphTypes/ActionQueryFields/Summon.cs b/NineChronicles.Headless/GraphTypes/ActionQueryFields/Summon.cs index 6391f7eaf..c5707b60f 100644 --- a/NineChronicles.Headless/GraphTypes/ActionQueryFields/Summon.cs +++ b/NineChronicles.Headless/GraphTypes/ActionQueryFields/Summon.cs @@ -39,5 +39,40 @@ private void RegisterSummon() return Encode(context, action); } ); + + Field>( + "runeSummon", + arguments: new QueryArguments( + new QueryArgument> + { + Name = "avatarAddress", + Description = "Avatar address to get summoned items" + }, + new QueryArgument> + { + Name = "groupId", + Description = "Summon group id" + }, + new QueryArgument> + { + Name = "summonCount", + Description = "Count to summon. Must between 1 and 10." + } + ), + resolve: context => + { + var avatarAddr = context.GetArgument
("avatarAddress"); + var groupId = context.GetArgument("groupId"); + var summonCount = context.GetArgument("summonCount"); + + ActionBase action = new RuneSummon + { + AvatarAddress = avatarAddr, + GroupId = groupId, + SummonCount = summonCount, + }; + return Encode(context, action); + } + ); } }