From d46097d9c2d20131868e553dd5d50094a5d1de7c Mon Sep 17 00:00:00 2001 From: lza_menace Date: Wed, 11 Jan 2023 10:51:06 -0800 Subject: [PATCH] change randomness to less shifting vars --- src/Main.sol | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Main.sol b/src/Main.sol index 8ee4abe..4917606 100644 --- a/src/Main.sol +++ b/src/Main.sol @@ -236,10 +236,11 @@ 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(); - require(_amount <= bombBalance(msg.sender), "not enough bombs"); + uint256 bal = bombBalance(msg.sender); + require(_amount <= bal, "not enough bombs"); 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, block.timestamp, msg.sender))) % supply) + 1; + uint256 randomBoomer = (uint256(keccak256(abi.encodePacked(i, supply, bal, msg.sender))) % supply) + 1; // Capture owner address _owner = unaboomer.ownerOf(randomBoomer); // Check if it was already killed