add func to get BOOMR mint amount, simplify sendBombs

master
lza_menace 1 year ago
parent b62b926ada
commit 0f26fdfaf5

@ -152,6 +152,13 @@ contract Main is Owned {
return unaboomer.balanceOf(_address);
}
/// Get BOOMR amount minted (including ones that have been burned/killed)
/// @param _address Wallet address to query the amount of BOOMR token minted
/// @return balance Amount of BOOMR tokens that have been minted by _address
function unaboomersMinted(address _address) public view returns (uint256) {
return unaboomer.tokensMintedByWallet(_address);
}
/// Get BOOMR token total supply
/// @return supply Amount of BOOMR tokens minted in total
function unaboomersRadicalized() public view returns (uint256) {
@ -229,21 +236,18 @@ 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 = unaboomersRadicalized();
uint256 killed = unaboomersKilled();
require(_amount <= bombBalance(msg.sender), "not enough bombs");
require(_amount <= supply, "not enough supply");
require(_amount <= supply - killed, "not enough active boomers");
for (uint256 i; i < _amount; i++) {
// 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;
uint256 randomBoomer = (uint256(keccak256(abi.encodePacked(i, block.timestamp, msg.sender))) % supply) + 1;
// Capture owner
address _owner = unaboomer.ownerOf(randomBoomer);
// Check if it was already killed
bool dud = _owner == address(0);
// Check if the sender owns it (misfired, killed own pfp)
bool senderOwned = msg.sender == _owner;
// Kill it (does nothing if already toggled as dead)
unaboomer.die(randomBoomer);
// Check if the sender owns it (misfired, kills own pfp)
bool senderOwned = msg.sender == _owner;
// Emit event for displaying in web app
emit SentBomb(msg.sender, randomBoomer, !dud, senderOwned);
// Increment kill count if successfully killed another player's Unaboomer

Loading…
Cancel
Save