Add random number to the basics of attributes, varying and decentralizing the character attributes
function rand(uint256 _length) internal returns (uint256) {
uint256 random = uint256(keccak256(abi.encodePacked(block.difficulty, block.timestamp, randomSeed)));
randomSeed ++;
return random % _length + 1;
}
Contract creators can customize the attribute list of their gaming characters based on their preference, to better integrate their own game.
When trading NFT, developers can also setup the transferable functionality based on the token ID, to ensure the liquidity boundary of the assets, which means one can determine where the NFT can be traded.
How to interact with character's smart contract
interface ICharacter {
function getGender(uint tokenId_) external view returns (uint);
function getAttack(uint tokenId_) external view returns (uint);
function getStamina(uint tokenId_) external view returns (uint);
function getDefense(uint tokenId_) external view returns (uint);
function getPower(uint tokenId_) external view returns (uint);
function getLife(uint tokenId_) external view returns (uint);
function getBronTime(uint tokenId_) external view returns (uint);
function getGrowth(uint tokenId_) external view returns (uint);
function mintNormall(address player, uint[2] memory parents) external;
function mint(address player) external;
function growUp(uint tokenId_) external;
function isCreation(uint tokenId_) external view returns (bool);
function burn(uint tokenId_) external returns (bool);
function deadTime(uint tokenId_) external view returns (uint);
function addDeadTime(uint tokenId, uint time_) external;
function getStar(uint tokenId_) external view returns(uint);
function mintNormallWithParents(address player) external;
function upGradeStar(uint tokenId) external;
}