|
|
|
@ -58,6 +58,12 @@ import {Mailbomb} from "./Mailbomb.sol";
|
|
|
|
|
|
|
|
|
|
contract Main is Owned {
|
|
|
|
|
|
|
|
|
|
/// Track the number of kills for each address
|
|
|
|
|
mapping(address => uint256) public killCount;
|
|
|
|
|
/// Index the number of kills to form a basic leaderboard
|
|
|
|
|
mapping(uint256 => address) public leaderboard;
|
|
|
|
|
/// Point to the latest leaderboard update
|
|
|
|
|
uint256 public leaderboardPointer;
|
|
|
|
|
/// Price of the Unaboomer ERC-721 token
|
|
|
|
|
uint256 public unaboomerPrice = 0.01 ether;
|
|
|
|
|
/// Price of the Mailbomb ERC-1155 token
|
|
|
|
@ -67,7 +73,7 @@ contract Main is Owned {
|
|
|
|
|
/// Mailbomb contract
|
|
|
|
|
Mailbomb public mailbomb;
|
|
|
|
|
|
|
|
|
|
/// SendBomb event is for recording the results of sendBombs
|
|
|
|
|
/// SentBomb event is for recording the results of sendBombs
|
|
|
|
|
/// @param from Sender of the bombs
|
|
|
|
|
/// @param tokenId Unaboomer token which was targeted
|
|
|
|
|
/// @param hit Whether or not the bomb killed the token or not (was a dud / already killed)
|
|
|
|
@ -118,7 +124,7 @@ contract Main is Owned {
|
|
|
|
|
/// The game stops.
|
|
|
|
|
modifier missionNotCompleted {
|
|
|
|
|
require(
|
|
|
|
|
unaboomer.killCount() <= (unaboomer.MAX_SUPPLY() - unaboomer.SURVIVOR_COUNT()),
|
|
|
|
|
unaboomer.totalKillCount() <= (unaboomer.MAX_SUPPLY() - unaboomer.SURVIVOR_COUNT()),
|
|
|
|
|
"mission already completed"
|
|
|
|
|
);
|
|
|
|
|
_;
|
|
|
|
@ -141,7 +147,7 @@ contract Main is Owned {
|
|
|
|
|
|
|
|
|
|
/// Get BOOMR kill count (unaboomers killed)
|
|
|
|
|
function unaboomersKilled() public view returns (uint256) {
|
|
|
|
|
return unaboomer.killCount();
|
|
|
|
|
return unaboomer.totalKillCount();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Get BOOMR token max supply
|
|
|
|
@ -191,6 +197,7 @@ contract Main is Owned {
|
|
|
|
|
|
|
|
|
|
/// Send N bombs to pseudo-random Unaboomer tokenIds to kill them.
|
|
|
|
|
/// If the Unaboomer is already dead, the bomb is considered a dud.
|
|
|
|
|
/// Update a leaderboard with updated kill counts.
|
|
|
|
|
/// @dev Pick a pseudo-random tokenID from Unaboomer contract and toggle a mapping value
|
|
|
|
|
/// @dev The likelihood of killing a boomer decreases as time goes on - i.e. more duds
|
|
|
|
|
/// @param _amount Amount of bombs to send to kill Unaboomers
|
|
|
|
@ -204,6 +211,17 @@ contract Main is Owned {
|
|
|
|
|
unaboomer.die(randomBoomer);
|
|
|
|
|
bool senderOwned = msg.sender == unaboomer.ownerOf(randomBoomer);
|
|
|
|
|
emit SentBomb(msg.sender, randomBoomer, !dud, senderOwned);
|
|
|
|
|
if(!dud && !senderOwned) {
|
|
|
|
|
killCount[msg.sender]++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
uint256 kills = killCount[msg.sender];
|
|
|
|
|
address leader = leaderboard[leaderboardPointer];
|
|
|
|
|
if (kills > killCount[leader]) {
|
|
|
|
|
if (leader != msg.sender) {
|
|
|
|
|
leaderboardPointer++;
|
|
|
|
|
leaderboard[leaderboardPointer] = msg.sender;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
mailbomb.explode(msg.sender, _amount);
|
|
|
|
|
}
|
|
|
|
|