Skip to content

Commit

Permalink
Merge pull request #322 from ipdae/improve/state-query-doc
Browse files Browse the repository at this point in the history
Document StateQuery
  • Loading branch information
longfin authored Feb 26, 2021
2 parents d485f08 + 2a2b39f commit 9eabe34
Show file tree
Hide file tree
Showing 12 changed files with 137 additions and 36 deletions.
54 changes: 31 additions & 23 deletions NineChronicles.Headless/GraphTypes/ActionMutation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ public class ActionMutation : ObjectGraphType<NineChroniclesNodeService>
public ActionMutation()
{
Field<NonNullGraphType<TxIdType>>("createAvatar",
description: "Create new avatar.",
arguments: new QueryArguments(
new QueryArgument<NonNullGraphType<StringGraphType>>
{
Name = "avatarName",
Description = "The character name."
Description = "Avatar name."
},
new QueryArgument<NonNullGraphType<IntGraphType>>
{
Expand Down Expand Up @@ -91,16 +92,17 @@ public ActionMutation()
});

Field<NonNullGraphType<TxIdType>>("hackAndSlash",
description: "Start stage to get material.",
arguments: new QueryArguments(
new QueryArgument<NonNullGraphType<AddressType>>
{
Name = "avatarAddress",
Description = "AvatarState address."
Description = "Avatar address."
},
new QueryArgument<NonNullGraphType<IntGraphType>>
{
Name = "worldId",
Description = "World ID."
Description = "World ID containing the stage ID."
},
new QueryArgument<NonNullGraphType<IntGraphType>>
{
Expand All @@ -115,7 +117,7 @@ public ActionMutation()
new QueryArgument<NonNullGraphType<AddressType>>
{
Name = "rankingArenaAddress",
Description = "AvatarState rankingMapAddress."
Description = "Address of RankingMapState containing the avatar address."
},
new QueryArgument<ListGraphType<GuidGraphType>>
{
Expand Down Expand Up @@ -174,26 +176,27 @@ public ActionMutation()
});

Field<NonNullGraphType<TxIdType>>("combinationEquipment",
description: "Combine new equipment.",
arguments: new QueryArguments(
new QueryArgument<NonNullGraphType<AddressType>>
{
Name = "avatarAddress",
Description = "AvatarState address."
Description = "Avatar address to create equipment."
},
new QueryArgument<NonNullGraphType<IntGraphType>>
{
Name = "recipeId",
Description = "EquipmentRecipe ID."
Description = "EquipmentRecipe ID from EquipmentRecipeSheet."
},
new QueryArgument<NonNullGraphType<IntGraphType>>
{
Name = "slotIndex",
Description = "The index of combination slot. 0 ~ 3"
Description = "The empty combination slot index to combine equipment. 0 ~ 3"
},
new QueryArgument<IntGraphType>
{
Name = "subRecipeId",
Description = "EquipmentSubRecipe ID."
Description = "EquipmentSubRecipe ID from EquipmentSubRecipeSheet."
}
),
resolve: context =>
Expand Down Expand Up @@ -229,26 +232,27 @@ public ActionMutation()
});

Field<NonNullGraphType<TxIdType>>("itemEnhancement",
description: "Upgrade equipment.",
arguments: new QueryArguments(
new QueryArgument<NonNullGraphType<AddressType>>
{
Name = "avatarAddress",
Description = "AvatarState address."
Description = "Avatar address to upgrade equipment."
},
new QueryArgument<NonNullGraphType<GuidGraphType>>
{
Name = "itemId",
Description = "Equipment Guid."
Description = "Equipment Guid for upgrade."
},
new QueryArgument<NonNullGraphType<GuidGraphType>>
{
Name = "materialId",
Description = "Material Guid."
Description = "Material Guid for equipment upgrade."
},
new QueryArgument<NonNullGraphType<IntGraphType>>
{
Name = "slotIndex",
Description = "The index of combination slot. 0 ~ 3"
Description = "The empty combination slot index to upgrade equipment. 0 ~ 3"
}
),
resolve: context =>
Expand Down Expand Up @@ -285,26 +289,27 @@ public ActionMutation()
});

Field<NonNullGraphType<TxIdType>>("buy",
description: "Buy registered shop item.",
arguments: new QueryArguments(
new QueryArgument<NonNullGraphType<AddressType>>
{
Name = "sellerAgentAddress",
Description = "ShopItem SellerAgentAddress."
Description = "Agent address from registered ShopItem."
},
new QueryArgument<NonNullGraphType<AddressType>>
{
Name = "sellerAvatarAddress",
Description = "ShopItem SellerAvatarAddress."
Description = "Avatar address from registered ShopItem."
},
new QueryArgument<NonNullGraphType<AddressType>>
{
Name = "buyerAvatarAddress",
Description = "AvatarState address."
Description = "Avatar address."
},
new QueryArgument<NonNullGraphType<GuidGraphType>>
{
Name = "productId",
Description = "ShopItem Guid."
Description = "ShopItem product ID."
}),
resolve: context =>
{
Expand Down Expand Up @@ -339,21 +344,22 @@ public ActionMutation()
}
});
Field<NonNullGraphType<TxIdType>>("sell",
description: "Register item to the shop.",
arguments: new QueryArguments(
new QueryArgument<NonNullGraphType<AddressType>>
{
Name = "sellerAvatarAddress",
Description = "AvatarState address."
Description = "Avatar address to register shop item."
},
new QueryArgument<NonNullGraphType<GuidGraphType>>
{
Name = "itemId",
Description = "Item Guid."
Description = "Item Guid to register on shop."
},
new QueryArgument<NonNullGraphType<IntGraphType>>
{
Name = "price",
Description = "Item price."
Description = "Item selling price."
}),
resolve: context =>
{
Expand Down Expand Up @@ -389,11 +395,12 @@ public ActionMutation()
});

Field<NonNullGraphType<TxIdType>>("dailyReward",
description: "Get daily reward.",
arguments: new QueryArguments(
new QueryArgument<NonNullGraphType<AddressType>>
{
Name = "avatarAddress",
Description = "AvatarState address."
Description = "Avatar address to receive reward."
}
),
resolve: context =>
Expand Down Expand Up @@ -424,21 +431,22 @@ public ActionMutation()
});

Field<NonNullGraphType<TxIdType>>("combinationConsumable",
description: "Combine new Consumable.",
arguments: new QueryArguments(
new QueryArgument<NonNullGraphType<AddressType>>
{
Name = "avatarAddress",
Description = "AvatarState address."
Description = "Avatar address to combine consumable."
},
new QueryArgument<NonNullGraphType<IntGraphType>>
{
Name = "recipeId",
Description = "ConsumableRecipe ID."
Description = "ConsumableRecipe ID from ConsumableRecipeSheet."
},
new QueryArgument<NonNullGraphType<IntGraphType>>
{
Name = "slotIndex",
Description = "The index of combination slot. 0 ~ 3"
Description = "The empty combination slot index to combine consumable. 0 ~ 3"
}
),
resolve: context =>
Expand Down
9 changes: 9 additions & 0 deletions NineChronicles.Headless/GraphTypes/StateQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ public StateQuery()
Name = "StateQuery";
Field<AvatarStateType>(
name: "avatar",
description: "State for avatar.",
arguments: new QueryArguments(new QueryArgument<AddressType>
{
Name = "address",
Description = "Address of avatar."
}),
resolve: context =>
{
Expand All @@ -28,10 +30,12 @@ public StateQuery()
});
Field<RankingMapStateType>(
name: "rankingMap",
description: "State for avatar EXP record.",
arguments: new QueryArguments(
new QueryArgument<NonNullGraphType<IntGraphType>>
{
Name = "index",
Description = "RankingMapState index. 0 ~ 99"
}),
resolve: context =>
{
Expand All @@ -40,13 +44,16 @@ public StateQuery()
});
Field<ShopStateType>(
name: "shop",
description: "State for shop.",
resolve: context => new ShopState((Dictionary) context.Source(Addresses.Shop)));
Field<WeeklyArenaStateType>(
name: "weeklyArena",
description: "State for weekly arena.",
arguments: new QueryArguments(
new QueryArgument<NonNullGraphType<IntGraphType>>
{
Name = "index",
Description = "WeeklyArenaState index. It increases every 56,000 blocks."
}),
resolve: context =>
{
Expand All @@ -56,9 +63,11 @@ public StateQuery()
});
Field<AgentStateType>(
name: "agent",
description: "State for agent.",
arguments: new QueryArguments(new QueryArgument<NonNullGraphType<AddressType>>
{
Name = "address",
Description = "Address of agent."
}),
resolve: context =>
{
Expand Down
6 changes: 5 additions & 1 deletion NineChronicles.Headless/GraphTypes/States/AgentStateType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@ public AgentStateType(StandaloneContext standaloneContext)
{
Field<NonNullGraphType<AddressType>>(
nameof(AgentState.address),
description: "Address of agent.",
resolve: context => context.Source.address);
Field<ListGraphType<NonNullGraphType<AddressType>>>(
nameof(AgentState.avatarAddresses),
description: "Address list of avatar.",
resolve: context => context.Source.avatarAddresses.Select(a => a.Value));
Field<NonNullGraphType<StringGraphType>>("gold",
Field<NonNullGraphType<StringGraphType>>(
"gold",
description: "Current NCG.",
resolve: context =>
{
if (!(standaloneContext.BlockChain is BlockChain<PolymorphicAction<ActionBase>> blockChain))
Expand Down
24 changes: 24 additions & 0 deletions NineChronicles.Headless/GraphTypes/States/AvatarStateType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,79 +15,103 @@ public AvatarStateType()
{
Field<NonNullGraphType<AddressType>>(
nameof(AvatarState.address),
description: "Address of avatar.",
resolve: context => context.Source.address);
Field<NonNullGraphType<IntGraphType>>(
nameof(AvatarState.blockIndex),
description: "Block index at the latest executed action.",
resolve: context => context.Source.blockIndex);
Field<NonNullGraphType<IntGraphType>>(
nameof(AvatarState.characterId),
description: "Character ID from CharacterSheet.",
resolve: context => context.Source.characterId);
Field<NonNullGraphType<LongGraphType>>(
nameof(AvatarState.dailyRewardReceivedIndex),
description: "Block index at the DailyReward execution.",
resolve: context => context.Source.dailyRewardReceivedIndex);
Field<NonNullGraphType<AddressType>>(
nameof(AvatarState.agentAddress),
description: "Address of agent.",
resolve: context => context.Source.agentAddress);
Field<NonNullGraphType<AddressType>>(
nameof(AvatarState.RankingMapAddress),
description: "Address of the RankingMapState where this avatar information is recorded.",
resolve: context => context.Source.RankingMapAddress);
Field<NonNullGraphType<LongGraphType>>(
nameof(AvatarState.updatedAt),
description: "Block index at the latest executed action.",
resolve: context => context.Source.updatedAt);

Field<NonNullGraphType<StringGraphType>>(
nameof(AvatarState.name),
description: "Avatar name.",
resolve: context => context.Source.name);
Field<NonNullGraphType<IntGraphType>>(
nameof(AvatarState.exp),
description: "Avatar total EXP.",
resolve: context => context.Source.exp);
Field<NonNullGraphType<IntGraphType>>(
nameof(AvatarState.level),
description: "Avatar Level.",
resolve: context => context.Source.level);
Field<NonNullGraphType<IntGraphType>>(
nameof(AvatarState.actionPoint),
description: "Current ActionPoint.",
resolve: context => context.Source.actionPoint);

Field<NonNullGraphType<IntGraphType>>(
nameof(AvatarState.ear),
description: "Index of ear color.",
resolve: context => context.Source.ear);
Field<NonNullGraphType<IntGraphType>>(
nameof(AvatarState.hair),
description: "Index of hair color.",
resolve: context => context.Source.hair);
Field<NonNullGraphType<IntGraphType>>(
nameof(AvatarState.lens),
description: "Index of eye color.",
resolve: context => context.Source.lens);
Field<NonNullGraphType<IntGraphType>>(
nameof(AvatarState.tail),
description: "Index of tail color.",
resolve: context => context.Source.tail);

Field<NonNullGraphType<InventoryType>>(
nameof(AvatarState.inventory),
description: "Avatar inventory.",
resolve: context => context.Source.inventory);
Field<NonNullGraphType<ListGraphType<NonNullGraphType<AddressType>>>>(
nameof(AvatarState.combinationSlotAddresses),
description: "Address list of combination slot.",
resolve: context => context.Source.combinationSlotAddresses);
Field<NonNullGraphType<CollectionMapType>>(
nameof(AvatarState.itemMap),
description: "List of acquired item ID.",
resolve: context => context.Source.itemMap);
Field<NonNullGraphType<CollectionMapType>>(
nameof(AvatarState.eventMap),
description: "List of quest event ID.",
resolve: context => context.Source.eventMap);
Field<NonNullGraphType<CollectionMapType>>(
nameof(AvatarState.monsterMap),
description: "List of defeated monster ID.",
resolve: context => context.Source.monsterMap);
Field<NonNullGraphType<CollectionMapType>>(
nameof(AvatarState.stageMap),
description: "List of cleared stage ID.",
resolve: context => context.Source.stageMap);

Field<NonNullGraphType<QuestListType>>(
nameof(AvatarState.questList),
description: "List of quest.",
resolve: context => context.Source.questList);
Field<NonNullGraphType<MailBoxType>>(
nameof(AvatarState.mailBox),
description: "List of mail.",
resolve: context => context.Source.mailBox);
Field<NonNullGraphType<WorldInformationType>>(
nameof(AvatarState.worldInformation),
description: "World & Stage information.",
resolve: context => context.Source.worldInformation);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@ public class CostumeType : ItemBaseType<Costume>
{
public CostumeType()
{
Field<NonNullGraphType<GuidGraphType>>(nameof(Costume.ItemId));
Field<NonNullGraphType<BooleanGraphType>>(nameof(Costume.Equipped));
Field<NonNullGraphType<GuidGraphType>>(
nameof(Costume.ItemId),
description: "Guid of costume."
);
Field<NonNullGraphType<BooleanGraphType>>(
nameof(Costume.Equipped),
description: "Status of Avatar equipped."
);
}
}
}
Loading

0 comments on commit 9eabe34

Please sign in to comment.