splitting
parent
9039b6562e
commit
4393670e6d
@ -0,0 +1,115 @@
|
||||
// SPDX-License-Identifier: UNLICENSED
|
||||
pragma solidity ^0.8.13;
|
||||
|
||||
|
||||
/******* Mint Mechanics
|
||||
.00 per unaboomer (BOOMR) - 10k supply
|
||||
.02 per bomb (BOMB) - infinite supply
|
||||
BOMB holders can randomly mail bombs to other owners
|
||||
1 BOMB kills 1 BOOMR - BOOMR image switches to explosion after being bombed
|
||||
chaos ensues until 1000 survivors - the game stops
|
||||
********/
|
||||
|
||||
import {ERC721} from "solmate/tokens/ERC721.sol";
|
||||
import {Owned} from "solmate/auth/Owned.sol";
|
||||
import {LibString} from "solmate/utils/LibString.sol";
|
||||
|
||||
import {Boomer} from "./Boomer.sol";
|
||||
import {Mailbomb} from "./Mailbomb.sol";
|
||||
|
||||
error NotEnoughEther();
|
||||
error NotOwnerOfToken();
|
||||
error MaxSupplyReached();
|
||||
error TooMany();
|
||||
error NoContract();
|
||||
error WrongEtherAmount();
|
||||
error MaxAmountReached();
|
||||
error NoAdmins();
|
||||
error NotAdmin();
|
||||
error NoRemoveSelf();
|
||||
error NoRemoveDeployer();
|
||||
error NotEnoughBombs();
|
||||
|
||||
// mintBoomer
|
||||
// mintBomb
|
||||
// mailBombs
|
||||
|
||||
contract Unaboomer is Owned {
|
||||
using LibString for uint256;
|
||||
|
||||
uint256 public price = 0.01 ether;
|
||||
uint256 public minted;
|
||||
string public baseURI;
|
||||
|
||||
Unaboomer public UnaboomerContract;
|
||||
|
||||
constructor() ERC721("Mailbomb", "BOMB") Owned(msg.sender) {}
|
||||
|
||||
// =========================================================================
|
||||
// Admin
|
||||
// =========================================================================
|
||||
|
||||
/// Withdraw funds to contract owner
|
||||
function withdraw() external onlyOwner {
|
||||
uint256 balance = address(this).balance;
|
||||
payable(msg.sender).transfer(balance);
|
||||
}
|
||||
|
||||
/// Set price for 1 BOMB
|
||||
function setPrice(uint256 _price) external onlyOwner {
|
||||
price = _price;
|
||||
}
|
||||
|
||||
/// Set metadata URI for alive BOOMR
|
||||
function setBaseURI(string calldata _baseURI) external onlyOwner {
|
||||
baseURI = _baseURI;
|
||||
}
|
||||
|
||||
/// Set contract address for Unaboomer tokens
|
||||
function setUnaboomerContract(address _address) external onlyOwner {
|
||||
UnaboomerContract = Unaboomer(_address);
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// Tokens
|
||||
// =========================================================================
|
||||
|
||||
function assembleBomb(uint256 _amount) external payable {
|
||||
if (msg.value < _amount * price) revert NotEnoughEther();
|
||||
unchecked {
|
||||
for (uint256 i; i < _amount; i++) {
|
||||
_mint(msg.sender, minted + 1);
|
||||
minted++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Send N bombs to pseudo-random Unaboomer tokenIds to potentially kill them.
|
||||
/// If the Unaboomer is already dead, the bomb is considered a dud.
|
||||
/// @dev Pick a pseudo-random tokenID from Unaboomer contract and toggle a mapping value
|
||||
function mailBombs(uint256[] calldata tokenIds) external returns (bool[] memory results) {
|
||||
if (tokenIds.length > balanceOf(msg.sender)) revert NotEnoughBombs();
|
||||
bool[] memory res = new bool[](tokenIds.length);
|
||||
uint256 boomerSupply = UnaboomerContract.totalSupply();
|
||||
for (uint256 i; i < tokenIds.length; i++) {
|
||||
if (ownerOf(tokenIds[i]) != msg.sender) revert NotOwnerOfToken();
|
||||
uint256 randomBoomer = uint256(keccak256(abi.encodePacked(tokenIds[i], block.timestamp, msg.sender))) % boomerSupply;
|
||||
_burn(tokenIds[i]);
|
||||
bool _res = UnaboomerContract.killBoomer(randomBoomer);
|
||||
res[i] = _res;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
function totalSupply() view public returns (uint256 supply) {
|
||||
return minted;
|
||||
}
|
||||
|
||||
function tokenURI(uint256 _tokenId) public view override returns (string memory) {
|
||||
return string(abi.encodePacked(baseURI, _tokenId.toString(), ".json"));
|
||||
}
|
||||
|
||||
function supportsInterface(bytes4 interfaceId) public view virtual override (ERC721) returns (bool) {
|
||||
return super.supportsInterface(interfaceId);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue