Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
ipdae committed Dec 3, 2024
1 parent 2f0960d commit aa0345f
Show file tree
Hide file tree
Showing 6 changed files with 287 additions and 180 deletions.
76 changes: 76 additions & 0 deletions .Lib9c.Tests/Action/Scenario/AuraScenarioTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,82 @@ public void Market()
}));
}

[Fact]
public void Combination()
{
var row = _tableSheets.EquipmentItemRecipeSheet.Values.FirstOrDefault(r =>
r.ItemSubType == ItemSubType.Aura && r.MaterialId > 0 && r.RequiredBlockIndex > 0);
var prevState = _initialState;
if (row is not null)
{
var avatarState = _initialState.GetAvatarState(_avatarAddress);
var inventory = avatarState.inventory;
var material =
ItemFactory.CreateMaterial(_tableSheets.MaterialItemSheet[row.MaterialId]);
inventory.AddItem(material, row.MaterialCount);
prevState = prevState.SetInventory(_avatarAddress, inventory);

var action = new CombinationEquipment
{
avatarAddress = _avatarAddress,
slotIndex = 0,
recipeId = row.Id,
subRecipeId = null,
payByCrystal = false,
useHammerPoint = false,
petId = null,
};

var nextState = action.Execute(new ActionContext
{
BlockIndex = 0,
PreviousState = prevState,
RandomSeed = 0,
Signer = _agentAddress,
});

var nextInventory = nextState.GetInventoryV2(_avatarAddress);
Assert.True(nextInventory.TryGetItem(row.ResultEquipmentId, out var item));
var aura = (Aura)item.item;
Assert.False(aura.equipped);
Assert.Equal(row.RequiredBlockIndex, aura.RequiredBlockIndex);

var has = new HackAndSlash
{
StageId = 1,
AvatarAddress = _avatarAddress,
Equipments = new List<Guid>
{
aura.ItemId,
},
Costumes = new List<Guid>(),
Foods = new List<Guid>(),
WorldId = 1,
RuneInfos = new List<RuneSlotInfo>(),
};

Assert.Throws<RequiredBlockIndexException>(() => has.Execute(new ActionContext
{
BlockIndex = 0,
PreviousState = nextState,
RandomSeed = 0,
Signer = _agentAddress,
}));

var equippedState = has.Execute(new ActionContext
{
BlockIndex = aura.RequiredBlockIndex,
PreviousState = nextState,
RandomSeed = 0,
Signer = _agentAddress,
});

nextInventory = equippedState.GetInventoryV2(_avatarAddress);
nextInventory.TryGetNonFungibleItem(aura.ItemId, out Aura aura2);
Assert.True(aura2.equipped);
}
}

private void Assert_Player(AvatarState avatarState, IWorld state, Address avatarAddress, Address itemSlotStateAddress)
{
var nextAvatarState = state.GetAvatarState(avatarAddress);
Expand Down
4 changes: 3 additions & 1 deletion Lib9c/TableCSV/Crystal/CrystalHammerPointSheet.csv
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,6 @@ recipe_ID,max_hammer_count,crystal_cost
210,40,20000000
211,40,20000000
212,40,20000000
213,40,20000000
213,40,20000000
256,9999999,999999999
257,9999999,999999999
Loading

0 comments on commit aa0345f

Please sign in to comment.