Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/1.20.2 #3060

Merged
merged 2 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .Lib9c.Tests/Action/ItemEnhancementTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -544,5 +544,46 @@ public void Execute_With_Hammer(bool oldStart)
Assert.Equal(preItemUsable.ItemId, resultEquipment.ItemId);
Assert.Equal(expectedCost, slotResult.gold);
}

[Theory]
[InlineData(true)]
[InlineData(false)]
public void Execute_Throw_InvalidItemTypeException(bool withMaterials)
{
var types = ItemEnhancement.HammerBannedTypes;
foreach (var itemSubType in types)
{
var row =
_tableSheets.EquipmentItemSheet.Values.First(r => r.ItemSubType == itemSubType);
var equipment = ItemFactory.CreateItemUsable(row, Guid.NewGuid(), 0);
_avatarState.inventory.AddItem(equipment);
_initialState = _initialState.SetAvatarState(_avatarAddress, _avatarState);
var materialIds = new List<Guid>();
if (withMaterials)
{
materialIds.Add(Guid.NewGuid());
materialIds.Add(Guid.NewGuid());
}

var action = new ItemEnhancement
{
itemId = equipment.ItemId,
materialIds = materialIds,
avatarAddress = _avatarAddress,
slotIndex = 0,
hammers = new Dictionary<int, int>
{
[600301] = 3,
},
};
Assert.Throws<InvalidItemTypeException>(() => action.Execute(new ActionContext
{
BlockIndex = 1,
PreviousState = _initialState,
RandomSeed = 0,
Signer = _agentAddress,
}));
}
}
}
}
3 changes: 2 additions & 1 deletion Lib9c/Action/ItemEnhancement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ public override IWorld Execute(IActionContext context)

// Validate enhancement materials
var uniqueMaterialIds = materialIds.Distinct().ToList();
if (!uniqueMaterialIds.Any())
// Validate hammer without materials count
if (hammers.Any())
{
if (HammerBannedTypes.Contains(enhancementEquipment.ItemSubType))
{
Expand Down
Loading