// Each uint is tokenID in Items contract // This example is not optimized for memory, // possible select smaller uint data types (uint16, uint32) to conserve memory? struct Robot { // uint refers to ERC-1155 tokenId uint head; uint leftArm; uint rightArm; uint legs; uint torso; uint background; } mapping(uint => Robot[]) public equippedRobotParts; //parent id => Robot data structure for child items // When swapping parts, check for item type match; something like this... function swapParts(erc721TokenId, erc1155TokenID_OLD, erc1155TokenID_NEW) { require(Items.itemType(erc1155TokenID_OLD) == Items.itemType(erc1155TokenID_NEW), "part types don't match"); uint itemType = Items.itemType(erc1155TokenID_OLD); // transfer tokens equippedRobotParts[erc721TokenId][itemType] = erc1155TokenID_NEW; // equip to data structure }
0.4.18