function core(uint256 _round, address _pAddr, uint256 _eth) internal {
      require(_round < maxRound);
      Round storage current = rounds[_round];
      require(current.activated && !current.finalized);

      
      
      
      
      
      
      if (block.timestamp > current.endTime) {
          
          finalize(_round);
          players[_pAddr].wallet = _eth.add(players[_pAddr].wallet);
          return;
          
          
          
      }
      
      if (_eth < 1000000000) {
          players[_pAddr].wallet = _eth.add(players[_pAddr].wallet);
          return;
      }
      
      
      uint256 _keys = keys(current.eth, _eth);
      
      if (_keys <= 0) {
          
          
          players[_pAddr].wallet = _eth.add(players[_pAddr].wallet);
          return;
      }

      if (_keys >= decimals) {
          
          current.winner = _pAddr;
          current.endTime = timeIncrease.add(current.endTime.mul(_keys / decimals));
          if (current.endTime.sub(block.timestamp) > current.roundTime) {
              current.endTime = block.timestamp.add(current.roundTime);
          }
          
          if (_keys >= decimals.mul(10)) {
              
              current.luckyCounter = current.luckyCounter.add(1);
              if(current.luckyCounter >= current.nextLucky) {
                  players[_pAddr].lucky = current.luckyPool.add(players[_pAddr].lucky);
                  playerRoundData[_pAddr][_round].lucky = current.luckyPool.add(playerRoundData[_pAddr][_round].lucky);
                  
                  emit Lucky(_pAddr, _round, current.nextLucky, current.luckyPool);
                  
                  current.pool = current.pool.sub(current.luckyPool);
                  current.luckyPool = 0;
                  current.nextLucky = luckyNumber.add(current.nextLucky);
                  
              }
          }
      }
      
      
      uint256 toOwnerAmount = _eth.sub(_eth.mul(toSpread) / 1000);
      toOwnerAmount = toOwnerAmount.sub(_eth.mul(toNext) / 1000);
      toOwnerAmount = toOwnerAmount.sub(_eth.mul(toRefer) / 1000);
      toOwnerAmount = toOwnerAmount.sub(_eth.mul(toPool) / 1000);
      current.pool = (_eth.mul(toPool) / 1000).add(current.pool);
      current.luckyPool = ((_eth.mul(toPool) / 1000).mul(toLucky) / 1000).add(current.luckyPool);
      
      if (current.keys == 0) {
          
          toOwnerAmount = toOwnerAmount.add((_eth.mul(toSpread) / 1000));
      } else {
          
          current.mask = current.mask.add((_eth.mul(toSpread).mul(10 ** 15)) / current.keys);
          
          
          
          
          
      }
      ownerPool = toOwnerAmount.add(ownerPool);

      
      playerRoundData[_pAddr][_round].keys = _keys.add(playerRoundData[_pAddr][_round].keys);
      current.keys = _keys.add(current.keys);
      current.eth = _eth.add(current.eth);

      
      
      playerRoundData[_pAddr][_round].mask = (current.mask.mul(_keys) / (10**18)).add(playerRoundData[_pAddr][_round].mask);
      
      
      if (players[_pAddr].referer == 0) {
          ownerPool = ownerPool.add(_eth.mul(toRefer) / 1000);
      } else {
          address _referer = id2Players[players[_pAddr].referer];
          assert(_referer != address(0));
          players[_referer].affiliate = (_eth.mul(toRefer) / 1000).add(players[_referer].affiliate);
          playerRoundData[_referer][_round].affiliate = (_eth.mul(toRefer) / 1000).add(playerRoundData[_referer][_round].affiliate);
      }

      
      
      Round storage next = rounds[nextRound];
      
      if (nextRound >= maxRound) {	 
          next = rounds[maxRound - 1];	 
      }
      
      next.pool = (_eth.mul(toNext) / 1000).add(next.pool);
      
        
      
      if(next.pool >= next.minimumPool && !next.activated) {
        next.activated = true;
        next.endTime = block.timestamp.add(next.roundTime);
        
        next.winner = address(0);

        if(nextRound != maxRound) {
          nextRound = nextRound.add(1);
        }
      }
      
      emit Buy(_pAddr, _keys, _eth, _round);

  }