Skip to content

Commit

Permalink
Merge pull request #3060 from planetarium/release/1.20.2
Browse files Browse the repository at this point in the history
Release/1.20.2
  • Loading branch information
ipdae authored Dec 2, 2024
2 parents 2c2aa64 + 7bee0e5 commit 36447a9
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
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

0 comments on commit 36447a9

Please sign in to comment.