Sewmina 6 months ago
parent
commit
74ed3d2efb
1 changed files with 27 additions and 0 deletions
  1. 27 0
      GameData.sol

+ 27 - 0
GameData.sol

@@ -8,12 +8,17 @@ import "@openzeppelin/contracts/access/Ownable.sol";
 
 contract GameData is ERC1155, Ownable, ERC1155Burnable {
 
+
     //------------------------------ ERC1155 COLLECTION-------------------------------
+
+
     uint256 public constant TOURNAMENT_TICKETS = 0;
     uint256 public constant SafeCoins = 1;
     uint256 public constant PP = 2;
     uint256 public constant TOURNAMENT_TROPHIES = 3;
 
+    uint256 public nextUserId = 100; //Dynamically change with user count, hence: new id for new player 
+
     uint256 public ticketPrice = 0.0001 ether; // Price for each ticket
 
     constructor() ERC1155("http://linode.playpoolstudios.com/begula/nft_data/{id}.json") Ownable(msg.sender){
@@ -21,6 +26,7 @@ contract GameData is ERC1155, Ownable, ERC1155Burnable {
         _mint(msg.sender, SafeCoins, 10**27,"");
         _mint(msg.sender, PP, 10**27, "");
         _mint(msg.sender, TOURNAMENT_TROPHIES, 36000, "");
+
     }
 
     function buyTickets(uint256 amount) external  payable {
@@ -44,6 +50,9 @@ contract GameData is ERC1155, Ownable, ERC1155Burnable {
 
     //------------------------------Game Management -------------------------------
 
+
+
+    //-----------setters and getters--------------------/
     address public operator = 0x05Ed0E0905979682bBD13A4524B2B1300153847e;
     function setOperator(address newOp) external onlyOwner{
         operator = newOp;
@@ -70,6 +79,22 @@ contract GameData is ERC1155, Ownable, ERC1155Burnable {
     //-----------end of Setters and getters----------/
 
 
+    //----------User Management--------------------/
+
+    function GetCurrentUserIndex() public view returns(uint256){
+        return nextUserId;
+    }
+
+    function MintUser(uint256 newUserId,address newUserAddress) public{
+        require(msg.sender == operator, "Only the operator can do this");
+
+        _mint(newUserAddress, newUserId, 1, "");
+        nextUserId++;
+    }
+    //------------------------------/
+
+
+    //----------Tourneys and tickets--------------------/
     function useTicket(address user, uint256 tournament_id) public {
         require(balanceOf(user, 0) > 0, "Purchase tickets to participate in this");
         _burn(user, 0, 1);
@@ -83,4 +108,6 @@ contract GameData is ERC1155, Ownable, ERC1155Burnable {
 
         expiredTournaments.push(tournament_id);
     }
+    //------------------------------/
+
 }