<commit_before>pragma solidity ^0.4.11;

contract RockPaperScissors {

    enum Stages {
        playerOneThrow,
        playerTwoThrow,
        playerOneReveal,
        playerTwoReveal,
        determineWinner
    }
    
    Stages public stage = Stages.playerOneThrow;
    
    modifier atStage(Stages _stage) {
        require(stage == _stage);
        _;
    }
    
    function nextStage() internal {
        stage = Stages(uint(stage) + 1);
    }
    
    Player player1;
    Player player2;
    uint bet;
    uint public resetTime;
    
    struct Player{
        address addy;
        bytes32 commitHash;
        uint commitTime;
        uint gameThrow;
        uint revealTime;
    }
    
    function RockPaperScissors(address _player1, address _player2, uint _bet)  {
        player1.addy = _player1;
        player2.addy = _player2;
        bet = _bet;
    }

    modifier includesPayment(){if(msg.value == bet){ _; }else{ throw; } }
    
    function playerOneCommit(bytes32 commitHash) payable atStage(Stages.playerOneThrow) includesPayment() {
        if(msg.sender == player1.addy) {
            player1.commitHash = commitHash;
            player1.commitTime = now;
            resetTime = 0;
            nextStage();
        } else {
            throw;
        }
    }
    
    function playerTwoCommit(bytes32 commitHash) payable atStage(Stages.playerTwoThrow) includesPayment() {
        if(msg.sender == player2.addy) {
            player2.commitHash = commitHash;
            player2.commitTime = now;
            nextStage();
        } else {
            throw;
        }
    }
    

    function playerOneReveal(uint gameThrow, uint secret) atStage(Stages.playerOneReveal) {
        bytes32 commitHash = sha3(gameThrow, secret);
        if(commitHash == player1.commitHash) {
            player1.gameThrow = gameThrow;
            player1.revealTime = now;
            nextStage();
        } else {
            throw;
        }
    }
    
    function playerTwoReveal(uint gameThrow, uint secret) atStage(Stages.playerTwoReveal) {
        bytes32 commitHash = sha3(gameThrow, secret);
        if(commitHash == player2.commitHash) {
            player2.gameThrow = gameThrow;
            player2.revealTime = now;
            nextStage();
        } else {
            throw;
        }
    }

    function determineWinner() atStage(Stages.determineWinner) {
        address winner;
        if(player1.gameThrow == 1 && player2.gameThrow == 2) {
            winner = player2.addy;
        } else if(player1.gameThrow == 2 && player2.gameThrow == 3) {
            winner = player2.addy;
        } else if(player1.gameThrow == 3 && player2.gameThrow == 1) {
            winner = player2.addy;
        } else if (player1.gameThrow != player2.gameThrow) {
            winner = player1.addy;
        }
        
        if(winner != 0x0) {
            winner.transfer(this.balance);
            reset();
        } else { //tie
            splitFunds();
        }
    }
    
    function returnFunds(){<commit_msg>Rework solidity, set more variables to public<commit_after>pragma solidity ^0.4.11;

contract RockPaperScissors {

    enum Stages {
        playerOneThrow,
        playerTwoThrow,
        playerOneReveal,
        playerTwoReveal,
        determineWinner
    }
    
    Stages public stage = Stages.playerOneThrow;
    
    modifier atStage(Stages _stage) {
        require(stage == _stage);
        _;
    }
    
    function nextStage() internal {
        stage = Stages(uint(stage) + 1);
    }
    
    Player public player1;
    Player public player2;
    uint public bet = 0;
    uint public resetTime;
    address public winner;
    
    struct Player{
        address addy;
        bytes32 commitHash;
        uint commitTime;
        uint gameThrow;
        uint revealTime;
    }
    
    function RockPaperScissors(address _player1, address _player2, uint _bet)  {
        player1.addy = _player1;
        player2.addy = _player2;
        bet = _bet;
    }

    modifier includesPayment(){if(msg.value == bet){ _; }else{ throw; } }
    
    function playerOneCommit(bytes32 commitHash) payable atStage(Stages.playerOneThrow) includesPayment() {
        if(msg.sender == player1.addy) {
            player1.commitHash = commitHash;
            player1.commitTime = now;
            resetTime = 0;
            nextStage();
        } else {
            throw;
        }
    }
    
    function playerTwoCommit(bytes32 commitHash) payable atStage(Stages.playerTwoThrow) includesPayment() {
        if(msg.sender == player2.addy) {
            player2.commitHash = commitHash;
            player2.commitTime = now;
            nextStage();
        } else {
            throw;
        }
    }
    

    function playerOneReveal(uint gameThrow, uint secret) atStage(Stages.playerOneReveal) {
        bytes32 commitHash = sha3(gameThrow, secret);
        if(commitHash == player1.commitHash) {
            player1.gameThrow = gameThrow;
            player1.revealTime = now;
            nextStage();
        } else {
            throw;
        }
    }
    
    function playerTwoReveal(uint gameThrow, uint secret) atStage(Stages.playerTwoReveal) {
        bytes32 commitHash = sha3(gameThrow, secret);
        if(commitHash == player2.commitHash) {
            player2.gameThrow = gameThrow;
            player2.revealTime = now;
            nextStage();
            determineWinner();
        } else {
            throw;
        }
    }

    function determineWinner() atStage(Stages.determineWinner) {
        
        if(player1.gameThrow == 1 && player2.gameThrow == 2) {
            winner = player2.addy;
        } else if(player1.gameThrow == 2 && player2.gameThrow == 3) {
            winner = player2.addy;
        } else if(player1.gameThrow == 3 && player2.gameThrow == 1) {
            winner = player2.addy;
        } else if (player1.gameThrow != player2.gameThrow) {
            winner = player1.addy;
        }
        
        if(winner != 0x0) {
            winner.transfer(this.balance);
        } else { //tie
            reset();
        }
    }
    
    function returnFunds(){
{'fraction_non_alphanumeric': 0.09494290375203915, 'fraction_numerical': 0.01908646003262643, 'mean_word_length': 1.8046660567246111, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5153832', 'n_tokens_mistral': 1829, 'n_tokens_neox': 1782, 'n_words': 362}