|
|
|
@ -60,7 +60,7 @@ 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
|
|
|
|
|
/// Index addresses to form a basic leaderboard
|
|
|
|
|
mapping(uint256 => address) public leaderboard;
|
|
|
|
|
/// Point to the latest leaderboard update
|
|
|
|
|
uint256 public leaderboardPointer;
|
|
|
|
@ -176,6 +176,40 @@ contract Main is Owned {
|
|
|
|
|
return mailbomb.bombsExploded();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Get N addresses from the leaderboard
|
|
|
|
|
/// @param _amount Amount of addresses to return
|
|
|
|
|
/// @return addresses List of addresses from the top N entries of leaderboard
|
|
|
|
|
function getLeaderboard(uint256 _amount) public view returns (address[] memory addresses) {
|
|
|
|
|
address[] memory addressList;
|
|
|
|
|
uint256 idx;
|
|
|
|
|
while (addressList.length < _amount) {
|
|
|
|
|
bool exists;
|
|
|
|
|
address a = leaderboard[leaderboardPointer - idx];
|
|
|
|
|
for (uint256 n; n < addressList.length; n++) {
|
|
|
|
|
if (addressList[n] == a) {
|
|
|
|
|
exists = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!exists) {
|
|
|
|
|
addressList[idx] = a;
|
|
|
|
|
idx++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return addressList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Get N kill amounts
|
|
|
|
|
/// @param addresses List of addresses to query kill counts for
|
|
|
|
|
/// @return amounts List of kill counts for each address in addresses
|
|
|
|
|
function getKillCounts(address[] memory addresses) public view returns (uint256[] memory amounts) {
|
|
|
|
|
uint256[] memory _amounts;
|
|
|
|
|
for (uint256 i; i < addresses.length; i++) {
|
|
|
|
|
address addr = addresses[i];
|
|
|
|
|
_amounts[i] = killCount[addr];
|
|
|
|
|
}
|
|
|
|
|
return _amounts;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// =========================================================================
|
|
|
|
|
// Tokens
|
|
|
|
|
// =========================================================================
|
|
|
|
|