contract LambDuhs is ERC721, Ownable {
    
    using SafeMath for uint256;

    uint256 public maxLambs = 8500;
    uint256 public lambPrice = 22000000000000000; // 0.022 ETH
    uint256 public constant maxLambBuy = 15;
    uint256 public lambReserves = 100;
    bool public saleIsActive = false; // Determines whether minting is available or not
    string public lambProvenance = ""; // Final proof provenance hash will be stored here
    string public pandoraBox = ""; // ;)
    
    constructor() ERC721("Lamb Duhs", "LAMB") {}
    
    function withdraw() public onlyOwner {
        uint256 balance = address(this).balance;
        msg.sender.transfer(balance);
    }

    function flipSaleState() public onlyOwner {
        saleIsActive = !saleIsActive;
    }

    function setPandoraBox(string memory inputString) public onlyOwner {
        pandoraBox = inputString;
    }

    // Sets the provenance hash to be stored in lambProvenance, will be stored following the minting process
    function setProvenanceHash(string memory provenanceHash) public onlyOwner {
        lambProvenance = provenanceHash;
    }

    // Reserves lambs for the team
    function reserveLambs(address _to, uint256 _reserveAmount) public onlyOwner {
        uint256 supply = totalSupply();
        require(_reserveAmount > 0 && _reserveAmount < lambReserves + 1, "Insufficient reserves remaining");
        for (uint256 i = 0; i < _reserveAmount; i++) {
            _safeMint(_to, supply + i);
        }
        lambReserves = lambReserves.sub(_reserveAmount);
    }

    // Points the tokens to the corresponding metadata including attribute information
    function setBaseURI(string memory baseURI) public onlyOwner {
        _setBaseURI(baseURI);
    }

    // Changes the ETH price, can be used in the event of excessive volatility
    function setLambPrice(uint256 newLambPrice) public onlyOwner {
        lambPrice = newLambPrice;
    }

    // Sometimes you just gotta gamble baby
    function mintLambs(uint256 tokenAmount) public payable {
        uint256 supply = totalSupply();
        require(saleIsActive, "Sale paused, minting disabled");
        require(tokenAmount > 0 && tokenAmount < maxLambBuy + 1, "15 token limit per transaction");
        require(supply.add(tokenAmount) < maxLambs + 1, "Exceeds maximum lamb supply");
        require(msg.value >= lambPrice.mul(tokenAmount), "Insufficient ether value sent");
        
        for(uint256 i; i < tokenAmount; i++) {
            if (supply < maxLambs){
                _safeMint(msg.sender, supply + i);
            }
        }
    }

    // Checks a wallet address for LAMB tokens
    function tokensOfWalletOwner(address _owner) public view returns (uint256[] memory) {
        uint256 tokenCount = balanceOf(_owner);
        uint256[] memory tokenIds = new uint256[](tokenCount);
        for(uint256 i; i < tokenCount; i++){
            tokenIds[i] = tokenOfOwnerByIndex(_owner, i);
        }
        return tokenIds;
    }

}
/**
 *
 *
 *                     
 *             .-:'"`;'"`-._               .-:'"`;'"`-._               .-:'"`;'"`-._
 *            (_,           )             (_,           )             (_,           )
 *          ,'o"(            )>         ,'o"(            )>         ,'o"(            )>
 *         (__,-'            )         (__,-'            )         (__,-'            )
 *            (             )             (             )             (             )
 *             `-'._.--._.-'               `-'._.--._.-'               `-'._.--._.-'
 *                |||  |||                    |||  |||                    |||  |||
 *
 *                              sup mutton chops, have some floofy bois
 *                              just don't count 'em until snooze time
 *
 *
 *               ▄▄▄     ▄▄▄▄▄▄ ▄▄   ▄▄ ▄▄▄▄▄▄▄    ▄▄▄▄▄▄  ▄▄   ▄▄ ▄▄   ▄▄ ▄▄▄▄▄▄▄ 
 *              █   █   █      █  █▄█  █  ▄    █  █      ██  █ █  █  █ █  █       █
 *              █   █   █  ▄   █       █ █▄█   █  █  ▄    █  █ █  █  █▄█  █  ▄▄▄▄▄█
 *              █   █   █ █▄█  █       █       █  █ █ █   █  █▄█  █       █ █▄▄▄▄▄ 
 *              █   █▄▄▄█      █       █  ▄   █   █ █▄█   █       █   ▄   █▄▄▄▄▄  █
 *              █       █  ▄   █ ██▄██ █ █▄█   █  █       █       █  █ █  █▄▄▄▄▄█ █
 *              █▄▄▄▄▄▄▄█▄█ █▄▄█▄█   █▄█▄▄▄▄▄▄▄█  █▄▄▄▄▄▄██▄▄▄▄▄▄▄█▄▄█ █▄▄█▄▄▄▄▄▄▄█
 *
 *
 * 
 *  Find us at lambduhs.com or twitter.com/lambduhsnft
 *  Sheep above modified from asciiart.eu, text generated from texteditor.com
 *
 */
function setLambPrice(uint256 newLambPrice) public onlyOwner {
    lambPrice = newLambPrice;
}

// Changes the ETH price, can be used in the event of excessive volatility