From 969935f9eb21747fcf5828dd4568a727ea1b97b6 Mon Sep 17 00:00:00 2001 From: lza_menace Date: Thu, 5 Jan 2023 15:56:59 -0800 Subject: [PATCH] start at token 1 --- src/Main.sol | 7 ++++--- src/Unaboomer.sol | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Main.sol b/src/Main.sol index ba87c92..980ba0a 100644 --- a/src/Main.sol +++ b/src/Main.sol @@ -222,12 +222,13 @@ 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 = unaboomer.totalSupply(); + uint256 killed = unaboomersKilled(); require(_amount <= bombBalance(msg.sender), "not enough bombs"); require(_amount <= supply, "not enough supply"); - require(_amount <= supply - unaboomersKilled(), "not enough active boomers"); + require(_amount <= supply - killed, "not enough active boomers"); for (uint256 i; i < _amount; i++) { - // Pick a pseudo-random Unaboomer token - uint256 randomBoomer = uint256(keccak256(abi.encodePacked(i, _amount, block.timestamp, msg.sender))) % supply; + // 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; // Check if it was already killed bool dud = unaboomer.tokenDead(randomBoomer); // Kill it (does nothing if already toggled as dead) diff --git a/src/Unaboomer.sol b/src/Unaboomer.sol index 197c7ad..d71bf3e 100644 --- a/src/Unaboomer.sol +++ b/src/Unaboomer.sol @@ -94,18 +94,18 @@ contract Unaboomer is ERC721, Owned { /// Mint tokens from main contract /// @param _to Address to mint BOOMR tokens to /// @param _amount Amount of BOOMR tokens to mint - function radicalize(address _to, uint256 _amount) external payable onlyMain { + function radicalize(address _to, uint256 _amount) external onlyMain { require(totalSupply() + _amount <= MAX_SUPPLY, "supply reached"); for (uint256 i; i < _amount; i++) { - _safeMint(_to, minted); minted++; + _safeMint(_to, minted); } } /// Toggle token state from living to dead /// @param tokenId Token ID of BOOMR to toggle living -> dead and increment kill count function die(uint256 tokenId) external onlyMain { - require(tokenId < totalSupply(), "invalid token id"); + require(tokenId <= totalSupply(), "invalid token id"); if (tokenDead[tokenId] == false) { totalKillCount++; tokenDead[tokenId] = true;