diff --git a/.Lib9c.DevExtensions.Tests/Action/FaucetRuneTest.cs b/.Lib9c.DevExtensions.Tests/Action/FaucetRuneTest.cs index a6ec66ffd4..a363067850 100644 --- a/.Lib9c.DevExtensions.Tests/Action/FaucetRuneTest.cs +++ b/.Lib9c.DevExtensions.Tests/Action/FaucetRuneTest.cs @@ -48,7 +48,7 @@ public FaucetRuneTest(ITestOutputHelper outputHelper) Address agentAddress = new PrivateKey().Address; _avatarAddress = new PrivateKey().Address; var agentState = new AgentState(agentAddress); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( _avatarAddress, agentAddress, 0, diff --git a/.Lib9c.Tests/Action/AccountStateDeltaExtensionsTest.cs b/.Lib9c.Tests/Action/AccountStateDeltaExtensionsTest.cs index 406d048b52..876dab5d00 100644 --- a/.Lib9c.Tests/Action/AccountStateDeltaExtensionsTest.cs +++ b/.Lib9c.Tests/Action/AccountStateDeltaExtensionsTest.cs @@ -30,7 +30,7 @@ public AccountStateDeltaExtensionsTest() _agentState = new AgentState(_agentAddress); _agentState.avatarAddresses[0] = _avatarAddress; _tableSheets = new TableSheets(TableSheetsImporter.ImportSheets()); - _avatarState = new AvatarState( + _avatarState = AvatarState.Create( _avatarAddress, _agentAddress, 0, diff --git a/.Lib9c.Tests/Action/AccountStateViewExtensionsTest.cs b/.Lib9c.Tests/Action/AccountStateViewExtensionsTest.cs index eb71443603..424fd0afe2 100644 --- a/.Lib9c.Tests/Action/AccountStateViewExtensionsTest.cs +++ b/.Lib9c.Tests/Action/AccountStateViewExtensionsTest.cs @@ -37,7 +37,7 @@ public AccountStateViewExtensionsTest() _agentState = new AgentState(_agentAddress); _agentState.avatarAddresses[0] = _avatarAddress; _tableSheets = new TableSheets(TableSheetsImporter.ImportSheets()); - _avatarState = new AvatarState( + _avatarState = AvatarState.Create( _avatarAddress, _agentAddress, 0, diff --git a/.Lib9c.Tests/Action/ActivateCollectionTest.cs b/.Lib9c.Tests/Action/ActivateCollectionTest.cs index 0b5410b570..4e711cb44a 100644 --- a/.Lib9c.Tests/Action/ActivateCollectionTest.cs +++ b/.Lib9c.Tests/Action/ActivateCollectionTest.cs @@ -38,16 +38,15 @@ public ActivateCollectionTest() _avatarAddress = _agentAddress.Derive("avatar"); var gameConfigState = new GameConfigState(sheets[nameof(GameConfigSheet)]); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( _avatarAddress, _agentAddress, 0, _tableSheets.GetAvatarSheets(), default - ) - { - level = 100, - }; + ); + avatarState.level = 100; + agentState.avatarAddresses.Add(0, _avatarAddress); _initialState = new World(MockUtil.MockModernWorldState) diff --git a/.Lib9c.Tests/Action/AdventureBoss/ClaimAdventureBossRewardTest.cs b/.Lib9c.Tests/Action/AdventureBoss/ClaimAdventureBossRewardTest.cs index b9dbdf405e..e50b2360f7 100644 --- a/.Lib9c.Tests/Action/AdventureBoss/ClaimAdventureBossRewardTest.cs +++ b/.Lib9c.Tests/Action/AdventureBoss/ClaimAdventureBossRewardTest.cs @@ -41,9 +41,13 @@ public class ClaimAdventureBossRewardTest private static readonly Address WantedAvatarAddress = Addresses.GetAvatarAddress(WantedAddress, 0); - private static readonly AvatarState WantedAvatarState = new ( - WantedAvatarAddress, WantedAddress, 0L, TableSheets.GetAvatarSheets(), - new PrivateKey().Address, name: "wanted" + private static readonly AvatarState WantedAvatarState = AvatarState.Create( + WantedAvatarAddress, + WantedAddress, + 0L, + TableSheets.GetAvatarSheets(), + new PrivateKey().Address, + name: "wanted" ); private static readonly AgentState WantedState = new (WantedAddress) @@ -58,9 +62,13 @@ public class ClaimAdventureBossRewardTest private static readonly Address ExplorerAvatarAddress = Addresses.GetAvatarAddress(ExplorerAddress, 0); - private static readonly AvatarState ExplorerAvatarState = new ( - ExplorerAvatarAddress, ExplorerAddress, 0L, TableSheets.GetAvatarSheets(), - new PrivateKey().Address, name: "explorer" + private static readonly AvatarState ExplorerAvatarState = AvatarState.Create( + ExplorerAvatarAddress, + ExplorerAddress, + 0L, + TableSheets.GetAvatarSheets(), + new PrivateKey().Address, + name: "explorer" ); private static readonly AgentState ExplorerState = new (ExplorerAddress) @@ -78,9 +86,13 @@ public class ClaimAdventureBossRewardTest private static readonly Address TesterAvatarAddress = Addresses.GetAvatarAddress(TesterAddress, 0); - private static readonly AvatarState TesterAvatarState = new ( - TesterAvatarAddress, TesterAddress, 0L, TableSheets.GetAvatarSheets(), - new PrivateKey().Address, name: "Tester" + private static readonly AvatarState TesterAvatarState = AvatarState.Create( + TesterAvatarAddress, + TesterAddress, + 0L, + TableSheets.GetAvatarSheets(), + new PrivateKey().Address, + name: "Tester" ); private static readonly AgentState TesterState = new (TesterAddress) diff --git a/.Lib9c.Tests/Action/AdventureBoss/ExploreAdventureBossTest.cs b/.Lib9c.Tests/Action/AdventureBoss/ExploreAdventureBossTest.cs index 91d9c797a7..c3e553067f 100644 --- a/.Lib9c.Tests/Action/AdventureBoss/ExploreAdventureBossTest.cs +++ b/.Lib9c.Tests/Action/AdventureBoss/ExploreAdventureBossTest.cs @@ -38,9 +38,13 @@ public class ExploreAdventureBossTest private static readonly Address WantedAvatarAddress = Addresses.GetAvatarAddress(WantedAddress, 0); - private static readonly AvatarState WantedAvatarState = new ( - WantedAvatarAddress, WantedAddress, 0L, TableSheets.GetAvatarSheets(), - new PrivateKey().Address, name: "wanted" + private static readonly AvatarState WantedAvatarState = AvatarState.Create( + WantedAvatarAddress, + WantedAddress, + 0L, + TableSheets.GetAvatarSheets(), + new PrivateKey().Address, + name: "wanted" ); private static readonly AgentState WantedState = new (WantedAddress) @@ -55,10 +59,14 @@ public class ExploreAdventureBossTest private static readonly Address TesterAvatarAddress = Addresses.GetAvatarAddress(TesterAddress, 0); - private static readonly AvatarState TesterAvatarState = new ( - TesterAvatarAddress, TesterAddress, 0L, TableSheets.GetAvatarSheets(), - new PrivateKey().Address, name: "Tester" - ) { level = 500 }; + private static readonly AvatarState TesterAvatarState = AvatarState.Create( + TesterAvatarAddress, + TesterAddress, + 0L, + TableSheets.GetAvatarSheets(), + new PrivateKey().Address, + name: "Tester" + ); private static readonly AgentState TesterState = new (TesterAddress) { @@ -80,6 +88,11 @@ public class ExploreAdventureBossTest .SetAgentState(TesterAddress, TesterState) .MintAsset(new ActionContext(), WantedAddress, 1_000_000 * NCG); + static ExploreAdventureBossTest() + { + TesterAvatarState.level = 500; + } + public ExploreAdventureBossTest() { var collectionSheet = TableSheets.CollectionSheet; diff --git a/.Lib9c.Tests/Action/AdventureBoss/SweepAdventureBossTest.cs b/.Lib9c.Tests/Action/AdventureBoss/SweepAdventureBossTest.cs index 1dede794e6..a037c84065 100644 --- a/.Lib9c.Tests/Action/AdventureBoss/SweepAdventureBossTest.cs +++ b/.Lib9c.Tests/Action/AdventureBoss/SweepAdventureBossTest.cs @@ -37,9 +37,13 @@ public class SweepAdventureBossTest private static readonly Address WantedAvatarAddress = Addresses.GetAvatarAddress(WantedAddress, 0); - private static readonly AvatarState WantedAvatarState = new ( - WantedAvatarAddress, WantedAddress, 0L, TableSheets.GetAvatarSheets(), - new PrivateKey().Address, name: "wanted" + private static readonly AvatarState WantedAvatarState = AvatarState.Create( + WantedAvatarAddress, + WantedAddress, + 0L, + TableSheets.GetAvatarSheets(), + new PrivateKey().Address, + name: "wanted" ); private static readonly AgentState WantedState = new (WantedAddress) @@ -54,9 +58,13 @@ public class SweepAdventureBossTest private static readonly Address TesterAvatarAddress = Addresses.GetAvatarAddress(TesterAddress, 0); - private static readonly AvatarState TesterAvatarState = new ( - TesterAvatarAddress, TesterAddress, 0L, TableSheets.GetAvatarSheets(), - new PrivateKey().Address, name: "Tester" + private static readonly AvatarState TesterAvatarState = AvatarState.Create( + TesterAvatarAddress, + TesterAddress, + 0L, + TableSheets.GetAvatarSheets(), + new PrivateKey().Address, + name: "Tester" ); private static readonly AgentState TesterState = new (TesterAddress) diff --git a/.Lib9c.Tests/Action/AdventureBoss/UnlockFloorTest.cs b/.Lib9c.Tests/Action/AdventureBoss/UnlockFloorTest.cs index 619761c788..80b2f201b1 100644 --- a/.Lib9c.Tests/Action/AdventureBoss/UnlockFloorTest.cs +++ b/.Lib9c.Tests/Action/AdventureBoss/UnlockFloorTest.cs @@ -35,9 +35,13 @@ public class UnlockFloorTest private static readonly Address WantedAvatarAddress = Addresses.GetAvatarAddress(WantedAddress, 0); - private static readonly AvatarState WantedAvatarState = new ( - WantedAvatarAddress, WantedAddress, 0L, TableSheets.GetAvatarSheets(), - new PrivateKey().Address, name: "wanted" + private static readonly AvatarState WantedAvatarState = AvatarState.Create( + WantedAvatarAddress, + WantedAddress, + 0L, + TableSheets.GetAvatarSheets(), + new PrivateKey().Address, + name: "wanted" ); private static readonly AgentState WantedState = new (WantedAddress) @@ -52,9 +56,13 @@ public class UnlockFloorTest private static readonly Address TesterAvatarAddress = Addresses.GetAvatarAddress(TesterAddress, 0); - private static readonly AvatarState TesterAvatarState = new ( - TesterAvatarAddress, TesterAddress, 0L, TableSheets.GetAvatarSheets(), - new PrivateKey().Address, name: "Tester" + private static readonly AvatarState TesterAvatarState = AvatarState.Create( + TesterAvatarAddress, + TesterAddress, + 0L, + TableSheets.GetAvatarSheets(), + new PrivateKey().Address, + name: "Tester" ); private static readonly AgentState TesterState = new (TesterAddress) diff --git a/.Lib9c.Tests/Action/AdventureBoss/WantedTest.cs b/.Lib9c.Tests/Action/AdventureBoss/WantedTest.cs index 280a512581..d156fd2c89 100644 --- a/.Lib9c.Tests/Action/AdventureBoss/WantedTest.cs +++ b/.Lib9c.Tests/Action/AdventureBoss/WantedTest.cs @@ -35,8 +35,11 @@ public class WantedTest private static readonly Address AgentAddress = new PrivateKey().Address; private static readonly Address AvatarAddress = Addresses.GetAvatarAddress(AgentAddress, 0); - private static readonly AvatarState AvatarState = new ( - AvatarAddress, AgentAddress, 0L, TableSheets.GetAvatarSheets(), + private static readonly AvatarState AvatarState = AvatarState.Create( + AvatarAddress, + AgentAddress, + 0L, + TableSheets.GetAvatarSheets(), new PrivateKey().Address, name: "avatar1" ); @@ -44,8 +47,11 @@ public class WantedTest private static readonly Address AvatarAddress2 = Addresses.GetAvatarAddress(AgentAddress, 1); - private static readonly AvatarState AvatarState2 = new ( - AvatarAddress2, AgentAddress, 0L, TableSheets.GetAvatarSheets(), + private static readonly AvatarState AvatarState2 = AvatarState.Create( + AvatarAddress2, + AgentAddress, + 0L, + TableSheets.GetAvatarSheets(), new PrivateKey().Address, name: "avatar2" ); diff --git a/.Lib9c.Tests/Action/ArenahelperTest.cs b/.Lib9c.Tests/Action/ArenahelperTest.cs index cb0dd4ad3b..c97dbd1313 100644 --- a/.Lib9c.Tests/Action/ArenahelperTest.cs +++ b/.Lib9c.Tests/Action/ArenahelperTest.cs @@ -92,18 +92,17 @@ public static (AgentState AgentState, AvatarState AvatarState) GetAgentStateWith var agentState = new AgentState(agentAddress); var avatarAddress = agentAddress.Derive("avatar"); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( avatarAddress, agentAddress, 0, tableSheets.GetAvatarSheets(), - rankingMapAddress) - { - worldInformation = new WorldInformation( - 0, - tableSheets.WorldSheet, - clearStageId), - }; + rankingMapAddress); + avatarState.worldInformation = new WorldInformation( + 0, + tableSheets.WorldSheet, + clearStageId); + agentState.avatarAddresses.Add(0, avatarAddress); return (agentState, avatarState); diff --git a/.Lib9c.Tests/Action/BattleArenaTest.cs b/.Lib9c.Tests/Action/BattleArenaTest.cs index 5fd8704add..0eedec51d4 100644 --- a/.Lib9c.Tests/Action/BattleArenaTest.cs +++ b/.Lib9c.Tests/Action/BattleArenaTest.cs @@ -1061,18 +1061,17 @@ private static (AgentState AgentState, AvatarState AvatarState) GetAgentStateWit var agentState = new AgentState(agentAddress); var avatarAddress = agentAddress.Derive("avatar"); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( avatarAddress, agentAddress, 0, tableSheets.GetAvatarSheets(), - rankingMapAddress) - { - worldInformation = new WorldInformation( - 0, - tableSheets.WorldSheet, - clearStageId), - }; + rankingMapAddress); + avatarState.worldInformation = new WorldInformation( + 0, + tableSheets.WorldSheet, + clearStageId); + agentState.avatarAddresses.Add(0, avatarAddress); return (agentState, avatarState); diff --git a/.Lib9c.Tests/Action/BuyMultipleTest.cs b/.Lib9c.Tests/Action/BuyMultipleTest.cs index be32c44547..93ab015891 100644 --- a/.Lib9c.Tests/Action/BuyMultipleTest.cs +++ b/.Lib9c.Tests/Action/BuyMultipleTest.cs @@ -58,18 +58,17 @@ public BuyMultipleTest(ITestOutputHelper outputHelper) var buyerAgentState = new AgentState(_buyerAgentAddress); _buyerAvatarAddress = new PrivateKey().Address; var rankingMapAddress = new PrivateKey().Address; - _buyerAvatarState = new AvatarState( + _buyerAvatarState = AvatarState.Create( _buyerAvatarAddress, _buyerAgentAddress, 0, _tableSheets.GetAvatarSheets(), - rankingMapAddress) - { - worldInformation = new WorldInformation( - 0, - _tableSheets.WorldSheet, - GameConfig.RequireClearedStageLevel.ActionsInShop), - }; + rankingMapAddress); + _buyerAvatarState.worldInformation = new WorldInformation( + 0, + _tableSheets.WorldSheet, + GameConfig.RequireClearedStageLevel.ActionsInShop); + buyerAgentState.avatarAddresses[0] = _buyerAvatarAddress; var shopState = new ShopState(); @@ -613,18 +612,17 @@ public void ExecuteThrowShopItemExpiredError() var agentState = new AgentState(agentAddress); var rankingMapAddress = new PrivateKey().Address; - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( avatarAddress, agentAddress, 0, _tableSheets.GetAvatarSheets(), - rankingMapAddress) - { - worldInformation = new WorldInformation( - 0, - _tableSheets.WorldSheet, - GameConfig.RequireClearedStageLevel.ActionsInShop), - }; + rankingMapAddress); + avatarState.worldInformation = new WorldInformation( + 0, + _tableSheets.WorldSheet, + GameConfig.RequireClearedStageLevel.ActionsInShop); + agentState.avatarAddresses[0] = avatarAddress; _sellerAgentStateMap[avatarState] = agentState; diff --git a/.Lib9c.Tests/Action/BuyProductTest.cs b/.Lib9c.Tests/Action/BuyProductTest.cs index b2b4e29be2..630d7af1c6 100644 --- a/.Lib9c.Tests/Action/BuyProductTest.cs +++ b/.Lib9c.Tests/Action/BuyProductTest.cs @@ -62,50 +62,47 @@ public BuyProductTest(ITestOutputHelper outputHelper) var sellerAgentState = new AgentState(SellerAgentAddress); var rankingMapAddress = new PrivateKey().Address; - var sellerAvatarState = new AvatarState( + var sellerAvatarState = AvatarState.Create( SellerAvatarAddress, SellerAgentAddress, 0, TableSheets.GetAvatarSheets(), - rankingMapAddress) - { - worldInformation = new WorldInformation( - 0, - TableSheets.WorldSheet, - GameConfig.RequireClearedStageLevel.ActionsInShop), - }; + rankingMapAddress); + sellerAvatarState.worldInformation = new WorldInformation( + 0, + TableSheets.WorldSheet, + GameConfig.RequireClearedStageLevel.ActionsInShop); + sellerAgentState.avatarAddresses[0] = SellerAvatarAddress; _sellerAgentAddress2 = new PrivateKey().Address; var agentState2 = new AgentState(_sellerAgentAddress2); _sellerAvatarAddress2 = new PrivateKey().Address; - var sellerAvatarState2 = new AvatarState( + var sellerAvatarState2 = AvatarState.Create( _sellerAvatarAddress2, _sellerAgentAddress2, 0, TableSheets.GetAvatarSheets(), - rankingMapAddress) - { - worldInformation = new WorldInformation( - 0, - TableSheets.WorldSheet, - GameConfig.RequireClearedStageLevel.ActionsInShop), - }; + rankingMapAddress); + sellerAvatarState2.worldInformation = new WorldInformation( + 0, + TableSheets.WorldSheet, + GameConfig.RequireClearedStageLevel.ActionsInShop); + agentState2.avatarAddresses[0] = _sellerAvatarAddress2; var buyerAgentState = new AgentState(BuyerAgentAddress); - _buyerAvatarState = new AvatarState( + _buyerAvatarState = AvatarState.Create( BuyerAvatarAddress, BuyerAgentAddress, 0, TableSheets.GetAvatarSheets(), - rankingMapAddress) - { - worldInformation = new WorldInformation( - 0, - TableSheets.WorldSheet, - GameConfig.RequireClearedStageLevel.ActionsInShop), - }; + rankingMapAddress); + _buyerAvatarState.worldInformation = new WorldInformation( + 0, + TableSheets.WorldSheet, + GameConfig.RequireClearedStageLevel.ActionsInShop); + buyerAgentState.avatarAddresses[0] = BuyerAvatarAddress; _orderId = new Guid("6d460c1a-755d-48e4-ad67-65d5f519dbc8"); diff --git a/.Lib9c.Tests/Action/BuyTest.cs b/.Lib9c.Tests/Action/BuyTest.cs index 9239d40cd5..446209e98d 100644 --- a/.Lib9c.Tests/Action/BuyTest.cs +++ b/.Lib9c.Tests/Action/BuyTest.cs @@ -67,35 +67,33 @@ public BuyTest(ITestOutputHelper outputHelper) var sellerAgentState = new AgentState(_sellerAgentAddress); _sellerAvatarAddress = new PrivateKey().Address; var rankingMapAddress = new PrivateKey().Address; - var sellerAvatarState = new AvatarState( + var sellerAvatarState = AvatarState.Create( _sellerAvatarAddress, _sellerAgentAddress, 0, _tableSheets.GetAvatarSheets(), - rankingMapAddress) - { - worldInformation = new WorldInformation( - 0, - _tableSheets.WorldSheet, - GameConfig.RequireClearedStageLevel.ActionsInShop), - }; + rankingMapAddress); + sellerAvatarState.worldInformation = new WorldInformation( + 0, + _tableSheets.WorldSheet, + GameConfig.RequireClearedStageLevel.ActionsInShop); + sellerAgentState.avatarAddresses[0] = _sellerAvatarAddress; _buyerAgentAddress = new PrivateKey().Address; var buyerAgentState = new AgentState(_buyerAgentAddress); _buyerAvatarAddress = new PrivateKey().Address; - _buyerAvatarState = new AvatarState( + _buyerAvatarState = AvatarState.Create( _buyerAvatarAddress, _buyerAgentAddress, 0, _tableSheets.GetAvatarSheets(), - rankingMapAddress) - { - worldInformation = new WorldInformation( - 0, - _tableSheets.WorldSheet, - GameConfig.RequireClearedStageLevel.ActionsInShop), - }; + rankingMapAddress); + _buyerAvatarState.worldInformation = new WorldInformation( + 0, + _tableSheets.WorldSheet, + GameConfig.RequireClearedStageLevel.ActionsInShop); + buyerAgentState.avatarAddresses[0] = _buyerAvatarAddress; _orderId = new Guid("6d460c1a-755d-48e4-ad67-65d5f519dbc8"); @@ -965,18 +963,17 @@ public void Execute_With_Testbed() var agentState = new AgentState(agentAddress); var rankingMapAddress = new PrivateKey().Address; - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( avatarAddress, agentAddress, 0, _tableSheets.GetAvatarSheets(), - rankingMapAddress) - { - worldInformation = new WorldInformation( - 0, - _tableSheets.WorldSheet, - GameConfig.RequireClearedStageLevel.ActionsInShop), - }; + rankingMapAddress); + avatarState.worldInformation = new WorldInformation( + 0, + _tableSheets.WorldSheet, + GameConfig.RequireClearedStageLevel.ActionsInShop); + agentState.avatarAddresses[0] = avatarAddress; _initialState = _initialState diff --git a/.Lib9c.Tests/Action/CancelProductRegistrationTest.cs b/.Lib9c.Tests/Action/CancelProductRegistrationTest.cs index 1fda194350..6ab1c35c77 100644 --- a/.Lib9c.Tests/Action/CancelProductRegistrationTest.cs +++ b/.Lib9c.Tests/Action/CancelProductRegistrationTest.cs @@ -55,18 +55,17 @@ public CancelProductRegistrationTest(ITestOutputHelper outputHelper) _avatarAddress = new PrivateKey().Address; _gameConfigState = new GameConfigState((Text)_tableSheets.GameConfigSheet.Serialize()); var rankingMapAddress = new PrivateKey().Address; - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( _avatarAddress, _agentAddress, 0, _tableSheets.GetAvatarSheets(), - rankingMapAddress) - { - worldInformation = new WorldInformation( - 0, - _tableSheets.WorldSheet, - GameConfig.RequireClearedStageLevel.ActionsInShop), - }; + rankingMapAddress); + avatarState.worldInformation = new WorldInformation( + 0, + _tableSheets.WorldSheet, + GameConfig.RequireClearedStageLevel.ActionsInShop); + agentState.avatarAddresses[0] = _avatarAddress; _initialState = _initialState diff --git a/.Lib9c.Tests/Action/ChargeActionPointTest.cs b/.Lib9c.Tests/Action/ChargeActionPointTest.cs index 5179a06572..82fcd1e7e1 100644 --- a/.Lib9c.Tests/Action/ChargeActionPointTest.cs +++ b/.Lib9c.Tests/Action/ChargeActionPointTest.cs @@ -34,7 +34,7 @@ public ChargeActionPointTest() _avatarAddress = _agentAddress.Derive("avatar"); var gameConfigState = new GameConfigState(_sheets[nameof(GameConfigSheet)]); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( _avatarAddress, _agentAddress, 0, diff --git a/.Lib9c.Tests/Action/ClaimItemsTest.cs b/.Lib9c.Tests/Action/ClaimItemsTest.cs index 93a9e2482c..b6d24032e5 100644 --- a/.Lib9c.Tests/Action/ClaimItemsTest.cs +++ b/.Lib9c.Tests/Action/ClaimItemsTest.cs @@ -330,18 +330,17 @@ private IWorld GenerateAvatar(IWorld state, out Address avatarAddress, out Addre var agentState = new AgentState(agentAddress); avatarAddress = agentAddress.Derive("avatar"); var rankingMapAddress = new PrivateKey().Address; - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( avatarAddress, agentAddress, 0, _tableSheets.GetAvatarSheets(), - rankingMapAddress) - { - worldInformation = new WorldInformation( - 0, - _tableSheets.WorldSheet, - GameConfig.RequireClearedStageLevel.ActionsInShop), - }; + rankingMapAddress); + avatarState.worldInformation = new WorldInformation( + 0, + _tableSheets.WorldSheet, + GameConfig.RequireClearedStageLevel.ActionsInShop); + agentState.avatarAddresses[0] = avatarAddress; state = state diff --git a/.Lib9c.Tests/Action/ClaimWorldBossKillRewardTest.cs b/.Lib9c.Tests/Action/ClaimWorldBossKillRewardTest.cs index 798357267f..ff8f064314 100644 --- a/.Lib9c.Tests/Action/ClaimWorldBossKillRewardTest.cs +++ b/.Lib9c.Tests/Action/ClaimWorldBossKillRewardTest.cs @@ -57,7 +57,7 @@ public void Execute(long blockIndex, Type exc) var rankingMapAddress = avatarAddress.Derive("ranking_map"); var gameConfigState = new GameConfigState(sheets[nameof(GameConfigSheet)]); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( avatarAddress, agentAddress, 0, diff --git a/.Lib9c.Tests/Action/CombinationConsumableTest.cs b/.Lib9c.Tests/Action/CombinationConsumableTest.cs index 633b13de50..06cc4bf9d2 100644 --- a/.Lib9c.Tests/Action/CombinationConsumableTest.cs +++ b/.Lib9c.Tests/Action/CombinationConsumableTest.cs @@ -42,7 +42,7 @@ public CombinationConsumableTest() var agentState = new AgentState(_agentAddress); agentState.avatarAddresses[0] = _avatarAddress; - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( _avatarAddress, _agentAddress, 1, diff --git a/.Lib9c.Tests/Action/CombinationEquipmentTest.cs b/.Lib9c.Tests/Action/CombinationEquipmentTest.cs index 9949e93ef2..b46ec22dc8 100644 --- a/.Lib9c.Tests/Action/CombinationEquipmentTest.cs +++ b/.Lib9c.Tests/Action/CombinationEquipmentTest.cs @@ -60,7 +60,7 @@ public CombinationEquipmentTest(ITestOutputHelper outputHelper) var gameConfigState = new GameConfigState(); - _avatarState = new AvatarState( + _avatarState = AvatarState.Create( _avatarAddress, _agentAddress, 1, diff --git a/.Lib9c.Tests/Action/CreateAvatarTest.cs b/.Lib9c.Tests/Action/CreateAvatarTest.cs index 8e612d8b25..ac6edaede0 100644 --- a/.Lib9c.Tests/Action/CreateAvatarTest.cs +++ b/.Lib9c.Tests/Action/CreateAvatarTest.cs @@ -143,7 +143,7 @@ public void ExecuteThrowInvalidAddressException() ) ); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( avatarAddress, _agentAddress, 0, @@ -244,7 +244,7 @@ public void AddItem() 10512000,2 600201,2 "); - var avatarState = new AvatarState(default, default, 0L, _tableSheets.GetAvatarSheets(), default, "test"); + var avatarState = AvatarState.Create(default, default, 0L, _tableSheets.GetAvatarSheets(), default, "test"); CreateAvatar.AddItem(itemSheet, createAvatarItemSheet, avatarState, new TestRandom()); foreach (var row in createAvatarItemSheet.Values) { @@ -269,7 +269,7 @@ public void MintAsset() "); var avatarAddress = new PrivateKey().Address; var agentAddress = new PrivateKey().Address; - var avatarState = new AvatarState(avatarAddress, agentAddress, 0L, _tableSheets.GetAvatarSheets(), default, "test"); + var avatarState = AvatarState.Create(avatarAddress, agentAddress, 0L, _tableSheets.GetAvatarSheets(), default, "test"); var nextState = CreateAvatar.MintAsset(createAvatarFavSheet, avatarState, new World(MockUtil.MockModernWorldState), new ActionContext()); foreach (var row in createAvatarFavSheet.Values) { diff --git a/.Lib9c.Tests/Action/CustomEquipmentCraft/CustomEquipmentCraftTest.cs b/.Lib9c.Tests/Action/CustomEquipmentCraft/CustomEquipmentCraftTest.cs index e584e1ab5f..adf0ddb566 100644 --- a/.Lib9c.Tests/Action/CustomEquipmentCraft/CustomEquipmentCraftTest.cs +++ b/.Lib9c.Tests/Action/CustomEquipmentCraft/CustomEquipmentCraftTest.cs @@ -56,7 +56,7 @@ public CustomEquipmentCraftTest() }, }; - _avatarState = new AvatarState( + _avatarState = AvatarState.Create( _avatarAddress, _agentAddress, 0, _tableSheets.GetAvatarSheets(), default ); #pragma warning disable CS0618 diff --git a/.Lib9c.Tests/Action/EventConsumableItemCraftsTest.cs b/.Lib9c.Tests/Action/EventConsumableItemCraftsTest.cs index 3f9d1f5f85..1372340386 100644 --- a/.Lib9c.Tests/Action/EventConsumableItemCraftsTest.cs +++ b/.Lib9c.Tests/Action/EventConsumableItemCraftsTest.cs @@ -42,16 +42,14 @@ public EventConsumableItemCraftsTest() agentState.avatarAddresses.Add(0, _avatarAddress); var gameConfigState = new GameConfigState(sheets[nameof(GameConfigSheet)]); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( _avatarAddress, _agentAddress, 0, _tableSheets.GetAvatarSheets(), new PrivateKey().Address - ) - { - level = 100, - }; + ); + avatarState.level = 100; var allSlotState = new AllCombinationSlotState(); for (var i = 0; i < AvatarState.DefaultCombinationSlotCount; i++) diff --git a/.Lib9c.Tests/Action/EventDungeonBattleTest.cs b/.Lib9c.Tests/Action/EventDungeonBattleTest.cs index 316be6ad7e..9106b46ca2 100644 --- a/.Lib9c.Tests/Action/EventDungeonBattleTest.cs +++ b/.Lib9c.Tests/Action/EventDungeonBattleTest.cs @@ -56,16 +56,14 @@ public EventDungeonBattleTest() agentState.avatarAddresses.Add(0, _avatarAddress); var gameConfigState = new GameConfigState(sheets[nameof(GameConfigSheet)]); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( _avatarAddress, _agentAddress, 0, _tableSheets.GetAvatarSheets(), new PrivateKey().Address - ) - { - level = 100, - }; + ); + avatarState.level = 100; _initialStates = _initialStates .SetAgentState(_agentAddress, agentState) diff --git a/.Lib9c.Tests/Action/EventMaterialItemCraftsTest.cs b/.Lib9c.Tests/Action/EventMaterialItemCraftsTest.cs index 3ea9ccdaa7..48745fa44d 100644 --- a/.Lib9c.Tests/Action/EventMaterialItemCraftsTest.cs +++ b/.Lib9c.Tests/Action/EventMaterialItemCraftsTest.cs @@ -45,16 +45,14 @@ public EventMaterialItemCraftsTest() agentState.avatarAddresses.Add(0, _avatarAddress); var gameConfigState = new GameConfigState(sheets[nameof(GameConfigSheet)]); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( _avatarAddress, _agentAddress, 0, _tableSheets.GetAvatarSheets(), new PrivateKey().Address - ) - { - level = 100, - }; + ); + avatarState.level = 100; _initialStates = _initialStates .SetAgentState(_agentAddress, agentState) diff --git a/.Lib9c.Tests/Action/GrindingTest.cs b/.Lib9c.Tests/Action/GrindingTest.cs index 49bb4e8a85..73dd5f6e8c 100644 --- a/.Lib9c.Tests/Action/GrindingTest.cs +++ b/.Lib9c.Tests/Action/GrindingTest.cs @@ -45,7 +45,7 @@ public GrindingTest() var gameConfigState = new GameConfigState(sheets[nameof(GameConfigSheet)]); _agentState = new AgentState(_agentAddress); - _avatarState = new AvatarState( + _avatarState = AvatarState.Create( _avatarAddress, _agentAddress, 0, diff --git a/.Lib9c.Tests/Action/HackAndSlashRandomBuffTest.cs b/.Lib9c.Tests/Action/HackAndSlashRandomBuffTest.cs index 35794e57d4..969a34a2c1 100644 --- a/.Lib9c.Tests/Action/HackAndSlashRandomBuffTest.cs +++ b/.Lib9c.Tests/Action/HackAndSlashRandomBuffTest.cs @@ -50,16 +50,15 @@ public HackAndSlashRandomBuffTest() var gameConfigState = new GameConfigState(_sheets[nameof(GameConfigSheet)]); _rankingMapAddress = _avatarAddress.Derive("ranking_map"); _currency = CrystalCalculator.CRYSTAL; - _avatarState = new AvatarState( + _avatarState = AvatarState.Create( _avatarAddress, _agentAddress, 0, _tableSheets.GetAvatarSheets(), _rankingMapAddress - ) - { - level = 100, - }; + ); + _avatarState.level = 100; + agentState.avatarAddresses.Add(0, _avatarAddress); _weeklyArenaState = new WeeklyArenaState(0); @@ -95,17 +94,16 @@ public void Execute(int stageId, bool advancedGacha, int balance, int gatheredSt var context = new ActionContext(); var states = _initialState.MintAsset(context, _agentAddress, balance * _currency); var gameConfigState = _initialState.GetGameConfigState(); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( _avatarAddress, _agentAddress, 0, _initialState.GetAvatarSheets(), - _rankingMapAddress) - { - worldInformation = - new WorldInformation(0, _initialState.GetSheet(), stageId), - level = 400, - }; + _rankingMapAddress); + avatarState.worldInformation = + new WorldInformation(0, _initialState.GetSheet(), stageId); + avatarState.level = 400; + var gachaStateAddress = Addresses.GetSkillStateAddressFromAvatarAddress(_avatarAddress); var gachaState = new CrystalRandomSkillState(gachaStateAddress, stageId); states = states.SetAvatarState(_avatarAddress, avatarState); @@ -156,17 +154,16 @@ public void ContainMinimumBuffRank(bool advancedGacha, CrystalRandomBuffSheet.Ro var context = new ActionContext(); var states = _initialState.MintAsset(context, _agentAddress, 100_000_000 * _currency); var gameConfigState = _initialState.GetGameConfigState(); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( _avatarAddress, _agentAddress, 0, _initialState.GetAvatarSheets(), - _rankingMapAddress) - { - worldInformation = - new WorldInformation(0, _initialState.GetSheet(), 1), - level = 400, - }; + _rankingMapAddress); + avatarState.worldInformation = + new WorldInformation(0, _initialState.GetSheet(), 1); + avatarState.level = 400; + var gachaStateAddress = Addresses.GetSkillStateAddressFromAvatarAddress(_avatarAddress); var gachaState = new CrystalRandomSkillState(gachaStateAddress, 1); states = states.SetAvatarState(_avatarAddress, avatarState); diff --git a/.Lib9c.Tests/Action/HackAndSlashSweepTest.cs b/.Lib9c.Tests/Action/HackAndSlashSweepTest.cs index e476a7cfda..dbc7515b9e 100644 --- a/.Lib9c.Tests/Action/HackAndSlashSweepTest.cs +++ b/.Lib9c.Tests/Action/HackAndSlashSweepTest.cs @@ -50,16 +50,15 @@ public HackAndSlashSweepTest() _avatarAddress = _agentAddress.Derive("avatar"); var gameConfigState = new GameConfigState(_sheets[nameof(GameConfigSheet)]); _rankingMapAddress = _avatarAddress.Derive("ranking_map"); - _avatarState = new AvatarState( + _avatarState = AvatarState.Create( _avatarAddress, _agentAddress, 0, _tableSheets.GetAvatarSheets(), _rankingMapAddress - ) - { - level = 100, - }; + ); + _avatarState.level = 100; + agentState.avatarAddresses.Add(0, _avatarAddress); #pragma warning disable CS0618 @@ -230,16 +229,14 @@ public void Execute_InvalidStageException(int clearedWorldId, int clearedStageId public void Execute_InvalidWorldException(int worldId, int stageId, bool unlockedIdsExist) { var gameConfigState = new GameConfigState(_sheets[nameof(GameConfigSheet)]); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( _avatarAddress, _agentAddress, 0, _initialState.GetAvatarSheets(), - _rankingMapAddress) - { - worldInformation = - new WorldInformation(0, _initialState.GetSheet(), 10000001), - }; + _rankingMapAddress); + avatarState.worldInformation = + new WorldInformation(0, _initialState.GetSheet(), 10000001); IWorld state = _initialState.SetAvatarState(_avatarAddress, avatarState); @@ -272,16 +269,14 @@ public void Execute_InvalidWorldException(int worldId, int stageId, bool unlocke public void Execute_UsageLimitExceedException() { var gameConfigState = new GameConfigState(_sheets[nameof(GameConfigSheet)]); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( _avatarAddress, _agentAddress, 0, _initialState.GetAvatarSheets(), - _rankingMapAddress) - { - worldInformation = - new WorldInformation(0, _initialState.GetSheet(), 25), - }; + _rankingMapAddress); + avatarState.worldInformation = + new WorldInformation(0, _initialState.GetSheet(), 25); IWorld state = _initialState.SetAvatarState(_avatarAddress, avatarState); @@ -308,17 +303,15 @@ public void Execute_UsageLimitExceedException() public void Execute_NotEnoughMaterialException(int useApStoneCount, int holdingApStoneCount) { var gameConfigState = _initialState.GetGameConfigState(); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( _avatarAddress, _agentAddress, 0, _initialState.GetAvatarSheets(), - _rankingMapAddress) - { - worldInformation = - new WorldInformation(0, _initialState.GetSheet(), 25), - level = 400, - }; + _rankingMapAddress); + avatarState.worldInformation = + new WorldInformation(0, _initialState.GetSheet(), 25); + avatarState.level = 400; var row = _tableSheets.MaterialItemSheet.Values.First(r => r.ItemSubType == ItemSubType.ApStone); @@ -368,17 +361,15 @@ public void Execute_NotEnoughMaterialException(int useApStoneCount, int holdingA public void Execute_NotEnoughActionPointException() { var gameConfigState = _initialState.GetGameConfigState(); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( _avatarAddress, _agentAddress, 0, _initialState.GetAvatarSheets(), - _rankingMapAddress) - { - worldInformation = - new WorldInformation(0, _initialState.GetSheet(), 25), - level = 400, - }; + _rankingMapAddress); + avatarState.worldInformation = + new WorldInformation(0, _initialState.GetSheet(), 25); + avatarState.level = 400; IWorld state = _initialState.SetAvatarState(_avatarAddress, avatarState) .SetActionPoint(_avatarAddress, 0); @@ -424,17 +415,15 @@ public void Execute_NotEnoughActionPointException() public void Execute_PlayCountIsZeroException() { var gameConfigState = _initialState.GetGameConfigState(); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( _avatarAddress, _agentAddress, 0, _initialState.GetAvatarSheets(), - _rankingMapAddress) - { - worldInformation = - new WorldInformation(0, _initialState.GetSheet(), 25), - level = 400, - }; + _rankingMapAddress); + avatarState.worldInformation = + new WorldInformation(0, _initialState.GetSheet(), 25); + avatarState.level = 400; IWorld state = _initialState.SetAvatarState(_avatarAddress, avatarState) .SetActionPoint(_avatarAddress, 0); @@ -480,17 +469,15 @@ public void Execute_PlayCountIsZeroException() public void Execute_NotEnoughCombatPointException() { var gameConfigState = _initialState.GetGameConfigState(); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( _avatarAddress, _agentAddress, 0, _initialState.GetAvatarSheets(), - _rankingMapAddress) - { - worldInformation = - new WorldInformation(0, _initialState.GetSheet(), 25), - level = 1, - }; + _rankingMapAddress); + avatarState.worldInformation = + new WorldInformation(0, _initialState.GetSheet(), 25); + avatarState.level = 1; IWorld state = _initialState.SetAvatarState(_avatarAddress, avatarState) .SetActionPoint(_avatarAddress, 0); @@ -543,17 +530,16 @@ public void ExecuteWithStake(int stakingLevel) const int worldId = 1; const int stageId = 1; var gameConfigState = _initialState.GetGameConfigState(); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( _avatarAddress, _agentAddress, 0, _initialState.GetAvatarSheets(), - _rankingMapAddress) - { - worldInformation = - new WorldInformation(0, _initialState.GetSheet(), 25), - level = 3, - }; + _rankingMapAddress); + avatarState.worldInformation = + new WorldInformation(0, _initialState.GetSheet(), 25); + avatarState.level = 3; + var itemRow = _tableSheets.MaterialItemSheet.Values.First(r => r.ItemSubType == ItemSubType.ApStone); var apStone = ItemFactory.CreateTradableMaterial(itemRow); @@ -620,17 +606,16 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 const int worldId = 1; const int stageId = 1; var gameConfigState = _initialState.GetGameConfigState(); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( _avatarAddress, _agentAddress, 0, _initialState.GetAvatarSheets(), - _rankingMapAddress) - { - worldInformation = - new WorldInformation(0, _initialState.GetSheet(), 25), - level = 3, - }; + _rankingMapAddress); + avatarState.worldInformation = + new WorldInformation(0, _initialState.GetSheet(), 25); + avatarState.level = 3; + var itemRow = _tableSheets.MaterialItemSheet.Values.First(r => r.ItemSubType == ItemSubType.ApStone); var apStone = ItemFactory.CreateTradableMaterial(itemRow); @@ -713,17 +698,15 @@ public void ExecuteDuplicatedException(int slotIndex, int runeId, int slotIndex2 [InlineData(int.MinValue + 1, 0)] public void Execute_ArgumentOutOfRangeException(int ap, int apPotion) { - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( _avatarAddress, _agentAddress, 0, _initialState.GetAvatarSheets(), - _rankingMapAddress) - { - worldInformation = - new WorldInformation(0, _initialState.GetSheet(), 25), - level = 400, - }; + _rankingMapAddress); + avatarState.worldInformation = + new WorldInformation(0, _initialState.GetSheet(), 25); + avatarState.level = 400; IWorld state = _initialState.SetAvatarState(_avatarAddress, avatarState) .SetActionPoint(_avatarAddress, 0); diff --git a/.Lib9c.Tests/Action/HackAndSlashTest.cs b/.Lib9c.Tests/Action/HackAndSlashTest.cs index 0b9973571d..792495826c 100644 --- a/.Lib9c.Tests/Action/HackAndSlashTest.cs +++ b/.Lib9c.Tests/Action/HackAndSlashTest.cs @@ -59,16 +59,15 @@ public HackAndSlashTest() _avatarAddress = _agentAddress.Derive("avatar"); var gameConfigState = new GameConfigState(_sheets[nameof(GameConfigSheet)]); _rankingMapAddress = _avatarAddress.Derive("ranking_map"); - _avatarState = new AvatarState( + _avatarState = AvatarState.Create( _avatarAddress, _agentAddress, 0, _tableSheets.GetAvatarSheets(), _rankingMapAddress - ) - { - level = 100, - }; + ); + _avatarState.level = 100; + _inventoryAddress = _avatarAddress.Derive(LegacyInventoryKey); _worldInformationAddress = _avatarAddress.Derive(LegacyWorldInformationKey); _questListAddress = _avatarAddress.Derive(LegacyQuestListKey); @@ -212,17 +211,16 @@ public void Execute_With_UpdateQuestList(int worldId, int stageId) var targetRow = worldQuestSheet.OrderedList.FirstOrDefault(e => e.Goal == stageId); Assert.NotNull(targetRow); // Update new AvatarState - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( _avatarAddress, _agentAddress, 0, state.GetAvatarSheets(), - _rankingMapAddress) - { - level = 400, - exp = state.GetSheet().OrderedList.First(e => e.Level == 400).Exp, - worldInformation = new WorldInformation(0, state.GetSheet(), stageId), - }; + _rankingMapAddress); + avatarState.level = 400; + avatarState.exp = state.GetSheet().OrderedList.First(e => e.Level == 400).Exp; + avatarState.worldInformation = new WorldInformation(0, state.GetSheet(), stageId); + var equipments = Doomfist.GetAllParts(_tableSheets, avatarState.level); foreach (var equipment in equipments) { diff --git a/.Lib9c.Tests/Action/ItemEnhancementTest.cs b/.Lib9c.Tests/Action/ItemEnhancementTest.cs index b41886221d..b5fa83694e 100644 --- a/.Lib9c.Tests/Action/ItemEnhancementTest.cs +++ b/.Lib9c.Tests/Action/ItemEnhancementTest.cs @@ -56,7 +56,7 @@ public ItemEnhancementTest() var agentState = new AgentState(_agentAddress); _avatarAddress = _agentAddress.Derive("avatar"); - _avatarState = new AvatarState( + _avatarState = AvatarState.Create( _avatarAddress, _agentAddress, 0, diff --git a/.Lib9c.Tests/Action/JoinArena1Test.cs b/.Lib9c.Tests/Action/JoinArena1Test.cs index 0cb904bb63..6f1e1d5cf8 100644 --- a/.Lib9c.Tests/Action/JoinArena1Test.cs +++ b/.Lib9c.Tests/Action/JoinArena1Test.cs @@ -55,18 +55,17 @@ public JoinArena1Test(ITestOutputHelper outputHelper) var tableSheets = new TableSheets(sheets); var rankingMapAddress = new PrivateKey().Address; var agentState = new AgentState(_signer); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( _avatarAddress, _signer, 0, tableSheets.GetAvatarSheets(), - rankingMapAddress) - { - worldInformation = new WorldInformation( - 0, - tableSheets.WorldSheet, - GameConfig.RequireClearedStageLevel.ActionsInRankingBoard), - }; + rankingMapAddress); + avatarState.worldInformation = new WorldInformation( + 0, + tableSheets.WorldSheet, + GameConfig.RequireClearedStageLevel.ActionsInRankingBoard); + agentState.avatarAddresses[0] = _avatarAddress; avatarState.level = GameConfig.RequireClearedStageLevel.ActionsInRankingBoard; @@ -74,18 +73,17 @@ public JoinArena1Test(ITestOutputHelper outputHelper) _avatar2Address = _signer2.Derive("avatar"); var agent2State = new AgentState(_signer2); - var avatar2State = new AvatarState( + var avatar2State = AvatarState.Create( _avatar2Address, _signer2, 0, tableSheets.GetAvatarSheets(), - rankingMapAddress) - { - worldInformation = new WorldInformation( - 0, - tableSheets.WorldSheet, - 1), - }; + rankingMapAddress); + avatar2State.worldInformation = new WorldInformation( + 0, + tableSheets.WorldSheet, + 1); + agent2State.avatarAddresses[0] = _avatar2Address; #pragma warning disable CS0618 // Use of obsolete method Currency.Legacy(): https://github.com/planetarium/lib9c/discussions/1319 diff --git a/.Lib9c.Tests/Action/JoinArena3Test.cs b/.Lib9c.Tests/Action/JoinArena3Test.cs index d58fe362a4..c1b633c195 100644 --- a/.Lib9c.Tests/Action/JoinArena3Test.cs +++ b/.Lib9c.Tests/Action/JoinArena3Test.cs @@ -57,18 +57,17 @@ public JoinArena3Test(ITestOutputHelper outputHelper) var rankingMapAddress = new PrivateKey().Address; var agentState = new AgentState(_signer); var gameConfigState = new GameConfigState(_sheets[nameof(GameConfigSheet)]); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( _avatarAddress, _signer, 0, tableSheets.GetAvatarSheets(), - rankingMapAddress) - { - worldInformation = new WorldInformation( - 0, - tableSheets.WorldSheet, - GameConfig.RequireClearedStageLevel.ActionsInRankingBoard), - }; + rankingMapAddress); + avatarState.worldInformation = new WorldInformation( + 0, + tableSheets.WorldSheet, + GameConfig.RequireClearedStageLevel.ActionsInRankingBoard); + agentState.avatarAddresses[0] = _avatarAddress; avatarState.level = GameConfig.RequireClearedStageLevel.ActionsInRankingBoard; @@ -76,18 +75,17 @@ public JoinArena3Test(ITestOutputHelper outputHelper) _avatar2Address = _signer2.Derive("avatar"); var agent2State = new AgentState(_signer2); - var avatar2State = new AvatarState( + var avatar2State = AvatarState.Create( _avatar2Address, _signer2, 0, tableSheets.GetAvatarSheets(), - rankingMapAddress) - { - worldInformation = new WorldInformation( - 0, - tableSheets.WorldSheet, - 1), - }; + rankingMapAddress); + avatar2State.worldInformation = new WorldInformation( + 0, + tableSheets.WorldSheet, + 1); + agent2State.avatarAddresses[0] = _avatar2Address; #pragma warning disable CS0618 // Use of obsolete method Currency.Legacy(): https://github.com/planetarium/lib9c/discussions/1319 diff --git a/.Lib9c.Tests/Action/MigrateMonsterCollectionTest.cs b/.Lib9c.Tests/Action/MigrateMonsterCollectionTest.cs index b7a4c16339..12de871818 100644 --- a/.Lib9c.Tests/Action/MigrateMonsterCollectionTest.cs +++ b/.Lib9c.Tests/Action/MigrateMonsterCollectionTest.cs @@ -37,7 +37,7 @@ public MigrateMonsterCollectionTest(ITestOutputHelper outputHelper) var tableSheets = new TableSheets(sheets); var rankingMapAddress = new PrivateKey().Address; var agentState = new AgentState(_signer); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( _avatarAddress, _signer, 0, diff --git a/.Lib9c.Tests/Action/MintAssetsTest.cs b/.Lib9c.Tests/Action/MintAssetsTest.cs index 5dc502d1fd..d1f8b54d76 100644 --- a/.Lib9c.Tests/Action/MintAssetsTest.cs +++ b/.Lib9c.Tests/Action/MintAssetsTest.cs @@ -330,18 +330,17 @@ private IWorld GenerateAvatar(IWorld state, out Address avatarAddress) var agentState = new AgentState(address); avatarAddress = address.Derive("avatar"); var rankingMapAddress = new PrivateKey().Address; - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( avatarAddress, address, 0, _tableSheets.GetAvatarSheets(), - rankingMapAddress) - { - worldInformation = new WorldInformation( - 0, - _tableSheets.WorldSheet, - GameConfig.RequireClearedStageLevel.ActionsInShop), - }; + rankingMapAddress); + avatarState.worldInformation = new WorldInformation( + 0, + _tableSheets.WorldSheet, + GameConfig.RequireClearedStageLevel.ActionsInShop); + agentState.avatarAddresses[0] = avatarAddress; state = state @@ -355,18 +354,17 @@ private IWorld GenerateAvatar(IWorld state, Address address, Address avatarAddre { var agentState = new AgentState(address); var rankingMapAddress = new PrivateKey().Address; - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( avatarAddress, address, 0, _tableSheets.GetAvatarSheets(), - rankingMapAddress) - { - worldInformation = new WorldInformation( - 0, - _tableSheets.WorldSheet, - GameConfig.RequireClearedStageLevel.ActionsInShop), - }; + rankingMapAddress); + avatarState.worldInformation = new WorldInformation( + 0, + _tableSheets.WorldSheet, + GameConfig.RequireClearedStageLevel.ActionsInShop); + agentState.avatarAddresses[0] = avatarAddress; state = state diff --git a/.Lib9c.Tests/Action/RaidTest.cs b/.Lib9c.Tests/Action/RaidTest.cs index 1427fd7376..69752395c5 100644 --- a/.Lib9c.Tests/Action/RaidTest.cs +++ b/.Lib9c.Tests/Action/RaidTest.cs @@ -149,7 +149,7 @@ int runeId2 } var gameConfigState = new GameConfigState(_sheets[nameof(GameConfigSheet)]); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( _avatarAddress, _agentAddress, 0, @@ -452,7 +452,7 @@ public void Execute_With_Reward() } var gameConfigState = new GameConfigState(_sheets[nameof(GameConfigSheet)]); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( _avatarAddress, _agentAddress, 0, @@ -606,7 +606,7 @@ public void Execute_With_Free_Crystal_Fee() } var gameConfigState = new GameConfigState(_sheets[nameof(GameConfigSheet)]); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( _avatarAddress, _agentAddress, 0, diff --git a/.Lib9c.Tests/Action/RankingBattleTest.cs b/.Lib9c.Tests/Action/RankingBattleTest.cs index 37ef5a7527..ae617ff92e 100644 --- a/.Lib9c.Tests/Action/RankingBattleTest.cs +++ b/.Lib9c.Tests/Action/RankingBattleTest.cs @@ -116,20 +116,19 @@ public static (AgentState AgentState, AvatarState AvatarState) GetAgentStateWith var agentState = new AgentState(agentAddress); var avatarAddress = agentAddress.Derive("avatar"); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( avatarAddress, agentAddress, 0, tableSheets.GetAvatarSheets(), - rankingMapAddress) - { - worldInformation = new WorldInformation( - 0, - tableSheets.WorldSheet, - Math.Max( - tableSheets.StageSheet.First?.Id ?? 1, - GameConfig.RequireClearedStageLevel.ActionsInRankingBoard)), - }; + rankingMapAddress); + avatarState.worldInformation = new WorldInformation( + 0, + tableSheets.WorldSheet, + Math.Max( + tableSheets.StageSheet.First?.Id ?? 1, + GameConfig.RequireClearedStageLevel.ActionsInRankingBoard)); + agentState.avatarAddresses.Add(0, avatarAddress); return (agentState, avatarState); diff --git a/.Lib9c.Tests/Action/RapidCombinationTest.cs b/.Lib9c.Tests/Action/RapidCombinationTest.cs index 43eb01f1b9..1af5e83f01 100644 --- a/.Lib9c.Tests/Action/RapidCombinationTest.cs +++ b/.Lib9c.Tests/Action/RapidCombinationTest.cs @@ -71,7 +71,7 @@ public RapidCombinationTest() var agentState = new AgentState(_agentAddress); _avatarAddress = new PrivateKey().Address; - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( _avatarAddress, _agentAddress, 0, diff --git a/.Lib9c.Tests/Action/ReRegisterProductTest.cs b/.Lib9c.Tests/Action/ReRegisterProductTest.cs index 91b65c1db0..c29c1df0e5 100644 --- a/.Lib9c.Tests/Action/ReRegisterProductTest.cs +++ b/.Lib9c.Tests/Action/ReRegisterProductTest.cs @@ -64,18 +64,17 @@ public ReRegisterProductTest(ITestOutputHelper outputHelper) _avatarAddress = new PrivateKey().Address; var rankingMapAddress = new PrivateKey().Address; _gameConfigState = new GameConfigState((Text)_tableSheets.GameConfigSheet.Serialize()); - _avatarState = new AvatarState( + _avatarState = AvatarState.Create( _avatarAddress, _agentAddress, 0, _tableSheets.GetAvatarSheets(), - rankingMapAddress) - { - worldInformation = new WorldInformation( - 0, - _tableSheets.WorldSheet, - GameConfig.RequireClearedStageLevel.ActionsInShop), - }; + rankingMapAddress); + _avatarState.worldInformation = new WorldInformation( + 0, + _tableSheets.WorldSheet, + GameConfig.RequireClearedStageLevel.ActionsInShop); + agentState.avatarAddresses[0] = _avatarAddress; _initialState = _initialState diff --git a/.Lib9c.Tests/Action/RedeemCodeTest.cs b/.Lib9c.Tests/Action/RedeemCodeTest.cs index d332cdb347..feb8ff49d4 100644 --- a/.Lib9c.Tests/Action/RedeemCodeTest.cs +++ b/.Lib9c.Tests/Action/RedeemCodeTest.cs @@ -55,7 +55,7 @@ public void Execute() var gameConfigState = new GameConfigState(); var agentState = new AgentState(_agentAddress); agentState.avatarAddresses[0] = _avatarAddress; - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( _avatarAddress, _agentAddress, 1, diff --git a/.Lib9c.Tests/Action/RegisterProduct0Test.cs b/.Lib9c.Tests/Action/RegisterProduct0Test.cs index 0bbea15efb..05d59e846c 100644 --- a/.Lib9c.Tests/Action/RegisterProduct0Test.cs +++ b/.Lib9c.Tests/Action/RegisterProduct0Test.cs @@ -41,19 +41,18 @@ public RegisterProduct0Test() var rankingMapAddress = new PrivateKey().Address; _tableSheets = new TableSheets(TableSheetsImporter.ImportSheets()); _gameConfigState = new GameConfigState((Text)_tableSheets.GameConfigSheet.Serialize()); - _avatarState = new AvatarState( + _avatarState = AvatarState.Create( AvatarAddress, _agentAddress, 0, _tableSheets.GetAvatarSheets(), - rankingMapAddress) - { - worldInformation = new WorldInformation( - 0, - _tableSheets.WorldSheet, - GameConfig.RequireClearedStageLevel.ActionsInShop), - actionPoint = DailyReward.ActionPointMax, - }; + rankingMapAddress); + _avatarState.worldInformation = new WorldInformation( + 0, + _tableSheets.WorldSheet, + GameConfig.RequireClearedStageLevel.ActionsInShop); + _avatarState.actionPoint = DailyReward.ActionPointMax; + agentState.avatarAddresses[0] = AvatarAddress; _initialState = new World(MockUtil.MockModernWorldState) diff --git a/.Lib9c.Tests/Action/RegisterProductTest.cs b/.Lib9c.Tests/Action/RegisterProductTest.cs index 78e94ba309..cdebbed4ca 100644 --- a/.Lib9c.Tests/Action/RegisterProductTest.cs +++ b/.Lib9c.Tests/Action/RegisterProductTest.cs @@ -41,18 +41,17 @@ public RegisterProductTest() var rankingMapAddress = new PrivateKey().Address; _tableSheets = new TableSheets(TableSheetsImporter.ImportSheets()); _gameConfigState = new GameConfigState((Text)_tableSheets.GameConfigSheet.Serialize()); - _avatarState = new AvatarState( + _avatarState = AvatarState.Create( AvatarAddress, _agentAddress, 0, _tableSheets.GetAvatarSheets(), - rankingMapAddress) - { - worldInformation = new WorldInformation( - 0, - _tableSheets.WorldSheet, - GameConfig.RequireClearedStageLevel.ActionsInShop), - }; + rankingMapAddress); + _avatarState.worldInformation = new WorldInformation( + 0, + _tableSheets.WorldSheet, + GameConfig.RequireClearedStageLevel.ActionsInShop); + agentState.avatarAddresses[0] = AvatarAddress; _initialState = new World(MockUtil.MockModernWorldState) diff --git a/.Lib9c.Tests/Action/RewardGoldTest.cs b/.Lib9c.Tests/Action/RewardGoldTest.cs index dab60ece07..63df7d4cf9 100644 --- a/.Lib9c.Tests/Action/RewardGoldTest.cs +++ b/.Lib9c.Tests/Action/RewardGoldTest.cs @@ -55,7 +55,7 @@ public RewardGoldTest() var avatarAddress = agentAddress.Derive("avatar"); _tableSheets = new TableSheets(sheets); - _avatarState = new AvatarState( + _avatarState = AvatarState.Create( avatarAddress, agentAddress, 0, @@ -63,7 +63,7 @@ public RewardGoldTest() default ); - _avatarState2 = new AvatarState( + _avatarState2 = AvatarState.Create( new PrivateKey().Address, agentAddress, 0, diff --git a/.Lib9c.Tests/Action/RuneEnhancementTest.cs b/.Lib9c.Tests/Action/RuneEnhancementTest.cs index 90cdb21738..1d792cbfd9 100644 --- a/.Lib9c.Tests/Action/RuneEnhancementTest.cs +++ b/.Lib9c.Tests/Action/RuneEnhancementTest.cs @@ -62,7 +62,7 @@ int seed var goldCurrencyState = new GoldCurrencyState(_goldCurrency); var rankingMapAddress = avatarAddress.Derive("ranking_map"); var agentState = new AgentState(agentAddress); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( avatarAddress, agentAddress, 0, @@ -184,7 +184,7 @@ int seed var goldCurrencyState = new GoldCurrencyState(_goldCurrency); var rankingMapAddress = avatarAddress.Derive("ranking_map"); var agentState = new AgentState(agentAddress); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( avatarAddress, agentAddress, 0, @@ -279,7 +279,7 @@ public void Execute_RuneCostNotFoundException() var goldCurrencyState = new GoldCurrencyState(_goldCurrency); var rankingMapAddress = avatarAddress.Derive("ranking_map"); var agentState = new AgentState(agentAddress); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( avatarAddress, agentAddress, 0, @@ -333,7 +333,7 @@ public void Execute_RuneCostDataNotFoundException() var goldCurrencyState = new GoldCurrencyState(_goldCurrency); var rankingMapAddress = avatarAddress.Derive("ranking_map"); var agentState = new AgentState(agentAddress); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( avatarAddress, agentAddress, 0, @@ -402,7 +402,7 @@ public void Execute_NotEnoughFungibleAssetValueException(bool ncg, bool crystal, var goldCurrencyState = new GoldCurrencyState(_goldCurrency); var rankingMapAddress = avatarAddress.Derive("ranking_map"); var agentState = new AgentState(agentAddress); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( avatarAddress, agentAddress, 0, @@ -517,7 +517,7 @@ public void Execute_TryCountIsZeroException() var goldCurrencyState = new GoldCurrencyState(_goldCurrency); var rankingMapAddress = avatarAddress.Derive("ranking_map"); var agentState = new AgentState(agentAddress); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( avatarAddress, agentAddress, 0, @@ -579,7 +579,7 @@ public void Execute_FailedLoadStateException() state = state.SetLegacyState(Addresses.TableSheet.Derive(key), value.Serialize()); } - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( avatarAddress, agentAddress, 0, @@ -645,7 +645,7 @@ public void RuneBonus(int[] prevRuneLevels, int tryCount, bool createNewRune, in var goldCurrencyState = new GoldCurrencyState(_goldCurrency); var rankingMapAddress = avatarAddress.Derive("ranking_map"); var agentState = new AgentState(agentAddress); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( avatarAddress, agentAddress, 0, diff --git a/.Lib9c.Tests/Action/Scenario/ArenaScenarioTest.cs b/.Lib9c.Tests/Action/Scenario/ArenaScenarioTest.cs index 872a6b9081..90e590aef3 100644 --- a/.Lib9c.Tests/Action/Scenario/ArenaScenarioTest.cs +++ b/.Lib9c.Tests/Action/Scenario/ArenaScenarioTest.cs @@ -161,18 +161,17 @@ public IWorld BattleArena( var agentState = new AgentState(agentAddress); var avatarAddress = agentAddress.Derive("avatar"); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( avatarAddress, agentAddress, 0, _tableSheets.GetAvatarSheets(), - _rankingMapAddress) - { - worldInformation = new WorldInformation( - 0, - _tableSheets.WorldSheet, - clearStageId), - }; + _rankingMapAddress); + avatarState.worldInformation = new WorldInformation( + 0, + _tableSheets.WorldSheet, + clearStageId); + agentState.avatarAddresses.Add(0, avatarAddress); _state = _state .SetAgentState(agentAddress, agentState) diff --git a/.Lib9c.Tests/Action/Scenario/AuraScenarioTest.cs b/.Lib9c.Tests/Action/Scenario/AuraScenarioTest.cs index 626cce5395..19a1a01890 100644 --- a/.Lib9c.Tests/Action/Scenario/AuraScenarioTest.cs +++ b/.Lib9c.Tests/Action/Scenario/AuraScenarioTest.cs @@ -56,7 +56,7 @@ public AuraScenarioTest() { var avatarAddress = addresses[i]; agentState.avatarAddresses.Add(i, avatarAddress); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( _avatarAddress, _agentAddress, 0, diff --git a/.Lib9c.Tests/Action/Scenario/CollectionScenarioTest.cs b/.Lib9c.Tests/Action/Scenario/CollectionScenarioTest.cs index d3abcad64d..7f291f47b7 100644 --- a/.Lib9c.Tests/Action/Scenario/CollectionScenarioTest.cs +++ b/.Lib9c.Tests/Action/Scenario/CollectionScenarioTest.cs @@ -41,7 +41,7 @@ public CollectionScenarioTest() { var avatarAddress = addresses[i]; agentState.avatarAddresses.Add(i, avatarAddress); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( _avatarAddress, _agentAddress, 0, diff --git a/.Lib9c.Tests/Action/Scenario/GrimoireScenarioTest.cs b/.Lib9c.Tests/Action/Scenario/GrimoireScenarioTest.cs index a9af87f6d2..2a8e7e3b2b 100644 --- a/.Lib9c.Tests/Action/Scenario/GrimoireScenarioTest.cs +++ b/.Lib9c.Tests/Action/Scenario/GrimoireScenarioTest.cs @@ -56,7 +56,7 @@ public GrimoireScenarioTest() { var avatarAddress = addresses[i]; agentState.avatarAddresses.Add(i, avatarAddress); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( _avatarAddress, _agentAddress, 0, diff --git a/.Lib9c.Tests/Action/Scenario/MarketScenarioTest.cs b/.Lib9c.Tests/Action/Scenario/MarketScenarioTest.cs index 29de1a25c9..9b84058ab4 100644 --- a/.Lib9c.Tests/Action/Scenario/MarketScenarioTest.cs +++ b/.Lib9c.Tests/Action/Scenario/MarketScenarioTest.cs @@ -53,55 +53,52 @@ public MarketScenarioTest(ITestOutputHelper outputHelper) var rankingMapAddress = new PrivateKey().Address; _tableSheets = new TableSheets(TableSheetsImporter.ImportSheets()); _gameConfigState = new GameConfigState((Text)_tableSheets.GameConfigSheet.Serialize()); - _sellerAvatarState = new AvatarState( + _sellerAvatarState = AvatarState.Create( _sellerAvatarAddress, _sellerAgentAddress, 0, _tableSheets.GetAvatarSheets(), - rankingMapAddress) - { - worldInformation = new WorldInformation( - 0, - _tableSheets.WorldSheet, - GameConfig.RequireClearedStageLevel.ActionsInShop), - actionPoint = DailyReward.ActionPointMax, - }; + rankingMapAddress); + _sellerAvatarState.worldInformation = new WorldInformation( + 0, + _tableSheets.WorldSheet, + GameConfig.RequireClearedStageLevel.ActionsInShop); + _sellerAvatarState.actionPoint = DailyReward.ActionPointMax; + agentState.avatarAddresses[0] = _sellerAvatarAddress; _sellerAgentAddress2 = new PrivateKey().Address; var agentState2 = new AgentState(_sellerAgentAddress2); _sellerAvatarAddress2 = new PrivateKey().Address; - _sellerAvatarState2 = new AvatarState( + _sellerAvatarState2 = AvatarState.Create( _sellerAvatarAddress2, _sellerAgentAddress2, 0, _tableSheets.GetAvatarSheets(), - rankingMapAddress) - { - worldInformation = new WorldInformation( - 0, - _tableSheets.WorldSheet, - GameConfig.RequireClearedStageLevel.ActionsInShop), - actionPoint = DailyReward.ActionPointMax, - }; + rankingMapAddress); + _sellerAvatarState2.worldInformation = new WorldInformation( + 0, + _tableSheets.WorldSheet, + GameConfig.RequireClearedStageLevel.ActionsInShop); + _sellerAvatarState2.actionPoint = DailyReward.ActionPointMax; + agentState2.avatarAddresses[0] = _sellerAvatarAddress2; _buyerAgentAddress = new PrivateKey().Address; var agentState3 = new AgentState(_buyerAgentAddress); _buyerAvatarAddress = new PrivateKey().Address; - var buyerAvatarState = new AvatarState( + var buyerAvatarState = AvatarState.Create( _buyerAvatarAddress, _buyerAgentAddress, 0, _tableSheets.GetAvatarSheets(), - rankingMapAddress) - { - worldInformation = new WorldInformation( - 0, - _tableSheets.WorldSheet, - GameConfig.RequireClearedStageLevel.ActionsInShop), - actionPoint = DailyReward.ActionPointMax, - }; + rankingMapAddress); + buyerAvatarState.worldInformation = new WorldInformation( + 0, + _tableSheets.WorldSheet, + GameConfig.RequireClearedStageLevel.ActionsInShop); + buyerAvatarState.actionPoint = DailyReward.ActionPointMax; + agentState3.avatarAddresses[0] = _buyerAvatarAddress; _currency = Currency.Legacy("NCG", 2, minters: null); diff --git a/.Lib9c.Tests/Action/Scenario/RuneScenarioTest.cs b/.Lib9c.Tests/Action/Scenario/RuneScenarioTest.cs index fc98f1c10f..280cf3f728 100644 --- a/.Lib9c.Tests/Action/Scenario/RuneScenarioTest.cs +++ b/.Lib9c.Tests/Action/Scenario/RuneScenarioTest.cs @@ -31,7 +31,7 @@ public void Craft_And_Unlock_And_Equip() var tableSheets = new TableSheets(sheets); agentState.avatarAddresses.Add(0, avatarAddress); var gameConfigState = new GameConfigState(sheets[nameof(GameConfigSheet)]); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( avatarAddress, agentAddress, 0, @@ -154,7 +154,7 @@ public void MigrateToRuneStateModule() var tableSheets = new TableSheets(sheets); agentState.avatarAddresses.Add(0, avatarAddress); var gameConfigState = new GameConfigState(sheets[nameof(GameConfigSheet)]); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( avatarAddress, agentAddress, 0, diff --git a/.Lib9c.Tests/Action/Scenario/SellAndCancellationAndSellTest.cs b/.Lib9c.Tests/Action/Scenario/SellAndCancellationAndSellTest.cs index 78ac5169f4..d82f44723b 100644 --- a/.Lib9c.Tests/Action/Scenario/SellAndCancellationAndSellTest.cs +++ b/.Lib9c.Tests/Action/Scenario/SellAndCancellationAndSellTest.cs @@ -46,19 +46,17 @@ public SellAndCancellationAndSellTest(ITestOutputHelper outputHelper) _avatarAddress = _agentAddress.Derive("avatar"); var agentState = new AgentState(_agentAddress); agentState.avatarAddresses[0] = _avatarAddress; - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( _avatarAddress, _agentAddress, 1, _tableSheets.GetAvatarSheets(), default - ) - { - worldInformation = new WorldInformation( - 0, - _tableSheets.WorldSheet, - GameConfig.RequireClearedStageLevel.ActionsInShop), - }; + ); + avatarState.worldInformation = new WorldInformation( + 0, + _tableSheets.WorldSheet, + GameConfig.RequireClearedStageLevel.ActionsInShop); _initialState = new World(MockUtil.MockModernWorldState) .SetLegacyState(GoldCurrencyState.Address, gold.Serialize()) diff --git a/.Lib9c.Tests/Action/Scenario/WorldUnlockScenarioTest.cs b/.Lib9c.Tests/Action/Scenario/WorldUnlockScenarioTest.cs index 7bb204dd28..61b8157f1c 100644 --- a/.Lib9c.Tests/Action/Scenario/WorldUnlockScenarioTest.cs +++ b/.Lib9c.Tests/Action/Scenario/WorldUnlockScenarioTest.cs @@ -37,16 +37,15 @@ public WorldUnlockScenarioTest() _avatarAddress = _agentAddress.Derive("avatar"); _rankingMapAddress = _avatarAddress.Derive("ranking_map"); var gameConfigState = new GameConfigState(sheets[nameof(GameConfigSheet)]); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( _avatarAddress, _agentAddress, 0, _tableSheets.GetAvatarSheets(), _rankingMapAddress - ) - { - level = 100, - }; + ); + avatarState.level = 100; + agentState.avatarAddresses.Add(0, _avatarAddress); _weeklyArenaState = new WeeklyArenaState(0); diff --git a/.Lib9c.Tests/Action/Summon/AuraSummonTest.cs b/.Lib9c.Tests/Action/Summon/AuraSummonTest.cs index 0215c6b5d5..c357865884 100644 --- a/.Lib9c.Tests/Action/Summon/AuraSummonTest.cs +++ b/.Lib9c.Tests/Action/Summon/AuraSummonTest.cs @@ -38,7 +38,7 @@ public AuraSummonTest() var agentState = new AgentState(_agentAddress); _avatarAddress = _agentAddress.Derive("avatar"); - _avatarState = new AvatarState( + _avatarState = AvatarState.Create( _avatarAddress, _agentAddress, 0, diff --git a/.Lib9c.Tests/Action/Summon/RuneSummonTest.cs b/.Lib9c.Tests/Action/Summon/RuneSummonTest.cs index 4f1b93f5c6..8e98da0d60 100644 --- a/.Lib9c.Tests/Action/Summon/RuneSummonTest.cs +++ b/.Lib9c.Tests/Action/Summon/RuneSummonTest.cs @@ -38,7 +38,7 @@ public RuneSummonTest() var agentState = new AgentState(_agentAddress); _avatarAddress = _agentAddress.Derive("avatar"); - _avatarState = new AvatarState( + _avatarState = AvatarState.Create( _avatarAddress, _agentAddress, 0, diff --git a/.Lib9c.Tests/Action/UnlockCombinationSlotTest.cs b/.Lib9c.Tests/Action/UnlockCombinationSlotTest.cs index 488201fec6..5b2407abf9 100644 --- a/.Lib9c.Tests/Action/UnlockCombinationSlotTest.cs +++ b/.Lib9c.Tests/Action/UnlockCombinationSlotTest.cs @@ -48,7 +48,7 @@ public IWorld Init(out Address agentAddress, out Address avatarAddress, out long state = state.SetLegacyState(Addresses.TableSheet.Derive(key), value.Serialize()); var gameConfigState = new GameConfigState(Sheets[nameof(GameConfigSheet)]); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( avatarAddress, agentAddress, 0, diff --git a/.Lib9c.Tests/Action/UnlockEquipmentRecipeTest.cs b/.Lib9c.Tests/Action/UnlockEquipmentRecipeTest.cs index 30c925ad1f..26edf9ad31 100644 --- a/.Lib9c.Tests/Action/UnlockEquipmentRecipeTest.cs +++ b/.Lib9c.Tests/Action/UnlockEquipmentRecipeTest.cs @@ -42,7 +42,7 @@ public UnlockEquipmentRecipeTest() var gameConfigState = new GameConfigState(sheets[nameof(GameConfigSheet)]); var agentState = new AgentState(_agentAddress); - _avatarState = new AvatarState( + _avatarState = AvatarState.Create( _avatarAddress, _agentAddress, 0, diff --git a/.Lib9c.Tests/Action/UnlockWorldTest.cs b/.Lib9c.Tests/Action/UnlockWorldTest.cs index a27a976711..3d5eee7f9e 100644 --- a/.Lib9c.Tests/Action/UnlockWorldTest.cs +++ b/.Lib9c.Tests/Action/UnlockWorldTest.cs @@ -40,7 +40,7 @@ public UnlockWorldTest() var gameConfigState = new GameConfigState(sheets[nameof(GameConfigSheet)]); var agentState = new AgentState(_agentAddress); - _avatarState = new AvatarState( + _avatarState = AvatarState.Create( _avatarAddress, _agentAddress, 0, diff --git a/.Lib9c.Tests/Battle/EnemyPlayerDigestTest.cs b/.Lib9c.Tests/Battle/EnemyPlayerDigestTest.cs index bf2be9e9d7..bb73a2f8cb 100644 --- a/.Lib9c.Tests/Battle/EnemyPlayerDigestTest.cs +++ b/.Lib9c.Tests/Battle/EnemyPlayerDigestTest.cs @@ -19,7 +19,7 @@ public class EnemyPlayerDigestTest public EnemyPlayerDigestTest() { _tableSheets = new TableSheets(TableSheetsImporter.ImportSheets()); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( new PrivateKey().Address, new PrivateKey().Address, 1234, diff --git a/.Lib9c.Tests/Model/AdventureBoss/AdventureBossSimulatorTest.cs b/.Lib9c.Tests/Model/AdventureBoss/AdventureBossSimulatorTest.cs index 1beac02fb6..262d0cc0a9 100644 --- a/.Lib9c.Tests/Model/AdventureBoss/AdventureBossSimulatorTest.cs +++ b/.Lib9c.Tests/Model/AdventureBoss/AdventureBossSimulatorTest.cs @@ -27,7 +27,7 @@ public AdventureBossSimulatorTest(ITestOutputHelper testOutputHelper) _testOutputHelper = testOutputHelper; _tableSheets = new TableSheets(TableSheetsImporter.ImportSheets()); _random = new TestRandom(); - _avatarState = new AvatarState( + _avatarState = AvatarState.Create( default, default, 0, diff --git a/.Lib9c.Tests/Model/Arena/ArenaAvatarStateTest.cs b/.Lib9c.Tests/Model/Arena/ArenaAvatarStateTest.cs index ac1bae3892..65ef1f554c 100644 --- a/.Lib9c.Tests/Model/Arena/ArenaAvatarStateTest.cs +++ b/.Lib9c.Tests/Model/Arena/ArenaAvatarStateTest.cs @@ -33,7 +33,7 @@ public void Serialize() private AvatarState GetNewAvatarState(Address avatarAddress, Address agentAddress) { var rankingState = new RankingState1(); - return new AvatarState( + return AvatarState.Create( avatarAddress, agentAddress, 0, diff --git a/.Lib9c.Tests/Model/Arena/PlayerDigestTest.cs b/.Lib9c.Tests/Model/Arena/PlayerDigestTest.cs index bd3a40e2bd..061a0f35ee 100644 --- a/.Lib9c.Tests/Model/Arena/PlayerDigestTest.cs +++ b/.Lib9c.Tests/Model/Arena/PlayerDigestTest.cs @@ -22,7 +22,7 @@ public class PlayerDigestTest public PlayerDigestTest() { _tableSheets = new TableSheets(TableSheetsImporter.ImportSheets()); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( new PrivateKey().Address, new PrivateKey().Address, 1234, diff --git a/.Lib9c.Tests/Model/ArenaSimulatorTest.cs b/.Lib9c.Tests/Model/ArenaSimulatorTest.cs index a891a72152..0f36ddcabe 100644 --- a/.Lib9c.Tests/Model/ArenaSimulatorTest.cs +++ b/.Lib9c.Tests/Model/ArenaSimulatorTest.cs @@ -37,7 +37,7 @@ public ArenaSimulatorTest(ITestOutputHelper testOutputHelper) _tableSheets = new TableSheets(TableSheetsImporter.ImportSheets()); _random = new TestRandom(); - _avatarState1 = new AvatarState( + _avatarState1 = AvatarState.Create( default, default, 0, @@ -45,7 +45,7 @@ public ArenaSimulatorTest(ITestOutputHelper testOutputHelper) default ); - _avatarState2 = new AvatarState( + _avatarState2 = AvatarState.Create( default, default, 0, diff --git a/.Lib9c.Tests/Model/BattleLogTest.cs b/.Lib9c.Tests/Model/BattleLogTest.cs index f7bb0fb5d9..f1f6c66ac1 100644 --- a/.Lib9c.Tests/Model/BattleLogTest.cs +++ b/.Lib9c.Tests/Model/BattleLogTest.cs @@ -27,7 +27,7 @@ public BattleLogTest() public void IsClearBeforeSimulate() { var agentState = new AgentState(default(Address)); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( default, agentState.address, 0, diff --git a/.Lib9c.Tests/Model/Order/FungibleOrderTest.cs b/.Lib9c.Tests/Model/Order/FungibleOrderTest.cs index 22de9e7808..aa0f788135 100644 --- a/.Lib9c.Tests/Model/Order/FungibleOrderTest.cs +++ b/.Lib9c.Tests/Model/Order/FungibleOrderTest.cs @@ -28,7 +28,7 @@ public FungibleOrderTest() // Use of obsolete method Currency.Legacy(): https://github.com/planetarium/lib9c/discussions/1319 _currency = Currency.Legacy("NCG", 2, null); #pragma warning restore CS0618 - _avatarState = new AvatarState( + _avatarState = AvatarState.Create( Addresses.Blacksmith, Addresses.Admin, 0, @@ -636,7 +636,7 @@ public void Transfer(bool add, Type exc) order.Sell2(_avatarState); } - var buyer = new AvatarState( + var buyer = AvatarState.Create( Addresses.Blacksmith, Addresses.Admin, 0, @@ -684,7 +684,7 @@ public void Transfer2(bool add, Type exc) order.Sell(_avatarState); } - var buyer = new AvatarState( + var buyer = AvatarState.Create( Addresses.Blacksmith, Addresses.Admin, 0, diff --git a/.Lib9c.Tests/Model/Order/NonFungibleOrderTest.cs b/.Lib9c.Tests/Model/Order/NonFungibleOrderTest.cs index 4399060281..44ac533134 100644 --- a/.Lib9c.Tests/Model/Order/NonFungibleOrderTest.cs +++ b/.Lib9c.Tests/Model/Order/NonFungibleOrderTest.cs @@ -30,7 +30,7 @@ public NonFungibleOrderTest() // Use of obsolete method Currency.Legacy(): https://github.com/planetarium/lib9c/discussions/1319 _currency = Currency.Legacy("NCG", 2, null); #pragma warning restore CS0618 - _avatarState = new AvatarState( + _avatarState = AvatarState.Create( Addresses.Blacksmith, Addresses.Admin, 0, @@ -649,7 +649,7 @@ public void Transfer(bool add, Type exc) order.Sell2(_avatarState); } - var buyer = new AvatarState( + var buyer = AvatarState.Create( Addresses.Blacksmith, Addresses.Admin, 0, @@ -697,7 +697,7 @@ public void Transfer2(bool add, Type exc) order.Sell(_avatarState); } - var buyer = new AvatarState( + var buyer = AvatarState.Create( Addresses.Blacksmith, Addresses.Admin, 0, diff --git a/.Lib9c.Tests/Model/PlayerTest.cs b/.Lib9c.Tests/Model/PlayerTest.cs index 6cbea9f21c..b4455650b1 100644 --- a/.Lib9c.Tests/Model/PlayerTest.cs +++ b/.Lib9c.Tests/Model/PlayerTest.cs @@ -30,7 +30,7 @@ public PlayerTest() { _random = new TestRandom(); _tableSheets = new TableSheets(TableSheetsImporter.ImportSheets()); - _avatarState = new AvatarState( + _avatarState = AvatarState.Create( default, default, 0, diff --git a/.Lib9c.Tests/Model/RaidSimulatorV1Test.cs b/.Lib9c.Tests/Model/RaidSimulatorV1Test.cs index a07c89fd78..dbdfccbf04 100644 --- a/.Lib9c.Tests/Model/RaidSimulatorV1Test.cs +++ b/.Lib9c.Tests/Model/RaidSimulatorV1Test.cs @@ -21,7 +21,7 @@ public RaidSimulatorV1Test() _tableSheets = new TableSheets(TableSheetsImporter.ImportSheets()); _random = new TestRandom(); - _avatarState = new AvatarState( + _avatarState = AvatarState.Create( default, default, 0, diff --git a/.Lib9c.Tests/Model/RaidSimulatorV2Test.cs b/.Lib9c.Tests/Model/RaidSimulatorV2Test.cs index a9203fa298..5112aa5bdf 100644 --- a/.Lib9c.Tests/Model/RaidSimulatorV2Test.cs +++ b/.Lib9c.Tests/Model/RaidSimulatorV2Test.cs @@ -21,7 +21,7 @@ public RaidSimulatorV2Test() _tableSheets = new TableSheets(TableSheetsImporter.ImportSheets()); _random = new TestRandom(); - _avatarState = new AvatarState( + _avatarState = AvatarState.Create( default, default, 0, diff --git a/.Lib9c.Tests/Model/RaidSimulatorV3Test.cs b/.Lib9c.Tests/Model/RaidSimulatorV3Test.cs index fcf3579897..cfe6f63851 100644 --- a/.Lib9c.Tests/Model/RaidSimulatorV3Test.cs +++ b/.Lib9c.Tests/Model/RaidSimulatorV3Test.cs @@ -29,7 +29,7 @@ public RaidSimulatorV3Test(ITestOutputHelper testOutputHelper) _tableSheets = new TableSheets(TableSheetsImporter.ImportSheets()); _random = new TestRandom(); - _avatarState = new AvatarState( + _avatarState = AvatarState.Create( default, default, 0, diff --git a/.Lib9c.Tests/Model/RankingSimulatorTest.cs b/.Lib9c.Tests/Model/RankingSimulatorTest.cs index e30f286db5..623f87d0b9 100644 --- a/.Lib9c.Tests/Model/RankingSimulatorTest.cs +++ b/.Lib9c.Tests/Model/RankingSimulatorTest.cs @@ -36,16 +36,15 @@ public void SimulateRequiredLevel(int level, int requiredLevel, bool expected) var rewardSheet = new WeeklyArenaRewardSheet(); rewardSheet.Set($"id,item_id,ratio,min,max,required_level\n1,302000,0.1,1,1,{requiredLevel}"); _tableSheets.WeeklyArenaRewardSheet = rewardSheet; - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( default, default, 0, _tableSheets.GetAvatarSheets(), default - ) - { - level = level, - }; + ); + avatarState.level = level; + avatarState.worldInformation.ClearStage( 1, GameConfig.RequireClearedStageLevel.ActionsInRankingBoard, @@ -88,7 +87,7 @@ public void SimulateRequiredLevel(int level, int requiredLevel, bool expected) [InlineData(1900, 6)] public void SimulateRankingScore(int score, int expected) { - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( default, default, 0, @@ -133,7 +132,7 @@ public void SimulateRankingScore(int score, int expected) [Fact] public void ConstructorWithCostume() { - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( default, default, 0, @@ -191,19 +190,17 @@ public void ConstructorWithCostume() public void CheckToReceiveAllRewardItems(int level, int simulationCount) { _tableSheets.WeeklyArenaRewardSheet = _tableSheets.WeeklyArenaRewardSheet; - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( default, default, 0, _tableSheets.GetAvatarSheets(), - default) - { - level = level, - worldInformation = new WorldInformation( - 0, - _tableSheets.WorldSheet, - GameConfig.RequireClearedStageLevel.ActionsInRankingBoard), - }; + default); + avatarState.level = level; + avatarState.worldInformation = new WorldInformation( + 0, + _tableSheets.WorldSheet, + GameConfig.RequireClearedStageLevel.ActionsInRankingBoard); var arenaInfo = new ArenaInfo(avatarState, _tableSheets.CharacterSheet, false); var enemyInfo = new ArenaInfo(avatarState, _tableSheets.CharacterSheet, false); diff --git a/.Lib9c.Tests/Model/RankingSimulatorV1Test.cs b/.Lib9c.Tests/Model/RankingSimulatorV1Test.cs index 9aace92084..ef06822fa9 100644 --- a/.Lib9c.Tests/Model/RankingSimulatorV1Test.cs +++ b/.Lib9c.Tests/Model/RankingSimulatorV1Test.cs @@ -36,16 +36,15 @@ public void SimulateRequiredLevel(int level, int requiredLevel, bool expected) var rewardSheet = new WeeklyArenaRewardSheet(); rewardSheet.Set($"id,item_id,ratio,min,max,required_level\n1,302000,0.1,1,1,{requiredLevel}"); _tableSheets.WeeklyArenaRewardSheet = rewardSheet; - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( default, default, 0, _tableSheets.GetAvatarSheets(), default - ) - { - level = level, - }; + ); + avatarState.level = level; + avatarState.worldInformation.ClearStage( 1, GameConfig.RequireClearedStageLevel.ActionsInRankingBoard, @@ -78,7 +77,7 @@ public void SimulateRequiredLevel(int level, int requiredLevel, bool expected) [InlineData(1900, 6)] public void SimulateRankingScore(int score, int expected) { - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( default, default, 0, @@ -115,7 +114,7 @@ public void SimulateRankingScore(int score, int expected) [Fact] public void ConstructorWithCostume() { - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( default, default, 0, @@ -175,15 +174,14 @@ public void ConstructorWithCostume() public void CheckToReceiveAllRewardItems(int level, int simulationCount) { _tableSheets.WeeklyArenaRewardSheet = _tableSheets.WeeklyArenaRewardSheet; - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( default, default, 0, _tableSheets.GetAvatarSheets(), - default) - { - level = level, - }; + default); + avatarState.level = level; + avatarState.worldInformation = new WorldInformation( 0, _tableSheets.WorldSheet, diff --git a/.Lib9c.Tests/Model/Skill/Adventure/CombatTest.cs b/.Lib9c.Tests/Model/Skill/Adventure/CombatTest.cs index 28f6822434..2f63cf7f1b 100644 --- a/.Lib9c.Tests/Model/Skill/Adventure/CombatTest.cs +++ b/.Lib9c.Tests/Model/Skill/Adventure/CombatTest.cs @@ -26,7 +26,7 @@ public CombatTest() _tableSheets = new TableSheets(csv); var gameConfigState = new GameConfigState(csv[nameof(GameConfigSheet)]); - _avatarState = new AvatarState( + _avatarState = AvatarState.Create( default, default, 0, diff --git a/.Lib9c.Tests/Model/Skill/Adventure/DoubleAttackTest.cs b/.Lib9c.Tests/Model/Skill/Adventure/DoubleAttackTest.cs index b32522f505..7706a73163 100644 --- a/.Lib9c.Tests/Model/Skill/Adventure/DoubleAttackTest.cs +++ b/.Lib9c.Tests/Model/Skill/Adventure/DoubleAttackTest.cs @@ -65,16 +65,15 @@ bool copyCharacter { Assert.True(_tableSheets.SkillSheet.TryGetValue(skillId, out var skillRow)); var twinAttack = new DoubleAttack(skillRow, 100, 100, default, StatType.NONE); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( new PrivateKey().Address, new PrivateKey().Address, 0, _tableSheets.GetAvatarSheets(), new PrivateKey().Address - ) - { - level = level, - }; + ); + avatarState.level = level; + var worldRow = _tableSheets.WorldSheet.First; Assert.NotNull(worldRow); diff --git a/.Lib9c.Tests/Model/Skill/Adventure/NormalAttackTest.cs b/.Lib9c.Tests/Model/Skill/Adventure/NormalAttackTest.cs index d1eb7d1356..6f97259c1c 100644 --- a/.Lib9c.Tests/Model/Skill/Adventure/NormalAttackTest.cs +++ b/.Lib9c.Tests/Model/Skill/Adventure/NormalAttackTest.cs @@ -36,7 +36,7 @@ public void Use(bool copyCharacter) Assert.True(_tableSheets.SkillSheet.TryGetValue(100000, out var skillRow)); var normalAttack = new NormalAttack(skillRow, 100, 100, default, StatType.NONE); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( new PrivateKey().Address, new PrivateKey().Address, 0, @@ -103,7 +103,7 @@ public void FocusSkill() // Set chance to 0 to minimize attack success probability var normalAttack = new NormalAttack(skillRow, 100, 0, default, StatType.NONE); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( new PrivateKey().Address, new PrivateKey().Address, 0, @@ -156,7 +156,7 @@ public void FocusSkill() Assert.Equal(0, player.AttackCount); // With Focus buff - avatarState = new AvatarState( + avatarState = AvatarState.Create( new PrivateKey().Address, new PrivateKey().Address, 0, diff --git a/.Lib9c.Tests/Model/Skill/Adventure/ShatterStrikeTest.cs b/.Lib9c.Tests/Model/Skill/Adventure/ShatterStrikeTest.cs index 968f9b56ca..dba821db23 100644 --- a/.Lib9c.Tests/Model/Skill/Adventure/ShatterStrikeTest.cs +++ b/.Lib9c.Tests/Model/Skill/Adventure/ShatterStrikeTest.cs @@ -38,7 +38,7 @@ public void Use(int enemyHp, int ratioBp, bool expectedEnemyDead, bool copyChara ); // 700010 is ShatterStrike var shatterStrike = new ShatterStrike(skillRow, 0, 0, ratioBp, StatType.NONE); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( new PrivateKey().Address, new PrivateKey().Address, 0, @@ -118,7 +118,7 @@ public void Use_MaxDamage(bool copyCharacter) ); // 700010 is ShatterStrike var shatterStrike = new ShatterStrike(skillRow, 0, 0, ratioBp, StatType.NONE); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( new PrivateKey().Address, new PrivateKey().Address, 0, diff --git a/.Lib9c.Tests/Model/Skill/Arena/ArenaCombatTest.cs b/.Lib9c.Tests/Model/Skill/Arena/ArenaCombatTest.cs index 74a9faeda1..20d37cbdd1 100644 --- a/.Lib9c.Tests/Model/Skill/Arena/ArenaCombatTest.cs +++ b/.Lib9c.Tests/Model/Skill/Arena/ArenaCombatTest.cs @@ -24,14 +24,14 @@ public class ArenaCombatTest public ArenaCombatTest() { _tableSheets = new TableSheets(TableSheetsImporter.ImportSheets()); - _avatar1 = new AvatarState( + _avatar1 = AvatarState.Create( default, default, 0, _tableSheets.GetAvatarSheets(), default ); - _avatar2 = new AvatarState( + _avatar2 = AvatarState.Create( default, default, 0, diff --git a/.Lib9c.Tests/Model/Skill/Arena/ArenaDoubleAttackTest.cs b/.Lib9c.Tests/Model/Skill/Arena/ArenaDoubleAttackTest.cs index d398ab3262..54283be89d 100644 --- a/.Lib9c.Tests/Model/Skill/Arena/ArenaDoubleAttackTest.cs +++ b/.Lib9c.Tests/Model/Skill/Arena/ArenaDoubleAttackTest.cs @@ -22,14 +22,14 @@ public class ArenaDoubleAttackTest public ArenaDoubleAttackTest() { _tableSheets = new TableSheets(TableSheetsImporter.ImportSheets()); - _avatar1 = new AvatarState( + _avatar1 = AvatarState.Create( default, default, 0, _tableSheets.GetAvatarSheets(), default ); - _avatar2 = new AvatarState( + _avatar2 = AvatarState.Create( default, default, 0, diff --git a/.Lib9c.Tests/Model/Skill/Arena/ArenaNormalAttackTest.cs b/.Lib9c.Tests/Model/Skill/Arena/ArenaNormalAttackTest.cs index ba2a0c1290..01e645b86d 100644 --- a/.Lib9c.Tests/Model/Skill/Arena/ArenaNormalAttackTest.cs +++ b/.Lib9c.Tests/Model/Skill/Arena/ArenaNormalAttackTest.cs @@ -24,14 +24,14 @@ public class ArenaNormalAttackTest public ArenaNormalAttackTest() { _tableSheets = new TableSheets(TableSheetsImporter.ImportSheets()); - _avatar1 = new AvatarState( + _avatar1 = AvatarState.Create( default, default, 0, _tableSheets.GetAvatarSheets(), default ); - _avatar2 = new AvatarState( + _avatar2 = AvatarState.Create( default, default, 0, diff --git a/.Lib9c.Tests/Model/Skill/Arena/ArenaShatterStrikeTest.cs b/.Lib9c.Tests/Model/Skill/Arena/ArenaShatterStrikeTest.cs index b712e0e2ab..aef5f46bff 100644 --- a/.Lib9c.Tests/Model/Skill/Arena/ArenaShatterStrikeTest.cs +++ b/.Lib9c.Tests/Model/Skill/Arena/ArenaShatterStrikeTest.cs @@ -25,14 +25,14 @@ public class ArenaShatterStrikeTest public ArenaShatterStrikeTest() { _tableSheets = new TableSheets(TableSheetsImporter.ImportSheets()); - _avatar1 = new AvatarState( + _avatar1 = AvatarState.Create( default, default, 0, _tableSheets.GetAvatarSheets(), default ); - _avatar2 = new AvatarState( + _avatar2 = AvatarState.Create( default, default, 0, diff --git a/.Lib9c.Tests/Model/Skill/BuffFactoryTest.cs b/.Lib9c.Tests/Model/Skill/BuffFactoryTest.cs index c54add442e..d6fdf997c5 100644 --- a/.Lib9c.Tests/Model/Skill/BuffFactoryTest.cs +++ b/.Lib9c.Tests/Model/Skill/BuffFactoryTest.cs @@ -22,7 +22,7 @@ public BuffFactoryTest() { _tableSheets = new TableSheets(TableSheetsImporter.ImportSheets()); var gameConfigState = new GameConfigState(); - _avatarState = new AvatarState( + _avatarState = AvatarState.Create( default, default, 0, diff --git a/.Lib9c.Tests/Model/Skill/Raid/NormalAttackTest.cs b/.Lib9c.Tests/Model/Skill/Raid/NormalAttackTest.cs index 22875d984e..b97a5d669f 100644 --- a/.Lib9c.Tests/Model/Skill/Raid/NormalAttackTest.cs +++ b/.Lib9c.Tests/Model/Skill/Raid/NormalAttackTest.cs @@ -24,7 +24,7 @@ public void FocusSkill() const int seed = 10; // This seed fails to attack enemy with NormalAttack // With Focus buff - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( new PrivateKey().Address, new PrivateKey().Address, 0, diff --git a/.Lib9c.Tests/Model/StageSimulatorTest.cs b/.Lib9c.Tests/Model/StageSimulatorTest.cs index 268a03cee8..5230301593 100644 --- a/.Lib9c.Tests/Model/StageSimulatorTest.cs +++ b/.Lib9c.Tests/Model/StageSimulatorTest.cs @@ -30,7 +30,7 @@ public StageSimulatorTest(ITestOutputHelper testOutputHelper) _tableSheets = new TableSheets(TableSheetsImporter.ImportSheets()); _random = new TestRandom(); - _avatarState = new AvatarState( + _avatarState = AvatarState.Create( default, default, 0, diff --git a/.Lib9c.Tests/Model/StageSimulatorV1Test.cs b/.Lib9c.Tests/Model/StageSimulatorV1Test.cs index 4e07e85e66..e05bd1620d 100644 --- a/.Lib9c.Tests/Model/StageSimulatorV1Test.cs +++ b/.Lib9c.Tests/Model/StageSimulatorV1Test.cs @@ -24,7 +24,7 @@ public StageSimulatorV1Test() _tableSheets = new TableSheets(TableSheetsImporter.ImportSheets()); _random = new TestRandom(); - _avatarState = new AvatarState( + _avatarState = AvatarState.Create( default, default, 0, diff --git a/.Lib9c.Tests/Model/State/AvatarStateTest.cs b/.Lib9c.Tests/Model/State/AvatarStateTest.cs index 7185b2f72e..7b8824dcff 100644 --- a/.Lib9c.Tests/Model/State/AvatarStateTest.cs +++ b/.Lib9c.Tests/Model/State/AvatarStateTest.cs @@ -70,7 +70,7 @@ public void UpdateFromQuestRewardDeterministic() var rankingState = new RankingState1(); Address avatarAddress = new PrivateKey().Address; Address agentAddress = new PrivateKey().Address; - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( avatarAddress, agentAddress, 0, @@ -480,7 +480,7 @@ private void ValidateEquipmentsV2(ItemSubType type, int count, int maxCount, lon private AvatarState GetNewAvatarState(Address avatarAddress, Address agentAddress) { var rankingState = new RankingState1(); - return new AvatarState( + return AvatarState.Create( avatarAddress, agentAddress, 0, diff --git a/.Lib9c.Tests/Model/State/RankingMapStateTest.cs b/.Lib9c.Tests/Model/State/RankingMapStateTest.cs index d724cb2dff..d512af6723 100644 --- a/.Lib9c.Tests/Model/State/RankingMapStateTest.cs +++ b/.Lib9c.Tests/Model/State/RankingMapStateTest.cs @@ -27,17 +27,16 @@ public void GetRankingInfos() for (var i = 0; i < 10; i++) { - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( _agentAddress.Derive(i.ToString()), _agentAddress, 0, _tableSheets.GetAvatarSheets(), _rankingMapAddress, "test" - ) - { - exp = 10 - i, - }; + ); + avatarState.exp = 10 - i; + state.Update(avatarState); } @@ -54,7 +53,7 @@ public void GetRankingInfos() public void Serialize() { var avatarAddress = _agentAddress.Derive("avatar"); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( avatarAddress, _agentAddress, 0, @@ -75,7 +74,7 @@ public void Serialize() public void SerializeEquals() { var avatarAddress = _agentAddress.Derive("avatar"); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( avatarAddress, _agentAddress, 0, @@ -85,7 +84,7 @@ public void SerializeEquals() ); var avatarAddress2 = _agentAddress.Derive("avatar2"); - var avatarState2 = new AvatarState( + var avatarState2 = AvatarState.Create( avatarAddress2, _agentAddress, 0, @@ -110,7 +109,7 @@ public void Update() { var avatarAddress = _agentAddress.Derive("avatar"); var rankingMapAddress = avatarAddress.Derive("ranking_map"); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( avatarAddress, _agentAddress, 0, diff --git a/.Lib9c.Tests/Model/State/ShardedShopStateV2Test.cs b/.Lib9c.Tests/Model/State/ShardedShopStateV2Test.cs index 1680de354b..e575d6f3e5 100644 --- a/.Lib9c.Tests/Model/State/ShardedShopStateV2Test.cs +++ b/.Lib9c.Tests/Model/State/ShardedShopStateV2Test.cs @@ -159,7 +159,7 @@ public void Serialize_DotNet_Api() public void Remove() { var tableSheets = new TableSheets(TableSheetsImporter.ImportSheets()); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( default, default, 0, diff --git a/.Lib9c.Tests/Model/State/WeeklyArenaStateTest.cs b/.Lib9c.Tests/Model/State/WeeklyArenaStateTest.cs index ac46a0f27a..6d83c8cadb 100644 --- a/.Lib9c.Tests/Model/State/WeeklyArenaStateTest.cs +++ b/.Lib9c.Tests/Model/State/WeeklyArenaStateTest.cs @@ -98,7 +98,7 @@ public void GetArenaInfosByFirstRankAndCount( for (var i = 0; i < infoCount; i++) { - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( new PrivateKey().Address, new PrivateKey().Address, 0L, @@ -131,7 +131,7 @@ public void GetArenaInfosByFirstRankAndCountThrow(int infoCount, int firstRank) for (var i = 0; i < infoCount; i++) { - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( new PrivateKey().Address, new PrivateKey().Address, 0L, @@ -170,7 +170,7 @@ public void GetArenaInfosByUpperAndLowerRange( targetAddress = avatarAddress; } - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( avatarAddress, new PrivateKey().Address, 0L, diff --git a/.Lib9c.Tests/TestHelper/BlockChainHelper.cs b/.Lib9c.Tests/TestHelper/BlockChainHelper.cs index 5c2d1dbc01..e119d8df0c 100644 --- a/.Lib9c.Tests/TestHelper/BlockChainHelper.cs +++ b/.Lib9c.Tests/TestHelper/BlockChainHelper.cs @@ -123,18 +123,17 @@ public static MakeInitialStateResult MakeInitialState() var agentState = new AgentState(agentAddress); var avatarAddress = new PrivateKey().Address; - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( avatarAddress, agentAddress, 0, tableSheets.GetAvatarSheets(), - rankingMapAddress) - { - worldInformation = new WorldInformation( - 0, - tableSheets.WorldSheet, - GameConfig.RequireClearedStageLevel.ActionsInShop), - }; + rankingMapAddress); + avatarState.worldInformation = new WorldInformation( + 0, + tableSheets.WorldSheet, + GameConfig.RequireClearedStageLevel.ActionsInShop); + agentState.avatarAddresses[0] = avatarAddress; var initCurrencyGold = goldCurrencyState.Currency * 100000000000; diff --git a/.Lib9c.Tests/Util/InitializeUtil.cs b/.Lib9c.Tests/Util/InitializeUtil.cs index c2e5b6b0f2..c92533ea5d 100644 --- a/.Lib9c.Tests/Util/InitializeUtil.cs +++ b/.Lib9c.Tests/Util/InitializeUtil.cs @@ -53,7 +53,7 @@ IWorld initialStatesWithAvatarState agentAddr ??= new PrivateKey().Address; var avatarAddr = Addresses.GetAvatarAddress(agentAddr.Value, avatarIndex); var agentState = new AgentState(agentAddr.Value); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( avatarAddr, agentAddr.Value, 0, diff --git a/Lib9c.DevExtensions/Action/CreateOrReplaceAvatar.cs b/Lib9c.DevExtensions/Action/CreateOrReplaceAvatar.cs index 78c09b6502..ce8d321297 100644 --- a/Lib9c.DevExtensions/Action/CreateOrReplaceAvatar.cs +++ b/Lib9c.DevExtensions/Action/CreateOrReplaceAvatar.cs @@ -414,20 +414,18 @@ public IWorld Execute( }); // Set AvatarState. - var avatar = new AvatarState( + var avatar = AvatarState.Create( avatarAddr, agentAddr, blockIndex, sheets.GetAvatarSheets(), default, - Name) - { - level = Level, - hair = Hair, - lens = Lens, - ear = Ear, - tail = Tail, - }; + Name); + avatar.level = Level; + avatar.hair = Hair; + avatar.lens = Lens; + avatar.ear = Ear; + avatar.tail = Tail; // ~Set AvatarState. // Set WorldInformation. diff --git a/Lib9c.DevExtensions/TestbedHelper.cs b/Lib9c.DevExtensions/TestbedHelper.cs index 793c8baf53..1970d5508a 100644 --- a/Lib9c.DevExtensions/TestbedHelper.cs +++ b/Lib9c.DevExtensions/TestbedHelper.cs @@ -39,20 +39,18 @@ public static AvatarState CreateAvatarState(string name, GameConfigState gameConfigState, Address rankingMapAddress) { - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( avatarAddress, agentAddress, blockIndex, avatarSheets, rankingMapAddress, name != string.Empty ? name : "testId" - ) - { - worldInformation = new WorldInformation( - 0, - worldSheet, - 0), - }; + ); + avatarState.worldInformation = new WorldInformation( + 0, + worldSheet, + 0); return avatarState; } diff --git a/Lib9c/Action/CreateAvatar.cs b/Lib9c/Action/CreateAvatar.cs index a51c91cade..3f9968d1ef 100644 --- a/Lib9c/Action/CreateAvatar.cs +++ b/Lib9c/Action/CreateAvatar.cs @@ -297,7 +297,7 @@ public static AvatarState CreateAvatarState(string name, { var state = ctx.PreviousState; var random = ctx.GetRandom(); - var avatarState = new AvatarState( + var avatarState = AvatarState.Create( avatarAddress, ctx.Signer, ctx.BlockIndex, diff --git a/Lib9c/Model/State/AvatarState.cs b/Lib9c/Model/State/AvatarState.cs index e6a6f7f7f6..a61e88edd6 100644 --- a/Lib9c/Model/State/AvatarState.cs +++ b/Lib9c/Model/State/AvatarState.cs @@ -68,11 +68,32 @@ public static Address CreateAvatarAddress() return key.PublicKey.Address; } - public AvatarState(Address address, + public static AvatarState Create(Address address, Address agentAddress, long blockIndex, AvatarSheets avatarSheets, Address rankingMapAddress, + string name = null) + { + var worldInformationVar = new WorldInformation(blockIndex, avatarSheets.WorldSheet, + GameConfig.IsEditor, name); + var questListVar = new QuestList( + avatarSheets.QuestSheet, + avatarSheets.QuestRewardSheet, + avatarSheets.QuestItemRewardSheet, + avatarSheets.EquipmentItemRecipeSheet, + avatarSheets.EquipmentItemSubRecipeSheet + ); + return new AvatarState( + address, agentAddress, blockIndex, questListVar, worldInformationVar, rankingMapAddress, name); + } + + public AvatarState(Address address, + Address agentAddress, + long blockIndex, + QuestList questList, + WorldInformation worldInformation, + Address rankingMapAddress, string name = null) : base(address) { Version = CurrentVersion; @@ -81,16 +102,10 @@ public AvatarState(Address address, level = 1; exp = 0; inventory = new Inventory(); - worldInformation = new WorldInformation(blockIndex, avatarSheets.WorldSheet, GameConfig.IsEditor, name); + this.worldInformation = worldInformation; updatedAt = blockIndex; this.agentAddress = agentAddress; - questList = new QuestList( - avatarSheets.QuestSheet, - avatarSheets.QuestRewardSheet, - avatarSheets.QuestItemRewardSheet, - avatarSheets.EquipmentItemRecipeSheet, - avatarSheets.EquipmentItemSubRecipeSheet - ); + this.questList = questList; mailBox = new MailBox(); this.blockIndex = blockIndex; stageMap = new CollectionMap();