Skip to content

Commit

Permalink
Merge branch 'feature/adventure-boss' into feature/adv-boss/simulator
Browse files Browse the repository at this point in the history
  • Loading branch information
U-lis authored Jun 10, 2024
2 parents 94b9096 + f8761e1 commit 58a418c
Show file tree
Hide file tree
Showing 255 changed files with 18,030 additions and 17,634 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class UnlockCraftActionTest

public UnlockCraftActionTest()
{
(_tableSheets, _agentAddress, _avatarAddress, _, _initialStateV2) =
(_tableSheets, _agentAddress, _avatarAddress, _initialStateV2) =
InitializeUtil.InitializeStates(isDevEx: true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class UnlockRecipeTest

public UnlockRecipeTest()
{
(_tableSheets, _agentAddress, _avatarAddress, _, _initialStateV2) =
(_tableSheets, _agentAddress, _avatarAddress, _initialStateV2) =
InitializeUtil.InitializeStates(isDevEx: true);
_recipeAddress = _avatarAddress.Derive("recipe_ids");
}
Expand Down
12 changes: 6 additions & 6 deletions .Lib9c.DevExtensions.Tests/Action/ManipulateStateTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class ManipulateStateTest

public ManipulateStateTest()
{
(_tableSheets, _agentAddress, _avatarAddress, _, _initialStateV2) =
(_tableSheets, _agentAddress, _avatarAddress, _initialStateV2) =
InitializeUtil.InitializeStates(
adminAddr: AdminAddr,
isDevEx: true);
Expand Down Expand Up @@ -111,7 +111,7 @@ public ManipulateStateTest()
public static IEnumerable<object[]> FetchInventory()
{
var random = new TestRandom();
var (tableSheets, _, _, _, _) = InitializeUtil.InitializeStates(isDevEx: true);
var (tableSheets, _, _, _) = InitializeUtil.InitializeStates(isDevEx: true);
var equipmentList = tableSheets.EquipmentItemSheet.Values.ToList();
var consumableList = tableSheets.ConsumableItemSheet.Values.ToList();
var materialList = tableSheets.MaterialItemSheet.Values.ToList();
Expand Down Expand Up @@ -170,7 +170,7 @@ public static IEnumerable<object[]> FetchInventory()
public static IEnumerable<object[]> FetchWorldInfo()
{
var random = new Random();
var (tableSheets, _, _, _, _) = InitializeUtil.InitializeStates(isDevEx: true);
var (tableSheets, _, _, _) = InitializeUtil.InitializeStates(isDevEx: true);
var worldSheet = tableSheets.WorldSheet;
yield return new object[]
{
Expand All @@ -195,7 +195,7 @@ public static IEnumerable<object[]> FetchWorldInfo()
public static IEnumerable<object[]> FetchQuest()
{
var random = new Random();
var (tableSheets, _, _, _, stateV2) = InitializeUtil.InitializeStates(isDevEx: true);
var (tableSheets, _, _, stateV2) = InitializeUtil.InitializeStates(isDevEx: true);
// Empty QuestList
yield return new object[]
{
Expand Down Expand Up @@ -455,7 +455,7 @@ public void SetAvatarState(
_initialStateV2,
new List<(Address, Address, IValue)>
{
(Addresses.Avatar, _avatarAddress, MigrationAvatarState.LegacySerializeV2(newAvatarState))
(Addresses.Avatar, _avatarAddress, newAvatarState.SerializeList())
},
new List<(Address, FungibleAssetValue)>()
);
Expand Down Expand Up @@ -547,7 +547,7 @@ public void SetWorldInformation(int lastClearedStage, WorldInformation targetInf
_initialStateV2,
new List<(Address, Address, IValue)>
{
(ReservedAddresses.LegacyAccount, _avatarAddress.Derive(SerializeKeys.LegacyWorldInformationKey), targetInfo.Serialize())
(Addresses.WorldInformation, _avatarAddress, targetInfo.Serialize())
},
new List<(Address, FungibleAssetValue)>()
);
Expand Down
2 changes: 1 addition & 1 deletion .Lib9c.DevExtensions.Tests/Action/Stage/ClearStageTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class ClearStageTest

public ClearStageTest()
{
(_tableSheets, _agentAddress, _avatarAddress, _, _initialStateV2) =
(_tableSheets, _agentAddress, _avatarAddress, _initialStateV2) =
InitializeUtil.InitializeStates(isDevEx: true);
}

Expand Down
19 changes: 3 additions & 16 deletions .Lib9c.Tests/Action/AccountStateViewExtensionsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,23 +128,10 @@ public void GetAvatarStateV2_Throw_FailedLoadStateException(string account)
Assert.Contains(account, exc.Message);
}

[Theory]
[InlineData(true)]
[InlineData(false)]
public void TryGetAvatarState(bool backward)
[Fact]
public void TryGetAvatarState()
{
IWorld states = new World(MockUtil.MockModernWorldState);
if (backward)
{
states = states
.SetLegacyState(_avatarAddress, MigrationAvatarState.LegacySerializeV1(_avatarState));
}
else
{
states = states
.SetAvatarState(_avatarAddress, _avatarState);
}

IWorld states = new World(MockUtil.MockModernWorldState).SetAvatarState(_avatarAddress, _avatarState);
Assert.True(states.TryGetAvatarState(_agentAddress, _avatarAddress, out _));
}

Expand Down
2 changes: 1 addition & 1 deletion .Lib9c.Tests/Action/ActionContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class ActionContext : IActionContext

public long BlockIndex { get; set; }

public int BlockProtocolVersion { get; set; }
public int BlockProtocolVersion { get; set; } = BlockMetadata.CurrentProtocolVersion;

public IWorld PreviousState { get; set; }

Expand Down
5 changes: 0 additions & 5 deletions .Lib9c.Tests/Action/ActionEvaluationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public ActionEvaluationTest()
[InlineData(typeof(InitializeStates))]
[InlineData(typeof(ItemEnhancement))]
[InlineData(typeof(MigrationActivatedAccountsState))]
[InlineData(typeof(MigrationAvatarState))]
[InlineData(typeof(PatchTableSheet))]
[InlineData(typeof(RankingBattle))]
[InlineData(typeof(RapidCombination))]
Expand Down Expand Up @@ -198,10 +197,6 @@ private ActionBase GetAction(Type type)
materialIds = new List<Guid>(),
},
MigrationActivatedAccountsState _ => new MigrationActivatedAccountsState(),
MigrationAvatarState _ => new MigrationAvatarState
{
avatarStates = new List<Dictionary>(),
},
PatchTableSheet _ => new PatchTableSheet
{
TableCsv = "table",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ AdventureBossGameData.ClaimableReward expectedReward
var potion = ItemFactory.CreateMaterial(materialRow);
for (var i = 0; i < anotherExplorerCount; i++)
{
var inventory = state.GetInventory(ExplorerAvatarAddress);
var inventory = state.GetInventoryV2(ExplorerAvatarAddress);
inventory.AddItem(potion, 1);
state = state.SetInventory(ExplorerAvatarAddress, inventory);
state = new ExploreAdventureBoss
Expand Down Expand Up @@ -970,7 +970,7 @@ private void Test(IWorld world, AdventureBossGameData.ClaimableReward expectedRe
);
}

var inventory = world.GetInventory(TesterAvatarAddress);
var inventory = world.GetInventoryV2(TesterAvatarAddress);
foreach (var item in expectedReward.ItemReward)
{
var itemState = inventory.Items.FirstOrDefault(i => i.item.Id == item.Key);
Expand Down
6 changes: 3 additions & 3 deletions .Lib9c.Tests/Action/AdventureBoss/ExploreAdventureBossTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public void Execute(

if (initialPotion > 0)
{
var inventory = state.GetInventory(TesterAvatarAddress);
var inventory = state.GetInventoryV2(TesterAvatarAddress);
inventory.AddItem(apPotion, initialPotion);
state = state.SetInventory(TesterAvatarAddress, inventory);
}
Expand Down Expand Up @@ -194,7 +194,7 @@ public void Execute(
BlockIndex = 1L,
});

var potion = state.GetInventory(TesterAvatarAddress).Items
var potion = state.GetInventoryV2(TesterAvatarAddress).Items
.FirstOrDefault(i => i.item.ItemSubType == ItemSubType.ApStone);
if (expectedPotion == 0)
{
Expand All @@ -211,7 +211,7 @@ public void Execute(
Assert.Equal(initialPotion - expectedPotion, exploreBoard.UsedApPotion);
Assert.Equal(expectedFloor, explorer.Floor);

var inventory = state.GetInventory(TesterAvatarAddress);
var inventory = state.GetInventoryV2(TesterAvatarAddress);
foreach (var (id, amount) in expectedRewards)
{
if (amount == 0)
Expand Down
6 changes: 3 additions & 3 deletions .Lib9c.Tests/Action/AdventureBoss/SweepAdventureBossTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public void Execute(
materialSheet.OrderedList.First(row => row.ItemSubType == ItemSubType.ApStone);
var apPotion = ItemFactory.CreateMaterial(materialRow);

var inventory = state.GetInventory(TesterAvatarAddress);
var inventory = state.GetInventoryV2(TesterAvatarAddress);
inventory.AddItem(apPotion, initialPotion);
state = state.SetInventory(TesterAvatarAddress, inventory);

Expand Down Expand Up @@ -175,7 +175,7 @@ public void Execute(
BlockIndex = 1L,
});

var potion = state.GetInventory(TesterAvatarAddress).Items
var potion = state.GetInventoryV2(TesterAvatarAddress).Items
.FirstOrDefault(i => i.item.ItemSubType == ItemSubType.ApStone);
if (expectedPotion == 0)
{
Expand All @@ -195,7 +195,7 @@ public void Execute(
Assert.Equal(floor * SweepAdventureBoss.UnitApPotion, exploreBoard.UsedApPotion);
Assert.Equal(explorer.UsedApPotion, exploreBoard.UsedApPotion);

inventory = state.GetInventory(TesterAvatarAddress);
inventory = state.GetInventoryV2(TesterAvatarAddress);
foreach (var (id, amount) in expectedRewards)
{
if (amount == 0)
Expand Down
4 changes: 2 additions & 2 deletions .Lib9c.Tests/Action/AdventureBoss/UnlockFloorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public void Execute(bool useNcg, bool notEnough, int startFloor, int expectedFlo
}
else
{
var inventory = state.GetInventory(TesterAvatarAddress);
var inventory = state.GetInventoryV2(TesterAvatarAddress);
inventory.AddItem(goldenDust, 5);
state = state.SetInventory(TesterAvatarAddress, inventory);
}
Expand Down Expand Up @@ -174,7 +174,7 @@ public void Execute(bool useNcg, bool notEnough, int startFloor, int expectedFlo
Assert.Equal(0 * NCG, resultState.GetBalance(TesterAddress, NCG));
if (!useNcg)
{
var inventory = resultState.GetInventory(TesterAvatarAddress);
var inventory = resultState.GetInventoryV2(TesterAvatarAddress);
Assert.Null(inventory.Items.FirstOrDefault(i => i.item.Id == 600202));
}

Expand Down
Loading

0 comments on commit 58a418c

Please sign in to comment.