contract StarCoin is Ownable, StandardToken {
    using SafeMath for uint;
    address gateway;
    string public name = "EtherPornStars Coin";
    string public symbol = "EPS";
    uint8 public decimals = 18;
    mapping (uint8 => address) public studioContracts;
    mapping (address => bool) public isMinter;
    event Withdrawal(address indexed to, uint256 value);
    event Burn(address indexed from, uint256 value);
    modifier onlyMinters {
      require(msg.sender == owner || isMinter[msg.sender]);
      _;
    }

    constructor () public {
  }
  /**
   * @dev Future sidechain integration for studios.
   */
    function setGateway(address _gateway) external onlyOwner {
        gateway = _gateway;
    }


    function _mintTokens(address _user, uint256 _amount) private {
        require(_user != 0x0);
        balances[_user] = balances[_user].add(_amount);
        totalSupply_ = totalSupply_.add(_amount);
        emit Transfer(address(this), _user, _amount);
    }

    function rewardTokens(address _user, uint256 _tokens) external   { 
        require(msg.sender == owner || isMinter[msg.sender]);
        _mintTokens(_user, _tokens);
    }
    function buyStudioStake(address _user, uint256 _tokens) external   { 
        require(msg.sender == owner || isMinter[msg.sender]);
        _burn(_user, _tokens);
    }
    function transferFromStudio(
      address _from,
      address _to,
      uint256 _value
    )
      external
      returns (bool)
    {
      require(msg.sender == owner || isMinter[msg.sender]);
      require(_value <= balances[_from]);
      require(_to != address(0));

      balances[_from] = balances[_from].sub(_value);
      balances[_to] = balances[_to].add(_value);
      emit Transfer(_from, _to, _value);
      return true;
  }

    function() payable public {
        // Intentionally left empty, for use by studios
    }

    function accountAuth(uint256 /*_challenge*/) external {
        // Does nothing by design
    }

    function burn(uint256 _amount) external {
        require(balances[msg.sender] >= _amount);
        balances[msg.sender] = balances[msg.sender].sub(_amount);
        totalSupply_ = totalSupply_.sub(_amount);
        emit Burn(msg.sender, _amount);
    }

    function withdrawBalance(uint _amount) external {
        require(balances[msg.sender] >= _amount);
        balances[msg.sender] = balances[msg.sender].sub(_amount);
        totalSupply_ = totalSupply_.sub(_amount);
        uint ethexchange = _amount.div(2);
        msg.sender.transfer(ethexchange);
    }

    function setIsMinter(address _address, bool _value) external onlyOwner {
        isMinter[_address] = _value;
    }

    function depositToGateway(uint256 amount) external {
        transfer(gateway, amount);
    }
}
function setGateway(address _gateway) external onlyOwner {
    gateway = _gateway;
}

/**
 * @dev Future sidechain integration for studios.
 */