contract armors is ERC721Enumerable, Ownable, RandomlyAssigned {
  using Strings for uint256;
  
  string public baseExtension = ".json";
  uint256 public cost = 0.001 ether;
  uint256 public maxBombSupply = 7000;
  uint256 public maxPublicSupply = 3000;
  uint256 public maxARMORSupply = 10000;
  uint256 public maxMintAmount = 20;
  bool public paused = false;
  
  string public baseURI = "https://ipfs.io/ipfs/QmY5czybYyGXpYz4t6Q8TscGgQfHTWUGqWsVYkBPrU5JzF/";
  
    //Allow Bomb holders to mint for free
  
  address public BombAddress = 0x7AB2352b1D2e185560494D5e577F9D3c238b78C5;
  BombInterface BombContract = BombInterface(BombAddress);
  uint public BombOwnersSupplyMinted = 0;
  uint public publicSupplyMinted = 0;

  constructor(
  ) ERC721("Armor", "Arm")
  RandomlyAssigned(10000, 1) {}

  // internal
  function _baseURI() internal view virtual override returns (string memory) {
    return baseURI;
  }

  function BombFreeMint(uint256 _mintAmount) public {
    require(!paused);
    require(_mintAmount > 0);
    require(_mintAmount <= maxMintAmount);
    require(BombOwnersSupplyMinted + _mintAmount <= maxBombSupply, "No more Bomb owner claims");
    require(totalSupply() + _mintAmount <= maxARMORSupply);
    require(BombContract.balanceOf(msg.sender) > 0, "Must own a Bomb to claim from this method");
    BombOwnersSupplyMinted = BombOwnersSupplyMinted + _mintAmount;
    
    for (uint256 i = 1; i <= _mintAmount; i++) {
        uint256 mintIndex = nextToken();
    if (totalSupply() < maxARMORSupply) {
                _safeMint(_msgSender(), mintIndex);
    }
   }
  }
  
   function publicmint(uint256 _mintAmount) public payable {
    require(!paused);
    require(_mintAmount > 0);
    require(_mintAmount <= maxMintAmount);
    require(totalSupply() + _mintAmount <= maxARMORSupply);
    require(publicSupplyMinted + _mintAmount <= maxPublicSupply, "No more public supply left");
    publicSupplyMinted = publicSupplyMinted + _mintAmount;
    require(msg.value >= cost * _mintAmount);

    for (uint256 i = 1; i <= _mintAmount; i++) {
        uint256 mintIndex = nextToken();
     if (totalSupply() < maxARMORSupply) {
                _safeMint(_msgSender(), mintIndex);
    }
   }
  }

  function walletOfOwner(address _owner)
    public
    view
    returns (uint256[] memory)
  {
    uint256 ownerTokenCount = balanceOf(_owner);
    uint256[] memory tokenIds = new uint256[](ownerTokenCount);
    for (uint256 i; i < ownerTokenCount; i++) {
      tokenIds[i] = tokenOfOwnerByIndex(_owner, i);
    }
    return tokenIds;
  }

  function tokenURI(uint256 tokenId)
    public
    view
    virtual
    override
    returns (string memory)
  {
    require(
      _exists(tokenId),
      "ERC721Metadata: URI query for nonexistent token"
    );

    string memory currentBaseURI = _baseURI();
    return bytes(currentBaseURI).length > 0
        ? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension))
        : "";
  }

  //only owner

  function withdraw() public payable onlyOwner {
    require(payable(msg.sender).send(address(this).balance));
  }
}
function _baseURI() internal view virtual override returns (string memory) {
    return baseURI;
  }
// internal