From 0f26fdfaf56c6d7ac810008d9f67d86f656d19b5 Mon Sep 17 00:00:00 2001 From: lza_menace Date: Mon, 9 Jan 2023 10:40:43 -0800 Subject: [PATCH] add func to get BOOMR mint amount, simplify sendBombs --- src/Main.sol | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Main.sol b/src/Main.sol index cfa621e..6d60b02 100644 --- a/src/Main.sol +++ b/src/Main.sol @@ -152,6 +152,13 @@ contract Main is Owned { return unaboomer.balanceOf(_address); } + /// Get BOOMR amount minted (including ones that have been burned/killed) + /// @param _address Wallet address to query the amount of BOOMR token minted + /// @return balance Amount of BOOMR tokens that have been minted by _address + function unaboomersMinted(address _address) public view returns (uint256) { + return unaboomer.tokensMintedByWallet(_address); + } + /// Get BOOMR token total supply /// @return supply Amount of BOOMR tokens minted in total function unaboomersRadicalized() public view returns (uint256) { @@ -229,21 +236,18 @@ contract Main is Owned { function sendBombs(uint256 _amount) external missionNotCompleted { // Ensure _amount will not exceed wallet balance of bombs, Unaboomer supply, and active Unaboomers uint256 supply = unaboomersRadicalized(); - uint256 killed = unaboomersKilled(); require(_amount <= bombBalance(msg.sender), "not enough bombs"); - require(_amount <= supply, "not enough supply"); - require(_amount <= supply - killed, "not enough active boomers"); for (uint256 i; i < _amount; i++) { // Pick a pseudo-random Unaboomer token - imperfectly derives token IDs so that repeats are probable - uint256 randomBoomer = (uint256(keccak256(abi.encodePacked(i, _amount, killed, block.timestamp, msg.sender))) % supply) + 1; + uint256 randomBoomer = (uint256(keccak256(abi.encodePacked(i, block.timestamp, msg.sender))) % supply) + 1; // Capture owner address _owner = unaboomer.ownerOf(randomBoomer); // Check if it was already killed bool dud = _owner == address(0); + // Check if the sender owns it (misfired, killed own pfp) + bool senderOwned = msg.sender == _owner; // Kill it (does nothing if already toggled as dead) unaboomer.die(randomBoomer); - // Check if the sender owns it (misfired, kills own pfp) - bool senderOwned = msg.sender == _owner; // Emit event for displaying in web app emit SentBomb(msg.sender, randomBoomer, !dud, senderOwned); // Increment kill count if successfully killed another player's Unaboomer