diff --git a/backend/app/Savor22b.Tests/Action/RemoveInstalledKitchenEquipmentActionTests.cs b/backend/app/Savor22b.Tests/Action/UninstallKitchenEquipmentActionTests.cs similarity index 89% rename from backend/app/Savor22b.Tests/Action/RemoveInstalledKitchenEquipmentActionTests.cs rename to backend/app/Savor22b.Tests/Action/UninstallKitchenEquipmentActionTests.cs index 13d73e8a..35dc47fa 100644 --- a/backend/app/Savor22b.Tests/Action/RemoveInstalledKitchenEquipmentActionTests.cs +++ b/backend/app/Savor22b.Tests/Action/UninstallKitchenEquipmentActionTests.cs @@ -9,9 +9,9 @@ namespace Savor22b.Tests.Action; using Savor22b.States; using Xunit; -public class RemoveInstalledKitchenEquipmentActionTests : ActionTests +public class UninstallKitchenEquipmentActionTests : ActionTests { - public RemoveInstalledKitchenEquipmentActionTests() { } + public UninstallKitchenEquipmentActionTests() { } private readonly Guid EquipmentStateId = new(); @@ -38,8 +38,8 @@ public void Execute_Success_Normal() beforeState = beforeState.SetState(SignerAddress(), beforeRootState.Serialize()); - var action = new RemoveInstalledKitchenEquipmentAction( - beforeRootState.InventoryState.KitchenEquipmentStateList[0].StateID + var action = new UninstallKitchenEquipmentAction( + 1 ); var afterState = action.Execute( @@ -87,7 +87,7 @@ public void Execute_Failure_NotInstalledKitchenEquipment() beforeState = beforeState.SetState(SignerAddress(), beforeRootState.Serialize()); - var action = new RemoveInstalledKitchenEquipmentAction(Guid.NewGuid()); + var action = new UninstallKitchenEquipmentAction(1); Assert.Throws(() => { diff --git a/backend/app/Savor22b/Action/RemoveInstalledKitchenEquipmentAction.cs b/backend/app/Savor22b/Action/UninstallKitchenEquipmentAction.cs similarity index 65% rename from backend/app/Savor22b/Action/RemoveInstalledKitchenEquipmentAction.cs rename to backend/app/Savor22b/Action/UninstallKitchenEquipmentAction.cs index e9062414..4f57b850 100644 --- a/backend/app/Savor22b/Action/RemoveInstalledKitchenEquipmentAction.cs +++ b/backend/app/Savor22b/Action/UninstallKitchenEquipmentAction.cs @@ -8,27 +8,27 @@ namespace Savor22b.Action; using Libplanet.Headless.Extensions; using Libplanet.State; -[ActionType(nameof(RemoveInstalledKitchenEquipmentAction))] -public class RemoveInstalledKitchenEquipmentAction : SVRAction +[ActionType(nameof(UninstallKitchenEquipmentAction))] +public class UninstallKitchenEquipmentAction : SVRAction { - public RemoveInstalledKitchenEquipmentAction() { } + public UninstallKitchenEquipmentAction() { } - public RemoveInstalledKitchenEquipmentAction(Guid installedEquipmentStateId) + public UninstallKitchenEquipmentAction(int spaceNumber) { - InstalledEquipmentStateId = installedEquipmentStateId; + SpaceNumber = spaceNumber; } - public Guid InstalledEquipmentStateId { get; private set; } + public int SpaceNumber { get; private set; } protected override IImmutableDictionary PlainValueInternal => new Dictionary() { - [nameof(InstalledEquipmentStateId)] = InstalledEquipmentStateId.Serialize(), + [nameof(SpaceNumber)] = SpaceNumber.Serialize(), }.ToImmutableDictionary(); protected override void LoadPlainValueInternal(IImmutableDictionary plainValue) { - InstalledEquipmentStateId = plainValue[nameof(InstalledEquipmentStateId)].ToGuid(); + SpaceNumber = plainValue[nameof(SpaceNumber)].ToInteger(); } public override IAccountStateDelta Execute(IActionContext ctx) @@ -49,7 +49,7 @@ public override IAccountStateDelta Execute(IActionContext ctx) KitchenState kitchenState = rootState.VillageState!.HouseState.KitchenState; - kitchenState.RemoveInstalledEquipment(InstalledEquipmentStateId); + kitchenState.UninstalledEquipment(SpaceNumber); return states.SetState(ctx.Signer, rootState.Serialize()); } diff --git a/backend/app/Savor22b/GraphTypes/Query/Query.cs b/backend/app/Savor22b/GraphTypes/Query/Query.cs index adfb90cf..6814f394 100644 --- a/backend/app/Savor22b/GraphTypes/Query/Query.cs +++ b/backend/app/Savor22b/GraphTypes/Query/Query.cs @@ -756,7 +756,7 @@ swarm is null AddField(new VillageField(blockChain, subject)); AddField(new ShowMeTheMoney(blockChain, swarm)); AddField(new ConquestDungeonActionQuery(blockChain, swarm)); - AddField(new RemoveInstalledKitchenEquipmentActionQuery(blockChain, swarm)); + AddField(new UninstallKitchenEquipmentActionQuery(blockChain, swarm)); AddField(new PeriodicDungeonRewardActionQuery(blockChain, swarm)); Field>( diff --git a/backend/app/Savor22b/GraphTypes/Query/RemoveInstalledKitchenEquipmentActionQuery.cs b/backend/app/Savor22b/GraphTypes/Query/UninstallKitchenEquipmentActionQuery.cs similarity index 71% rename from backend/app/Savor22b/GraphTypes/Query/RemoveInstalledKitchenEquipmentActionQuery.cs rename to backend/app/Savor22b/GraphTypes/Query/UninstallKitchenEquipmentActionQuery.cs index 873f57da..7bde0330 100644 --- a/backend/app/Savor22b/GraphTypes/Query/RemoveInstalledKitchenEquipmentActionQuery.cs +++ b/backend/app/Savor22b/GraphTypes/Query/UninstallKitchenEquipmentActionQuery.cs @@ -8,12 +8,12 @@ namespace Savor22b.GraphTypes.Query; using Libplanet.Net; using Savor22b.Action; -public class RemoveInstalledKitchenEquipmentActionQuery : FieldType +public class UninstallKitchenEquipmentActionQuery : FieldType { - public RemoveInstalledKitchenEquipmentActionQuery(BlockChain blockChain, Swarm swarm) + public UninstallKitchenEquipmentActionQuery(BlockChain blockChain, Swarm swarm) : base() { - Name = "createAction_RemoveInstalledKitchenEquipmentActionQuery"; + Name = "createAction_UninstallKitchenEquipmentActionQuery"; Type = typeof(NonNullGraphType); Description = "설치된 큰 조리도구를 설치 제거합니다."; Arguments = new QueryArguments( @@ -22,10 +22,10 @@ public RemoveInstalledKitchenEquipmentActionQuery(BlockChain blockChain, Swarm s Name = "publicKey", Description = "대상 유저의 40-hex 형태의 address 입니다.", }, - new QueryArgument> + new QueryArgument> { - Name = "installedEquipmentStateId", - Description = "제거하려는 설치된 큰 조리도구의 State Id(Guid) 입니다.", + Name = "spaceNumber", + Description = "제거하려는 설치된 큰 조리도구의 설치공간 번호 입니다.", } ); Resolver = new FuncFieldResolver(context => @@ -36,8 +36,8 @@ public RemoveInstalledKitchenEquipmentActionQuery(BlockChain blockChain, Swarm s Libplanet.ByteUtil.ParseHex(context.GetArgument("publicKey")) ); - var action = new RemoveInstalledKitchenEquipmentAction( - context.GetArgument("installedEquipmentStateId") + var action = new UninstallKitchenEquipmentAction( + context.GetArgument("spaceNumber") ); return new GetUnsignedTransactionHex( diff --git a/backend/app/Savor22b/States/KitchenState.cs b/backend/app/Savor22b/States/KitchenState.cs index a655a9ee..b6403644 100644 --- a/backend/app/Savor22b/States/KitchenState.cs +++ b/backend/app/Savor22b/States/KitchenState.cs @@ -80,27 +80,15 @@ int spaceNumber } } - public void RemoveInstalledEquipment(Guid stateId) + public void UninstalledEquipment(int spaceNumber) { - if (FirstApplianceSpace.InstalledKitchenEquipmentStateId == stateId) - { - FirstApplianceSpace.UnInstallKitchenEquipment(); - return; - } - - if (SecondApplianceSpace.InstalledKitchenEquipmentStateId == stateId) - { - SecondApplianceSpace.UnInstallKitchenEquipment(); - return; - } - - if (ThirdApplianceSpace.InstalledKitchenEquipmentStateId == stateId) + var applianceSpace = GetApplianceSpaceStateByNumber(spaceNumber); + if (applianceSpace.InstalledKitchenEquipmentStateId is null) { - ThirdApplianceSpace.UnInstallKitchenEquipment(); - return; + throw new InvalidValueException($"The space {spaceNumber} is not installed any kitchen equipment."); } - throw new InvalidValueException($"The equipment with the id {stateId} is not installed."); + applianceSpace.UnInstallKitchenEquipment(); } public ApplianceSpaceState GetApplianceSpaceStateByNumber(int spaceNumber)