contract SuperplayerEquipmentV001 is EquipGeneratorWhitelist,ERC721 ,ERC721Metadata("SuperPlayerEquipment","SPE") {

  using SafeMath for uint256;

  enum EquipmentPart {Weapon ,Head,Coat,Pants ,Shoes }
  enum EquipmentRareness {White,Green,Blue,Purple, Orange,Red }

  struct Equipment {
    string key; //using key to contains part and rareness format : rareness_part_name
//    EquipmentPart part;
 //   EquipmentRareness rareness;
    uint[] randomProperties;
    uint[] extraRandomProperties; //for equipment enhance
  }


  event Birth(uint256 tokenId , string key,  uint[] randomProps,uint[]  extraProps);

  uint256 TotalEquipNum; // for ERC721


  Equipment[] private equips;

  constructor() public{

  }

  function totalSupply() public view returns (uint) {
    return TotalEquipNum;
  }

  function addEquipmentGenerator(address addr, string memory category) onlyOwner public returns(bool success){
    return addAddressToWhitelist(addr,category);
  }

  function removeEquipmentGenerator(address addr) onlyOwner public returns(bool success){
    return removeAddressFromWhitelist(addr);
  }

  /*
   * This privilege should transfer to the community nodes ,but as the beginning,our team control it for game's quickly  iteration
   */
  function createEquip(address to, string memory key, uint[] memory randomProps,uint[] memory extraRandomProps ) canGenerate public returns(uint256){
    Equipment memory newEquip = Equipment({
      key : key,
//      part :part,
 //     rareness : rareness,
      randomProperties : randomProps,
      extraRandomProperties :extraRandomProps
    });
    TotalEquipNum = TotalEquipNum.add(1);
    uint256 newEquipId = equips.push(newEquip).sub(1);
    emit Birth(newEquipId,key,/*part,rareness,*/randomProps,extraRandomProps);
    _mint(to,newEquipId);

    return newEquipId;
  }


  function getEquip(uint256 idx) public view returns(
    string memory key,
//    EquipmentPart part,
 //   EquipmentRareness rareness,
    uint[] memory randomProps
  ){
      require(idx < TotalEquipNum);
      Equipment storage equip = equips[idx];
      key = equip.key;
  //    part = equip.part;
   //   rareness = equip.rareness;
      randomProps = equip.randomProperties;
  }
}
function createEquip(address to, string memory key, uint[] memory randomProps,uint[] memory extraRandomProps ) canGenerate public returns(uint256){
  Equipment memory newEquip = Equipment({
    key : key,
      part :part,
/     rareness : rareness,
    randomProperties : randomProps,
    extraRandomProperties :extraRandomProps
  });
  TotalEquipNum = TotalEquipNum.add(1);
  uint256 newEquipId = equips.push(newEquip).sub(1);
  emit Birth(newEquipId,key,/*part,rareness,*/randomProps,extraRandomProps);
  _mint(to,newEquipId);

  return newEquipId;
}

/*
 * This privilege should transfer to the community nodes ,but as the beginning,our team control it for game's quickly  iteration
 */