Skip to content
This repository was archived by the owner on Feb 7, 2025. It is now read-only.

[SVR-322] [던전] 특정 유저의 던전 정보 READ 기능 #167

Merged
merged 8 commits into from
Apr 16, 2024
24 changes: 24 additions & 0 deletions backend/app/Savor22b/GraphTypes/Query/Query.cs
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,30 @@ swarm is null
AddField(new ConquestDungeonActionQuery(blockChain, swarm));
AddField(new RemoveInstalledKitchenEquipmentActionQuery(blockChain, swarm));
AddField(new PeriodicDungeonRewardActionQuery(blockChain, swarm));

Field<NonNullGraphType<IntGraphType>>(
name: "maxDungeonKeyCount",
description: "던전 키의 최대 개수입니다.",
resolve: context => UserDungeonState.MaxDungeonKey
);

Field<NonNullGraphType<LongGraphType>>(
name: "dungeonKeyChargeIntervalBlock",
description: "던전 키의 충전 주기(Block)입니다.",
resolve: context => UserDungeonState.DungeonKeyChargeIntervalBlock
);

Field<NonNullGraphType<IntGraphType>>(
name: "maxDungeonConquestKeyCount",
description: "던전 점령 키(던전마다 할당)의 최대 개수입니다.",
resolve: context => UserDungeonState.MaxDungeonConquestKeyCount
);

Field<NonNullGraphType<LongGraphType>>(
name: "dungeonConquestKeyChargeIntervalBlock",
description: "던전 점령 키(던전마다 할당)의 충전 주기(Block)입니다.",
resolve: context => UserDungeonState.DungeonConquestKeyChargeIntervalBlock
);
}

private List<RecipeResponse> combineRecipeData()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace Savor22b.GraphTypes.Types;

using GraphQL.Types;
using Savor22b.States;

public class DungeonConquestHistoryStateType : ObjectGraphType<DungeonConquestHistoryState>
{
public DungeonConquestHistoryStateType()
{
Field<NonNullGraphType<LongGraphType>>(
name: "BlockIndex",
description: "던전 점령을 신청한 블록의 인덱스입니다.",
resolve: context => context.Source.BlockIndex
);

Field<NonNullGraphType<BooleanGraphType>>(
name: "DungeonConquestStatus",
description: "던전의 점령 신청이 성공했는지 여부입니다.",
resolve: context => context.Source.DungeonConquestStatus
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace Savor22b.GraphTypes.Types;

using GraphQL.Types;
using Savor22b.States;

public class DungeonHistoryStateType : ObjectGraphType<DungeonHistoryState>
{
public DungeonHistoryStateType()
{
Field<NonNullGraphType<LongGraphType>>(
name: "BlockIndex",
description: "던전 클리어를 신청한 블록 인덱스입니다.",
resolve: context => context.Source.BlockIndex
);

Field<NonNullGraphType<BooleanGraphType>>(
name: "DungeonClearStatus",
description: "던전 클리어 결과입니다.",
resolve: context => context.Source.DungeonClearStatus
);
}
}
65 changes: 65 additions & 0 deletions backend/app/Savor22b/GraphTypes/Types/UserDungeonDetailType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
namespace Savor22b.GraphTypes.Types;

using GraphQL;
using GraphQL.Types;
using Libplanet.Blockchain;
using Libplanet.Net;
using Libplanet.Store;
using Savor22b.States;

public class UserDungeonDetailType : ObjectGraphType<UserDungeonState>
{
public UserDungeonDetailType(
BlockChain blockChain,
BlockRenderer blockRenderer,
IStore store,
Swarm? swarm = null
)
{
Field<NonNullGraphType<IntGraphType>>(
name: "DungeonConquestKeyCount",
description: "해당 던전에 점령 신청 할 수 있는 키의 남은 갯수입니다.",
resolve: context =>
{
int dungeonId = context.GetArgument<int>("dungeonId");
return context.Source.GetDungeonConquestKeyCount(dungeonId, blockChain.Count);
}
);

Field<BooleanGraphType>(
name: "IsDungeonConquestRewardReceivable",
description: "점령한 던전의 주기적 보상을 받을 수 있는지 여부를 반환합니다. 점령한 던전이 아니라면 null을 반환합니다.",
resolve: context =>
{
int dungeonId = context.GetArgument<int>("dungeonId");

DungeonConquestHistoryState? history = context.Source.CurrentConquestDungeonHistory(
dungeonId
);

if (history is null)
{
return null;
}

return context.Source.IsDungeonConquestRewardReceivable(
dungeonId,
history.BlockIndex,
blockChain.Count
);
}
);

Field<NonNullGraphType<ListGraphType<DungeonHistoryStateType>>>(
name: "DungeonHistories",
description: "던전의 탐험 기록(클리어 기록)을 반환합니다.",
resolve: context => context.Source.DungeonHistories
);

Field<NonNullGraphType<ListGraphType<DungeonConquestHistoryStateType>>>(
name: "DungeonConquestHistories",
description: "던전의 점령 기록을 반환합니다.",
resolve: context => context.Source.DungeonConquestHistories
);
}
}
26 changes: 6 additions & 20 deletions backend/app/Savor22b/GraphTypes/Types/UserDungeonStateType.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace Savor22b.GraphTypes.Types;

using System.Collections.Immutable;
using GraphQL;
using GraphQL.Types;
using Libplanet;
Expand All @@ -24,34 +25,19 @@ public UserDungeonStateType(
resolve: context => context.Source.GetDungeonKeyCount(blockChain.Count)
);

Field<BooleanGraphType>(
name: "IsDungeonConquestRewardReceivable",
description: "점령한 던전의 주기적 보상을 받을 수 있는지 여부를 반환합니다. 점령한 던전이 아니라면 null을 반환합니다.",
Field<NonNullGraphType<UserDungeonDetailType>>(
name: "DungeonDetail",
description: "특정 던전에 대한(유저의) 상세 정보입니다.",
arguments: new QueryArguments(
new QueryArgument<NonNullGraphType<IntGraphType>>
{
Name = "dungeonId",
Description = "보상을 받고자 하는 던전(점령한)의 ID",
Description = "조회할 던전의 ID입니다.",
}
),
resolve: context =>
{
int dungeonId = context.GetArgument<int>("dungeonId");

DungeonConquestHistoryState? history = context.Source.CurrentConquestDungeonHistory(
dungeonId
);

if (history is null)
{
return null;
}

return context.Source.IsDungeonConquestRewardReceivable(
dungeonId,
history.BlockIndex,
blockChain.Count
);
return context.Source;
}
);
}
Expand Down
Loading