Repository: CryptoBlades/cryptoblades
File: contracts/cryptoblades.sol (Solidity)

Code before:
        uint8 chosenElementFee = chosenElement == 100 ? 1 : 2;

        _payContract(msg.sender, mintWeaponFee * num * chosenElementFee);

        for (uint i = 0; i < num; i++) {
            weapons.mint(msg.sender, uint256(keccak256(abi.encodePacked(blockhash(block.number - 1), msg.sender, i))), chosenElement);
        }
    }

    function mintWeapon(uint8 chosenElement) public onlyNonContract oncePerBlock(msg.sender) {
        uint8 chosenElementFee = chosenElement == 100 ? 1 : 2;

        _payContract(msg.sender, mintWeaponFee * chosenElementFee);

        //uint256 seed = randoms.getRandomSeed(msg.sender);
        weapons.mint(msg.sender, uint256(keccak256(abi.encodePacked(blockhash(block.number - 1), msg.sender))), chosenElement);
    }

    function burnWeapon(uint256 burnID) public
            isWeaponOwner(burnID) requestPayFromPlayer(burnWeaponFee) {
        _payContract(msg.sender, burnWeaponFee);
        weapons.burn(burnID);
    }

    function burnWeapons(uint256[] memory burnIDs) public
            isWeaponsOwner(burnIDs) requestPayFromPlayer(burnWeaponFee.mul(ABDKMath64x64.fromUInt(burnIDs.length))) {
        _payContract(msg.sender, burnWeaponFee.mul(ABDKMath64x64.fromUInt(burnIDs.length)));
        for(uint i = 0; i < burnIDs.length; i++) {
            weapons.burn(burnIDs[i]);
        }
    }

    function reforgeWeapon(uint256 reforgeID, uint256 burnID) public
            isWeaponOwner(reforgeID) isWeaponOwner(burnID) requestPayFromPlayer(reforgeWeaponFee) {
        _payContract(msg.sender, reforgeWeaponFee);
        weapons.reforge(reforgeID, burnID);
    }

    function reforgeWeaponWithDust(uint256 reforgeID, uint8 amountLB, uint8 amount4B, uint8 amount5B) public
            isWeaponOwner(reforgeID) requestPayFromPlayer(reforgeWeaponWithDustFee) {
        _payContract(msg.sender, reforgeWeaponWithDustFee);
        weapons.reforgeWithDust(reforgeID, amountLB, amount4B, amount5B);
    }

    function migrateRandoms(IRandoms _newRandoms) external {
        require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "Not admin");
        randoms = _newRandoms;
    }

    modifier fightModifierChecks(uint256 character, uint256 weapon) {
        _onlyNonContract();

Review comment (suggestion):
I just noticed and I think we should only allow passing 0, 1, 2, 3, 100 as chosenElement, other values are not supported and could cause unexpected behavior.
Please create a modifier to check for supported elements and apply to both mint functions.
Something along those lines:
```
modifier isSupportedElement(uint8 element) {
    _isSupportedElement(element);
    _;
}

function _isSupportedElement(uint8 element) internal view {
   require(element == 100 || (element>= 0 && element<= 3), "Not supported element");
}
```

I'm not too sure what effect it will have on the gas cost - if it's significant it might be better to create a separate function for mints with chosenElement and leave this as it was originally for random elements. @poshdan please share your opinion on this.

Code after:
        mintPaymentSkillDepositeds[_minter].skillDepositedFromWallet = 0;
        mintPaymentSkillDepositeds[_minter].skillDepositedFromRewards = 0;
        mintPaymentSkillDepositeds[_minter].skillDepositedFromIgo = 0;
    }

    function mintWeapon(uint256 chosenElement) public onlyNonContract oncePerBlock(msg.sender)  {
        _discardPaymentIfExpired(msg.sender);

        require(mintPayments[msg.sender].count == 1, "count mismatch");

        bytes32 hash = mintPayments[msg.sender].blockHash;
        try weapons.mint(msg.sender, randoms.getRandomSeedUsingHash(msg.sender, hash), chosenElement) {
            _usePayment(msg.sender, address(weapons), 1);

            mintPaymentSkillDepositeds[msg.sender].skillDepositedFromWallet = 0;
            mintPaymentSkillDepositeds[msg.sender].skillDepositedFromRewards = 0;
            mintPaymentSkillDepositeds[msg.sender].skillDepositedFromIgo = 0;

            emit MintWeaponsSuccess(msg.sender, 1);
        }
        catch {
            emit MintWeaponsFailure(msg.sender, 1);
        }
    }*/

    function mintWeaponN(uint32 num, uint8 chosenElement)
        external
        onlyNonContract
        oncePerBlock(msg.sender)
        isSupportedElement(chosenElement)
    {
        uint8 chosenElementFee = chosenElement == 100 ? 1 : 2;
        _payContractConvertedSupportingStaked(msg.sender, usdToSkill(mintWeaponFee * num * chosenElementFee));
        _mintWeaponNLogic(num, chosenElement);
    }

    function mintWeapon(uint8 chosenElement) external onlyNonContract oncePerBlock(msg.sender) isSupportedElement(chosenElement) {
        uint8 chosenElementFee = chosenElement == 100 ? 1 : 2;
        _payContractConvertedSupportingStaked(msg.sender, usdToSkill(mintWeaponFee * chosenElementFee));
        _mintWeaponLogic(chosenElement);
    }

    function mintWeaponNUsingStakedSkill(uint32 num, uint8 chosenElement)
        external
        onlyNonContract
        oncePerBlock(msg.sender)
        isSupportedElement(chosenElement)
    {
        uint8 chosenElementFee = chosenElement == 100 ? 1 : 2;
        int128 discountedMintWeaponFee =
            mintWeaponFee