contract BundNFTMarketPlace is ERC1155 {
    using SafeMath for uint256;
    using SafeERC20 for BundNFTToken;

    BundNFTToken public BundNFT;

    uint8 RareNFT = 0;                       //_______| Rare NFT token index: 0 |_________
    uint8 SpecialNFT = 1;                    //_______| Rare NFT token index: 1 |________
    uint8 LegendNFT = 2;                     //_______| Rare NFT token index: 2 |________

    uint8 copiesRareNFT = 6;                       //_______| Copies of Rare NFT    : 6 |_________
    uint8 copiesSpecialNFT = 12;                   //_______| Copies of Special NFT :  12 |_________
    uint8 copiesLegendNFT = 1;                     //_______| Copy of Legend NFT    :  1 |_________

    uint256 basePriceRareNFT = 400*10**18;       //________| 400 BundNFT for each Rare_NFT |_____
    uint256 basePriceSpecialNFT = 200*10**18;    //________| 200 BundNFT for each Rare_NFT |_____
    uint256 basePriceLegendNFT = 800*10**18;     //________| 800 BundNFT for each Rare_NFT |_____
   
    mapping(uint8 => uint8) public mintedNFT;                  //_______| Mapping to track each NFT minting |_______

    constructor(address _bundNFT) {
        BundNFT = BundNFTToken(_bundNFT); 
    }

    function burn(uint256 _amount) public virtual returns (bool) {
       BundNFT.burn(_amount);
       return true;
    } 
    
    function purchaseRareNFT(uint8 _copiesNFT) public {
        
        require(mintedNFT[RareNFT] < copiesRareNFT," RareNFT: Exceeding 6 copies");
        require(BundNFT.balanceOf(msg.sender) >= basePriceRareNFT.mul(_copiesNFT),"Insufficient BundNFT in your wallet");
        
        _mint(msg.sender, RareNFT, _copiesNFT, "");
        BundNFT.safeTransferFrom(msg.sender, address(this), basePriceRareNFT.mul(_copiesNFT)); 

        mintedNFT[RareNFT] += _copiesNFT;                                 

    }

    function purchaseSpecialNFT(uint8 _copiesNFT) public {
        
        require(mintedNFT[SpecialNFT] < copiesSpecialNFT," SpecialNFT: Exceeding 12 copies");
        require(BundNFT.balanceOf(msg.sender) >= basePriceSpecialNFT.mul(_copiesNFT),"Insufficient BundNFT in your wallet");
        
        _mint(msg.sender, SpecialNFT, _copiesNFT, "");
        
        BundNFT.safeTransferFrom(msg.sender, address(this), basePriceSpecialNFT.mul(_copiesNFT));
        mintedNFT[SpecialNFT] += _copiesNFT;                                 
    }


    function purchaseLegendNFT() public {
        
        require(mintedNFT[LegendNFT] < copiesLegendNFT," LegendNFT: Exceeding 1 copy");
        require(BundNFT.balanceOf(msg.sender) >= basePriceLegendNFT, "Insufficient BundNFT in your wallet");
        
        _mint(msg.sender, LegendNFT, 1, "");

        BundNFT.safeTransferFrom(msg.sender, address(this), basePriceLegendNFT);
        mintedNFT[LegendNFT] += 1;            

    }

    //++++| Burn all bundNFT deposits |+++++
    function burnDeposits() public onlyOwner {
        require(BundNFT.balanceOf(address(this)) >= basePriceLegendNFT, "No bundNFT deposits");
        burn(BundNFT.balanceOf(address(this)));          
    }

    //++++| Claim all bundNFT deposits |+++++
    function claimDeposits() public onlyOwner {
        require(BundNFT.balanceOf(address(this)) > 0, "No bundNFT deposits in this contract");
        BundNFT.transfer(owner(), BundNFT.balanceOf(address(this))); 
                            
    }


}
function claimDeposits() public onlyOwner {
        require(BundNFT.balanceOf(address(this)) > 0, "No bundNFT deposits in this contract");
        BundNFT.transfer(owner(), BundNFT.balanceOf(address(this))); 
                            
    }
//++++| Claim all bundNFT deposits |+++++