contract SRSC is ERC721Enumerable, Ownable {
    uint public constant MAX_RATS = 8888;
    string _baseTokenURI;
    bool public paused = true;

    constructor(string memory baseURI) ERC721("Sewer Rat Social Club", "SRSC")  {
        setBaseURI(baseURI);
    }

    modifier saleIsOpen{
        require(totalSupply() < MAX_RATS, "Sale end");
        _;
    }

    /**
     * Sewer Rats reserved for promotions and Dev Team
    */
    function reserveRats() public onlyOwner {
        uint supply = totalSupply();
        uint i;
        for (i = 0; i < 30; i++) {
            _safeMint(msg.sender, supply + i);
        }
    }


    function mintSewerRat(address _to, uint _count) public payable saleIsOpen {
        if(msg.sender != owner()){
            require(!paused, "Paused");
        }
        require(totalSupply() + _count <= MAX_RATS, "Max limit");
        require(totalSupply() < MAX_RATS, "Sale end");
        require(_count <= 15, "Exceeds 15");
        require(msg.value >= price(_count), "Value below price");

        for(uint i = 0; i < _count; i++){
            _safeMint(_to, totalSupply());
        }
    }

    function price(uint _count) public view returns (uint256) {
        uint _id = totalSupply();
        // free 200
        if(_id <= 229 ){
            require(_count <= 1, "Max 1 Free Per TX");
            return 0;
        }

        return 50000000000000000 * _count; // 0.05 ETH
    }

    function contractURI() public view returns (string memory) {
        return "https://gateway.pinata.cloud/ipfs/Qmce2MpyvCSYcrRDseRWjAqQJLevaXGBAfsYnyV8eLqWDg";
    }

    function _baseURI() internal view virtual override returns (string memory) {
        return _baseTokenURI;
    }
    function setBaseURI(string memory baseURI) public onlyOwner {
        _baseTokenURI = baseURI;
    }

    function walletOfOwner(address _owner) external view returns(uint256[] memory) {
        uint tokenCount = balanceOf(_owner);

        uint256[] memory tokensId = new uint256[](tokenCount);
        for(uint i = 0; i < tokenCount; i++){
            tokensId[i] = tokenOfOwnerByIndex(_owner, i);
        }

        return tokensId;
    }

    function pause(bool val) public onlyOwner {
        paused = val;
    }

    function withdrawAll() public payable onlyOwner {
        require(payable(_msgSender()).send(address(this).balance));
    }
}
function reserveRats() public onlyOwner {
    uint supply = totalSupply();
    uint i;
    for (i = 0; i < 30; i++) {
        _safeMint(msg.sender, supply + i);
    }
}

/**
 * Sewer Rats reserved for promotions and Dev Team
 */