diff --git a/backend/app/Savor22b.Tests/Action/CancelFoodActionTests.cs b/backend/app/Savor22b.Tests/Action/CancelFoodActionTests.cs index a49b4cf9..15365852 100644 --- a/backend/app/Savor22b.Tests/Action/CancelFoodActionTests.cs +++ b/backend/app/Savor22b.Tests/Action/CancelFoodActionTests.cs @@ -58,6 +58,7 @@ public class CancelFoodActionTests : ActionTests RootState beforeRootState = new RootState( beforeInventoryState, + new DungeonState(), new VillageState(new HouseState(1, 1, 1, beforeKitchenState)) ); diff --git a/backend/app/Savor22b.Tests/Action/CreateFoodActionTests.cs b/backend/app/Savor22b.Tests/Action/CreateFoodActionTests.cs index e854770b..496cb46e 100644 --- a/backend/app/Savor22b.Tests/Action/CreateFoodActionTests.cs +++ b/backend/app/Savor22b.Tests/Action/CreateFoodActionTests.cs @@ -176,6 +176,7 @@ ImmutableList FoodIDList RootState rootState = new RootState( inventoryState, + new DungeonState(), new VillageState(new HouseState(1, 1, 1, resultKitchenState)) ); diff --git a/backend/app/Savor22b.Tests/Action/HarvestingSeedActionTests.cs b/backend/app/Savor22b.Tests/Action/HarvestingSeedActionTests.cs index f95081e9..aa27e255 100644 --- a/backend/app/Savor22b.Tests/Action/HarvestingSeedActionTests.cs +++ b/backend/app/Savor22b.Tests/Action/HarvestingSeedActionTests.cs @@ -19,6 +19,7 @@ public void Execute_Success_Normal() IAccountStateDelta beforeState = new DummyState(); RootState beforeRootState = new RootState( new InventoryState(), + new DungeonState(), new VillageState( new HouseState( 1, 1, 1, new KitchenState() @@ -70,6 +71,7 @@ public void Execute_Success_AfterRemoveWeed() IAccountStateDelta beforeState = new DummyState(); RootState beforeRootState = new RootState( new InventoryState(), + new DungeonState(), new VillageState( new HouseState( 1, 1, 1, new KitchenState() diff --git a/backend/app/Savor22b.Tests/Action/InstallKitchenEquipmentActionTests.cs b/backend/app/Savor22b.Tests/Action/InstallKitchenEquipmentActionTests.cs index d46b4090..c2a0fb24 100644 --- a/backend/app/Savor22b.Tests/Action/InstallKitchenEquipmentActionTests.cs +++ b/backend/app/Savor22b.Tests/Action/InstallKitchenEquipmentActionTests.cs @@ -30,6 +30,7 @@ public void Execute_Success_NormalCase(int spaceNumber) ImmutableList.Empty.Add(new KitchenEquipmentState(Guid.NewGuid(), 1, 1)), ImmutableList.Empty ), + new DungeonState(), new VillageState( new HouseState( 1, 1, 1, new KitchenState() @@ -99,6 +100,7 @@ public void Execute_Failure_NotHaveKitchenEquipment() ImmutableList.Empty, ImmutableList.Empty ), + new DungeonState(), new VillageState( new HouseState( 1, 1, 1, new KitchenState() @@ -138,6 +140,7 @@ public void Execute_Failure_NotPlacedHouse() ImmutableList.Empty, ImmutableList.Empty ), + new DungeonState(), null ); diff --git a/backend/app/Savor22b.Tests/Action/PlaceUserHouseActionTests.cs b/backend/app/Savor22b.Tests/Action/PlaceUserHouseActionTests.cs index 60a38e49..6c59ac09 100644 --- a/backend/app/Savor22b.Tests/Action/PlaceUserHouseActionTests.cs +++ b/backend/app/Savor22b.Tests/Action/PlaceUserHouseActionTests.cs @@ -64,7 +64,7 @@ private IAccountStateDelta createStateForRelocationHouse() prevGlobalUserHouseState.UserHouse.Add("1,0,0", SignerAddress()); VillageState villageState = new VillageState(new HouseState(1, 0, 0, new KitchenState())); - RootState prevRootState = new RootState(new InventoryState(), villageState); + RootState prevRootState = new RootState(new InventoryState(), new DungeonState(), villageState); state = state.MintAsset( SignerAddress(), @@ -141,6 +141,7 @@ private IAccountStateDelta createStateForInProgressReplaceHouse() VillageState villageState = new VillageState(new HouseState(1, 0, 0, new KitchenState())); RootState prevRootState = new RootState( new InventoryState(), + new DungeonState(), villageState, new RelocationState(1, 90, 1, 0, 0) ); diff --git a/backend/app/Savor22b.Tests/Action/PlantingSeedActionTests.cs b/backend/app/Savor22b.Tests/Action/PlantingSeedActionTests.cs index 06d43c02..76384c69 100644 --- a/backend/app/Savor22b.Tests/Action/PlantingSeedActionTests.cs +++ b/backend/app/Savor22b.Tests/Action/PlantingSeedActionTests.cs @@ -95,7 +95,8 @@ public void Execute_InvalidVillageState() InventoryState inventoryState = getInventoryState(); RootState beforeRootState = new RootState( - inventoryState + inventoryState, + new DungeonState() ); beforeState = beforeState.SetState( diff --git a/backend/app/Savor22b.Tests/Action/RemovePlantedSeedActionTests.cs b/backend/app/Savor22b.Tests/Action/RemovePlantedSeedActionTests.cs index deef72b5..bb98eba8 100644 --- a/backend/app/Savor22b.Tests/Action/RemovePlantedSeedActionTests.cs +++ b/backend/app/Savor22b.Tests/Action/RemovePlantedSeedActionTests.cs @@ -19,6 +19,7 @@ public void Execute_Success_Normal() IAccountStateDelta beforeState = new DummyState(); RootState beforeRootState = new RootState( new InventoryState(), + new DungeonState(), new VillageState( new HouseState( 1, 1, 1, new KitchenState() diff --git a/backend/app/Savor22b.Tests/Action/RemoveWeedActionTests.cs b/backend/app/Savor22b.Tests/Action/RemoveWeedActionTests.cs index cd1c790f..904b498d 100644 --- a/backend/app/Savor22b.Tests/Action/RemoveWeedActionTests.cs +++ b/backend/app/Savor22b.Tests/Action/RemoveWeedActionTests.cs @@ -17,6 +17,7 @@ public RootState createRootStatePreset() { RootState beforeRootState = new RootState( new InventoryState(), + new DungeonState(), new VillageState( new HouseState( 1, 1, 1, new KitchenState() diff --git a/backend/app/Savor22b/States/RootState.cs b/backend/app/Savor22b/States/RootState.cs index cff5086d..1ddd5a7e 100644 --- a/backend/app/Savor22b/States/RootState.cs +++ b/backend/app/Savor22b/States/RootState.cs @@ -5,6 +5,7 @@ namespace Savor22b.States; public class RootState : State { public InventoryState InventoryState { get; private set; } + public DungeonState DungeonState { get; private set; } public RelocationState? RelocationState { get; private set; } @@ -13,31 +14,15 @@ public class RootState : State public RootState() { InventoryState = new InventoryState(); + DungeonState = new DungeonState(); VillageState = null; RelocationState = null; } - public RootState(InventoryState inventoryState) + public RootState(InventoryState inventoryState, DungeonState dungeonState, VillageState? villageState = null, RelocationState? relocationState = null) { - InventoryState = inventoryState; - VillageState = null; - RelocationState = null; - } - - public RootState(InventoryState inventoryState, VillageState villageState) - { - InventoryState = inventoryState; - VillageState = villageState; - RelocationState = null; - } - - public RootState( - InventoryState inventoryState, - VillageState villageState, - RelocationState relocationState - ) - { - InventoryState = inventoryState; + InventoryState = inventoryState ?? new InventoryState(); + DungeonState = dungeonState ?? new DungeonState(); VillageState = villageState; RelocationState = relocationState; } @@ -55,6 +40,17 @@ public RootState(Bencodex.Types.Dictionary encoded) InventoryState = new InventoryState(); } + if (encoded.ContainsKey((Text)nameof(DungeonState))) + { + DungeonState = new DungeonState( + (Bencodex.Types.Dictionary)encoded[nameof(DungeonState)] + ); + } + else + { + DungeonState = new DungeonState(); + } + if (encoded.ContainsKey((Text)nameof(VillageState))) { VillageState = new VillageState( @@ -101,6 +97,10 @@ public IValue Serialize() (Text)nameof(InventoryState), InventoryState.Serialize() ), + new KeyValuePair( + (Text)nameof(DungeonState), + DungeonState.Serialize() + ), }; if (RelocationState is not null)