|
|
|
@ -222,12 +222,13 @@ 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 = unaboomer.totalSupply();
|
|
|
|
|
uint256 killed = unaboomersKilled();
|
|
|
|
|
require(_amount <= bombBalance(msg.sender), "not enough bombs");
|
|
|
|
|
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++) {
|
|
|
|
|
// Pick a pseudo-random Unaboomer token
|
|
|
|
|
uint256 randomBoomer = uint256(keccak256(abi.encodePacked(i, _amount, block.timestamp, msg.sender))) % supply;
|
|
|
|
|
// 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;
|
|
|
|
|
// Check if it was already killed
|
|
|
|
|
bool dud = unaboomer.tokenDead(randomBoomer);
|
|
|
|
|
// Kill it (does nothing if already toggled as dead)
|
|
|
|
|