contract SummoningLoot is ERC721, ReentrancyGuard, Ownable {
    using SafeMath for uint256;

    string public PROVENANCE = "";
    uint256 public lootersPrice = 15000000000000000; //0.015 ETH
    uint256 public publicPrice = 100000000000000000; //0.1 ETH
    bool public saleIsActive = true;
    bool public privateSale = true;

    //Loot Contract
    address public lootAddress = 0xFF9C1b15B16263C61d017ee9F65C50e4AE0113D7;
    LootInterface lootContract = LootInterface(lootAddress);

    constructor() ERC721("SummoningLoot", "SML") {
    }

    function withdraw() public onlyOwner {
        uint balance = address(this).balance;
        msg.sender.transfer(balance);
    }

    function deposit() public payable onlyOwner {}

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

    function endPrivateSale() public onlyOwner {
        require(privateSale);
        privateSale = false;
    }

    function setLootersPrice(uint256 newPrice) public onlyOwner {
        lootersPrice = newPrice;
    }

    function setPublicPrice(uint256 newPrice) public onlyOwner {
        publicPrice = newPrice;
    }

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

    function setProvenance(string memory prov) public onlyOwner {
        PROVENANCE = prov;
    }

    //Private sale minting (reserved for Loot owners)
    function mintWithLoot(uint lootId) public payable nonReentrant {
        require(privateSale, "Private sale minting is over");
        require(saleIsActive, "Sale must be active to mint");
        require(lootersPrice <= msg.value, "Ether value sent is not correct");
        require(lootContract.ownerOf(lootId) == msg.sender, "Not the owner of this loot");

        _safeMint(msg.sender, lootId);
    }

    //Public sale minting
    function mint(uint lootId) public payable nonReentrant {
        require(!privateSale, "Public sale minting not started");
        require(saleIsActive, "Sale must be active to mint");
        require(publicPrice <= msg.value, "Ether value sent is not correct");
        require(lootId > 0 && lootId < 8001, "Token ID invalid");

        _safeMint(msg.sender, lootId);
    }
}
/**
 * @title SummoningLoot contract
 * @dev Extends ERC721 Non-Fungible Token Standard basic implementation
 */
function mintWithLoot(uint lootId) public payable nonReentrant {
    require(privateSale, "Private sale minting is over");
    require(saleIsActive, "Sale must be active to mint");
    require(lootersPrice <= msg.value, "Ether value sent is not correct");
    require(lootContract.ownerOf(lootId) == msg.sender, "Not the owner of this loot");

    _safeMint(msg.sender, lootId);
}

//Private sale minting (reserved for Loot owners)