master
lza_menace 1 year ago
parent 053470d648
commit 1c21b158c4

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

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

@ -1,15 +1,6 @@
// 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 {ERC721A} from "erc721a/ERC721A.sol";
import {Owned} from "solmate/auth/Owned.sol";
import {LibString} from "solmate/utils/LibString.sol";
@ -58,7 +49,8 @@ contract Unaboomer is ERC721A, Owned {
// =========================================================================
// Modifiers
// =========================================================================
/// Only main address can mint
modifier onlyMain {
require(msg.sender == address(main), "invalid minter");
_;
@ -75,8 +67,8 @@ contract Unaboomer is ERC721A, Owned {
}
/// Toggle token state from living to dead
function kill(uint256 tokenId) external onlyMain {
require(tokenId <= totalSupply(), "invalid token id");
function die(uint256 tokenId) external onlyMain {
require(tokenId < totalSupply(), "invalid token id");
if (tokenDead[tokenId] == false) {
killCount++;
tokenDead[tokenId] = true;
@ -84,7 +76,7 @@ contract Unaboomer is ERC721A, Owned {
}
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"));
} else {
return string(abi.encodePacked(aliveURI, _tokenId.toString(), ".json"));

@ -51,6 +51,34 @@ contract UnaboomerTest is Test {
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