start at token 1

master
lza_menace 2 years ago
parent 06efb7d240
commit 969935f9eb

@ -222,12 +222,13 @@ contract Main is Owned {
function sendBombs(uint256 _amount) external missionNotCompleted { function sendBombs(uint256 _amount) external missionNotCompleted {
// Ensure _amount will not exceed wallet balance of bombs, Unaboomer supply, and active Unaboomers // Ensure _amount will not exceed wallet balance of bombs, Unaboomer supply, and active Unaboomers
uint256 supply = unaboomer.totalSupply(); uint256 supply = unaboomer.totalSupply();
uint256 killed = unaboomersKilled();
require(_amount <= bombBalance(msg.sender), "not enough bombs"); require(_amount <= bombBalance(msg.sender), "not enough bombs");
require(_amount <= supply, "not enough supply"); 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++) { for (uint256 i; i < _amount; i++) {
// Pick a pseudo-random Unaboomer token // Pick a pseudo-random Unaboomer token - imperfectly derives token IDs so that repeats are probable
uint256 randomBoomer = uint256(keccak256(abi.encodePacked(i, _amount, block.timestamp, msg.sender))) % supply; uint256 randomBoomer = (uint256(keccak256(abi.encodePacked(i, _amount, killed, block.timestamp, msg.sender))) % supply) + 1;
// Check if it was already killed // Check if it was already killed
bool dud = unaboomer.tokenDead(randomBoomer); bool dud = unaboomer.tokenDead(randomBoomer);
// Kill it (does nothing if already toggled as dead) // Kill it (does nothing if already toggled as dead)

@ -94,18 +94,18 @@ contract Unaboomer is ERC721, Owned {
/// Mint tokens from main contract /// Mint tokens from main contract
/// @param _to Address to mint BOOMR tokens to /// @param _to Address to mint BOOMR tokens to
/// @param _amount Amount of BOOMR tokens to mint /// @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"); require(totalSupply() + _amount <= MAX_SUPPLY, "supply reached");
for (uint256 i; i < _amount; i++) { for (uint256 i; i < _amount; i++) {
_safeMint(_to, minted);
minted++; minted++;
_safeMint(_to, minted);
} }
} }
/// Toggle token state from living to dead /// Toggle token state from living to dead
/// @param tokenId Token ID of BOOMR to toggle living -> dead and increment kill count /// @param tokenId Token ID of BOOMR to toggle living -> dead and increment kill count
function die(uint256 tokenId) external onlyMain { function die(uint256 tokenId) external onlyMain {
require(tokenId < totalSupply(), "invalid token id"); require(tokenId <= totalSupply(), "invalid token id");
if (tokenDead[tokenId] == false) { if (tokenDead[tokenId] == false) {
totalKillCount++; totalKillCount++;
tokenDead[tokenId] = true; tokenDead[tokenId] = true;

Loading…
Cancel
Save