Skip to content

Commit

Permalink
only sell full durability tools
Browse files Browse the repository at this point in the history
  • Loading branch information
dhvanipa committed Jun 5, 2024
1 parent 1da0326 commit f13da06
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/hardhat/contracts/SellChest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol";
import { IERC165 } from "@latticexyz/store/src/IERC165.sol";

import { ObjectType } from "@biomesaw/world/src/codegen/tables/ObjectType.sol";
import { ObjectTypeMetadata } from "@biomesaw/world/src/codegen/tables/ObjectTypeMetadata.sol";
import { ItemMetadata } from "@biomesaw/world/src/codegen/tables/ItemMetadata.sol";
import { ReversePlayer } from "@biomesaw/world/src/codegen/tables/ReversePlayer.sol";
import { ChestMetadata, ChestMetadataData } from "@biomesaw/world/src/codegen/tables/ChestMetadata.sol";

Expand Down Expand Up @@ -70,6 +72,12 @@ contract SellChest is IChestTransferHook {
if (chestShopData.objectTypeId != transferObjectTypeId) {
return false;
}
if (toolEntityId != bytes32(0)) {
require(
ItemMetadata.getNumUsesLeft(toolEntityId) == ObjectTypeMetadata.getDurability(chestShopData.objectTypeId),
"Tool must have full durability"
);
}

uint256 sellPrice = chestShopData.price;
if (sellPrice == 0) {
Expand Down

0 comments on commit f13da06

Please sign in to comment.