contract KnockoffToken is ERC721, Ownable {

    using Counters for Counters.Counter;
    Counters.Counter private _tokenIds;

    uint public constant MAX_KNOCKOFFS = 1000;
    bool public hasSaleStarted = true;

    string public constant R = "The manufacturers have learned that this taste is merely whimsical. ";

    constructor (string memory name, string memory symbol, string memory baseURI) public ERC721(name, symbol){
        _setBaseURI(baseURI);
    }

    function setBaseURI(string memory baseURI) public onlyOwner {
        _setBaseURI(baseURI);
    }

    function calculatePrice() public view returns (uint256) {
        require(hasSaleStarted == true, "Sale hasn't started");
        require(totalSupply() < MAX_KNOCKOFFS, "No more knockoffs");

        uint currentSupply = totalSupply();

        if (currentSupply >= 998) {
            return 1888000000000000000;	// 1.888 ETH 
        }
        else if (currentSupply >= 991) {
            return 1867530900000000000;	// 1.8675309 ETH 
        }
        else if (currentSupply >= 984) {
            return 1808000000000000000;	// 1.808 ETH 
        }
        else if (currentSupply >= 977) {
            return 1777000000000000000;	// 1.777 ETH 
        }
        else if (currentSupply >= 970) {
            return 1690000000000000000;	// 1.69 ETH 
        }
        else if (currentSupply >= 963) {
            return 1666000000000000000;	// 1.666 ETH 
        }
        else if (currentSupply >= 956) {
            return 1618030000000000000;	// 1.61803 ETH 
        }
        else if (currentSupply >= 949) {
            return 1481516234200000000;	// 1.4815162342 ETH 
        }
        else if (currentSupply >= 942) {
            return 1420000000000000000;	// 1.42 ETH 
        }
        else if (currentSupply >= 935) {
            return 1404000000000000000;	// 1.404 ETH 
        }
        else if (currentSupply >= 928) {
            return 1337000000000000000;	// 1.337 ETH 
        }
        else if (currentSupply >= 921) {
            return 1314000000000000000;	// 1.314 ETH 
        }
        else if (currentSupply >= 914) {
            return 1303000000000000000;	// 1.303 ETH 
        }
        else if (currentSupply >= 907) {
            return 1300000000000000000;	// 1.3 ETH 
        } // bigger
        else if (currentSupply >= 895) {
            return 911000000000000000;	// 0.911 ETH 
        }
        else if (currentSupply >= 852) {
            return 888000000000000000;	// 0.888 ETH 
        }
        else if (currentSupply >= 809) {
            return 867530900000000000;	// 0.8675309 ETH 
        }
        else if (currentSupply >= 766) {
            return 808000000000000000;	// 0.808 ETH 
        }
        else if (currentSupply >= 723) {
            return 777000000000000000;	// 0.777 ETH 
        }
        else if (currentSupply >= 680) {
            return 690000000000000000;	// 0.69 ETH 
        }
        else if (currentSupply >= 637) {
            return 666000000000000000;	// 0.666 ETH 
        }
        else if (currentSupply >= 594) {
            return 481516234200000000;	// 0.4815162342 ETH 
        }
        else if (currentSupply >= 551) {
            return 420000000000000000;	// 0.42 ETH 
        }
        else if (currentSupply >= 508) {
            return 404000000000000000;	// 0.404 ETH 
        }
        else if (currentSupply >= 465) {
            return 314000000000000000;	// 0.314 ETH 
        }
        else if (currentSupply >= 422) {
            return 303000000000000000;	// 0.303 ETH 
        }
        else if (currentSupply >= 379) {
            return 161803000000000000;	// 0.161803 ETH 
        }
        else if (currentSupply >= 336) {
            return 133700000000000000;	// 0.1337 ETH 
        }
        else if (currentSupply >= 293) {
            return 130000000000000000;	// 0.13 ETH 
        } // medium
        else if (currentSupply >= 255) {
            return 91100000000000000;	// 0.0911 ETH 
        }
        else if (currentSupply >= 238) {
            return 88800000000000000;	// 0.0888 ETH 
        }
        else if (currentSupply >= 221) {
            return 86753090000000000;	// 0.08675309 ETH 
        }
        else if (currentSupply >= 204) {
            return 80800000000000000;	// 0.0808 ETH 
        }
        else if (currentSupply >= 187) {
            return 77700000000000000;	// 0.0777 ETH 
        }
        else if (currentSupply >= 170) {
            return 69000000000000000;	// 0.069 ETH 
        }
        else if (currentSupply >= 153) {
            return 66600000000000000;	// 0.0666 ETH 
        }
        else if (currentSupply >= 136) {
            return 48151623420000000;	// 0.04815162342 ETH 
        }
        else if (currentSupply >= 119) {
            return 42000000000000000;	// 0.042 ETH 
        }
        else if (currentSupply >= 102) {
            return 40400000000000000;	// 0.0404 ETH 
        }
        else if (currentSupply >= 85) {
            return 31400000000000000;	// 0.0314 ETH 
        }
        else if (currentSupply >= 68) {
            return 30300000000000000;	// 0.0303 ETH 
        }
        else if (currentSupply >= 51) {
            return 16180300000000000;	// 0.0161803 ETH 
        }
        else if (currentSupply >= 34) {
            return 13370000000000000;	// 0.01337 ETH 
        }
        else {
            return 13000000000000000;	// 0.013 ETH 
        }

    }
    function startSale() public onlyOwner {
        hasSaleStarted = true;
    }
    
    function pauseSale() public onlyOwner {
        hasSaleStarted = false;
    }

    /**
    * @dev Withdraw ether from this contract (Callable by owner only)
    */
    function withdraw() onlyOwner public {
        uint balance = address(this).balance;
        msg.sender.transfer(balance);
    }

    function mint(address to) public payable {
        require(SafeMath.add(totalSupply(), 1) <= MAX_KNOCKOFFS, "Exceeds maximum knockoffs supply.");
        require(calculatePrice() == msg.value, "Cheapskate. Amount of Ether sent is not correct.");
        

        uint256 newTokenId = _tokenIds.current();
        _safeMint(msg.sender, newTokenId);(to, newTokenId);
        _setTokenURI(newTokenId, Strings.toString(newTokenId));
        _tokenIds.increment();
    }
}
// Inspired by PIXL and Chubbies. 
function withdraw() onlyOwner public {
        uint balance = address(this).balance;
        msg.sender.transfer(balance);
    }
/**
 * @dev Withdraw ether from this contract (Callable by owner only)
 */