master
lza_menace 2 years ago
parent 053470d648
commit 1c21b158c4

@ -1,15 +1,6 @@
// SPDX-License-Identifier: UNLICENSED // SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13; 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 {ERC1155} from "solmate/tokens/ERC1155.sol"; import {ERC1155} from "solmate/tokens/ERC1155.sol";
import {Owned} from "solmate/auth/Owned.sol"; import {Owned} from "solmate/auth/Owned.sol";
import {LibString} from "solmate/utils/LibString.sol"; import {LibString} from "solmate/utils/LibString.sol";
@ -48,6 +39,7 @@ contract Mailbomb is ERC1155, Owned {
// Modifiers // Modifiers
// ========================================================================= // =========================================================================
/// Only main address can mint
modifier onlyMain { modifier onlyMain {
require(msg.sender == address(main), "invalid minter"); require(msg.sender == address(main), "invalid minter");
_; _;

@ -91,13 +91,14 @@ contract Main is Owned {
uint256[] memory tokensKilled uint256[] memory tokensKilled
) { ) {
require(_amount <= mailbomb.balanceOf(msg.sender, 1), "not enough bombs"); require(_amount <= mailbomb.balanceOf(msg.sender, 1), "not enough bombs");
require(_amount <= unaboomer.totalSupply(), "not enough supply");
bool[] memory res = new bool[](_amount); bool[] memory res = new bool[](_amount);
uint256[] memory killed = new uint256[](_amount); uint256[] memory killed = new uint256[](_amount);
uint256 boomerSupply = unaboomer.totalSupply(); uint256 boomerSupply = unaboomer.totalSupply();
for (uint256 i; i < _amount; i++) { for (uint256 i; i < _amount; i++) {
uint256 randomBoomer = uint256(keccak256(abi.encodePacked(i, block.timestamp, msg.sender))) % boomerSupply; uint256 randomBoomer = uint256(keccak256(abi.encodePacked(i, block.timestamp, msg.sender))) % boomerSupply;
bool dud = unaboomer.tokenDead(randomBoomer); bool dud = unaboomer.tokenDead(randomBoomer);
unaboomer.kill(randomBoomer); unaboomer.die(randomBoomer);
res[i] = dud; res[i] = dud;
killed[i] = randomBoomer; killed[i] = randomBoomer;
} }

@ -1,15 +1,6 @@
// SPDX-License-Identifier: UNLICENSED // SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13; 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 {ERC721A} from "erc721a/ERC721A.sol"; import {ERC721A} from "erc721a/ERC721A.sol";
import {Owned} from "solmate/auth/Owned.sol"; import {Owned} from "solmate/auth/Owned.sol";
import {LibString} from "solmate/utils/LibString.sol"; import {LibString} from "solmate/utils/LibString.sol";
@ -59,6 +50,7 @@ contract Unaboomer is ERC721A, Owned {
// Modifiers // Modifiers
// ========================================================================= // =========================================================================
/// Only main address can mint
modifier onlyMain { modifier onlyMain {
require(msg.sender == address(main), "invalid minter"); require(msg.sender == address(main), "invalid minter");
_; _;
@ -75,8 +67,8 @@ contract Unaboomer is ERC721A, Owned {
} }
/// Toggle token state from living to dead /// Toggle token state from living to dead
function kill(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) {
killCount++; killCount++;
tokenDead[tokenId] = true; tokenDead[tokenId] = true;
@ -84,7 +76,7 @@ contract Unaboomer is ERC721A, Owned {
} }
function tokenURI(uint256 _tokenId) public view override returns (string memory) { function tokenURI(uint256 _tokenId) public view override returns (string memory) {
if (tokenDead[_tokenId]) { if (tokenDead[_tokenId] == true) {
return string(abi.encodePacked(deadURI, _tokenId.toString(), ".json")); return string(abi.encodePacked(deadURI, _tokenId.toString(), ".json"));
} else { } else {
return string(abi.encodePacked(aliveURI, _tokenId.toString(), ".json")); return string(abi.encodePacked(aliveURI, _tokenId.toString(), ".json"));

@ -51,6 +51,34 @@ contract UnaboomerTest is Test {
console.log(boomr.killCount()); console.log(boomr.killCount());
} }
// function testX() public {} function testKilling() public {
address t = address(1);
startHoax(t);
main.assembleBombs{value: .1 ether}(10);
vm.expectRevert(bytes("not enough supply"));
main.sendBombs(10);
main.radicalizeBoomers{value: .1 ether}(10);
main.sendBombs(10);
assertEq(bomb.balanceOf(t, 1), 20);
}
function testFailDirectFunctions() public {
address t = address(1);
startHoax(t);
boomr.radicalize(t, 10);
boomr.die(1);
bomb.create(t, 10);
bomb.explode(t, 10);
}
function testURILogic() public {
address t = address(1);
boomr.setAliveURI('ipfs://alive/');
boomr.setDeadURI('ipfs://dead/');
startHoax(t);
main.radicalizeBoomers{value: .01 ether}(1);
assertEq(boomr.tokenURI(0), 'ipfs://alive/0.json');
main.sendBombs(1);
assertEq(boomr.tokenURI(0), 'ipfs://dead/0.json');
}
} }

Loading…
Cancel
Save