GameRPS

Git Source

State Variables

ROCK

bytes1 public constant ROCK = bytes1(uint8(Hand.Rock));

PAPER

bytes1 public constant PAPER = bytes1(uint8(Hand.Paper));

SCISSORS

bytes1 public constant SCISSORS = bytes1(uint8(Hand.Scissors));

games

mapping(address => RPSPlay[]) public games;

Functions

getUserGameLength

function getUserGameLength(address _user) public view returns (uint256);

play

function play(address _player, uint256 _amount, bytes1[] memory _hands) public virtual;

play

function play(address _player, uint256 _amount, bytes32 _hands, uint8 _streak) public virtual;

handsToBytes32

function handsToBytes32(bytes1[] memory _hands) public pure returns (bytes32 result);

toRPS

function toRPS(uint256 _amount, bytes32 _hands, uint8 _streak) public view returns (RPSPlay memory result);

calcMultiplier

function calcMultiplier(uint8 _len, bytes32 _player, bytes32 _dealer) internal pure returns (uint256 multiplier);

rule

function rule(bytes1 _player, bytes1 _dealer) internal pure returns (uint8);

verify

function verify(RPSPlay memory data) internal view returns (uint8 code);

getDealerHash

function getDealerHash(RPSPlay memory data) public view returns (bytes32);

claimReward

function claimReward(address owner) public returns (uint256 prize);

Events

GamePlayed

event GamePlayed(address indexed player, uint256 indexed countPlay, uint256 targetBlock, uint256 timestamp);

Claimed

event Claimed(address indexed player, uint256 reward);

Structs

RPSPlay

struct RPSPlay {
    address player;
    uint256 timestamp;
    uint256 targetBlock;
    uint256 bet;
    bytes32 hands;
    uint8 streak;
}

Enums

Hand

enum Hand {
    Rock,
    Paper,
    Scissors
}