contract PhorgottenRunesWizardsCult is ERC721, Ownable {
    using Strings for uint256;

    uint256 public constant MAX_WIZARDS = 10442;

    string public constant R =
        'It is not our part to master all the tides of the world, but to do what is in us phor the succour of those years wherein we are set, uprooting the evil in the phields that we know, so that those who live after may have clean earth to till.';
    
    uint256 public totalSupply = 0;

    string public baseUri = "https://phorgottenrunes.com/api/metadata?id=";

    constructor() ERC721('PhorgottenRunesWizardsCult', 'WIZARDS') {}

    function mint(uint256 _numWizards) external payable {
        
        uint256 curTotalSupply = totalSupply;
        require(curTotalSupply + _numWizards <= MAX_WIZARDS, "Minting has finished, maximum supply has been reached.");

        if(_numWizards>1){
            uint256 cumulative_cost = 0;
            for (uint256 n = 1; n <= _numWizards; n++) {
                cumulative_cost += 0.07 ether;
            }
            require(cumulative_cost <= msg.value, "You didn't send enough ETH to mint.");
        }else{
            require(0.07 ether <= msg.value, "You didn't send enough ETH to mint.");
        }
        
        for (uint256 i = 1; i <= _numWizards; ++i) {
            _safeMint(msg.sender, curTotalSupply + i);
        }

        totalSupply += _numWizards;
    }

    function setBaseURI(string memory _baseUri) external onlyOwner {
        baseUri = _baseUri;
    }

    function withdraw() external payable onlyOwner {
        uint256 balance = address(this).balance;
        (bool withdrawEth, ) = payable(0xc638e1254a649723B3cB32DB96b1F2E42e34640C).call{value: balance}(""); 
        require(withdrawEth, "Transfer failed.");
    }

    // INTERNAL FUNCTIONS
    function _baseURI() internal view virtual override returns (string memory) {
        return baseUri;
    }
}
function _baseURI() internal view virtual override returns (string memory) {
    return baseUri;
}

// INTERNAL FUNCTIONS