|
|
|
@ -56,12 +56,21 @@ contract UnaboomerCommon is Owned {
|
|
|
|
|
mailbomb = Mailbomb(_address);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// =========================================================================
|
|
|
|
|
// Modifiers
|
|
|
|
|
// =========================================================================
|
|
|
|
|
|
|
|
|
|
modifier missionCompleted {
|
|
|
|
|
require(unaboomer.killCount() <= unaboomer.SURVIVOR_COUNT(), "mission already completed");
|
|
|
|
|
_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// =========================================================================
|
|
|
|
|
// Tokens
|
|
|
|
|
// =========================================================================
|
|
|
|
|
|
|
|
|
|
/// Radicalize a boomer to become a Unaboomer
|
|
|
|
|
function radicalizeBoomer(uint256 _amount) external payable {
|
|
|
|
|
function radicalizeBoomers(uint256 _amount) external payable missionCompleted {
|
|
|
|
|
// check if game halted
|
|
|
|
|
require(msg.value >= _amount * boomerPrice, "not enough ether");
|
|
|
|
|
unaboomer.mint(msg.sender, _amount);
|
|
|
|
@ -69,25 +78,17 @@ contract UnaboomerCommon is Owned {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Assemble additional mailbombs to kill targets
|
|
|
|
|
function assembleBomb(uint256 _amount) external payable {
|
|
|
|
|
function assembleBombs(uint256 _amount) external payable missionCompleted {
|
|
|
|
|
// check if game halted
|
|
|
|
|
require(msg.value >= _amount * bombPrice, "not enough ether");
|
|
|
|
|
mailbomb.mint(msg.sender, _amount);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Kill random targets with mail bombs
|
|
|
|
|
/// @dev Function returns a boolean depending on if Boomer was already killed or not - i.e. if dud
|
|
|
|
|
/// @dev The likelihood of killing a boomer decreases as time goes on - i.e. more duds
|
|
|
|
|
function killBoomer(uint256 tokenId) private returns (bool isDud) {
|
|
|
|
|
bool dud = unaboomer.tokenDead(tokenId);
|
|
|
|
|
unaboomer.kill(tokenId);
|
|
|
|
|
return dud;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Send N bombs to pseudo-random Unaboomer tokenIds to potentially kill them.
|
|
|
|
|
/// If the Unaboomer is already dead, the bomb is a dud.
|
|
|
|
|
/// @dev Pick a pseudo-random tokenID from Unaboomer contract and toggle a mapping value
|
|
|
|
|
function sendBombs(uint256[] calldata tokenIds) external returns (bool[] memory results) {
|
|
|
|
|
/// @dev The likelihood of killing a boomer decreases as time goes on - i.e. more duds
|
|
|
|
|
function sendBombs(uint256[] calldata tokenIds) external missionCompleted returns (bool[] memory results) {
|
|
|
|
|
require(tokenIds.length <= mailbomb.balanceOf(msg.sender));
|
|
|
|
|
bool[] memory res = new bool[](tokenIds.length);
|
|
|
|
|
uint256 boomerSupply = unaboomer.totalSupply();
|
|
|
|
@ -95,8 +96,9 @@ contract UnaboomerCommon is Owned {
|
|
|
|
|
require(mailbomb.ownerOf(tokenIds[i]) == msg.sender, "token not owned");
|
|
|
|
|
uint256 randomBoomer = uint256(keccak256(abi.encodePacked(tokenIds[i], block.timestamp, msg.sender))) % boomerSupply;
|
|
|
|
|
mailbomb.burn(tokenIds[i]);
|
|
|
|
|
bool _res = killBoomer(randomBoomer);
|
|
|
|
|
res[i] = _res;
|
|
|
|
|
bool dud = unaboomer.tokenDead(randomBoomer);
|
|
|
|
|
unaboomer.kill(randomBoomer);
|
|
|
|
|
res[i] = dud;
|
|
|
|
|
}
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|