Marco Antonio Corallo
MasterMind
An implementation of MasterMind on Ethereum Blockchain
function AFK(uint256 id) external nonpayable
sender put under accusation the opponent
Name |
Type |
Description |
id |
uint256 |
: game id |
function claimStakeByAFK(uint256 id) external nonpayable
transfer the stake to the player that accuse and win the AFK
Name |
Type |
Description |
id |
uint256 |
: game id |
function declareStake(uint256 id, uint256 stake) external nonpayable
set stake value. If the two players declare different values => close the game
Name |
Type |
Description |
id |
uint256 |
: game id |
stake |
uint256 |
: stake declared by the sender |
function joinGame() external nonpayable
Overload with no params: join a random game
function joinGame(uint256 id) external nonpayable
Name |
Type |
Description |
id |
uint256 |
: identifier of the game the challenger wants to join |
function leaveGame(uint256 id) external nonpayable
Allow a player to leave the game. If the stake has already been put, the give-up player lose the game.
Name |
Type |
Description |
id |
uint256 |
: game id |
function newGame() external nonpayable returns (uint256)
Overload with no params: create a new game without a specific challenger
Name |
Type |
Description |
_0 |
uint256 |
undefined |
function newGame(address challenger_addr) external nonpayable returns (uint256)
Name |
Type |
Description |
challenger_addr |
address |
: address of the player the game creator wants to play with or address(0) |
Name |
Type |
Description |
_0 |
uint256 |
game's id |
function prepareGame(uint256 id) external payable
Allow players to put stake. When both the players put it, shuffle roles If a player put a different stake from what was declared, the tx is reverted.
Name |
Type |
Description |
id |
uint256 |
: game id |
function sendCode(bytes32 _hash, uint256 id) external nonpayable
allow a player to send the secret code
Name |
Type |
Description |
_hash |
bytes32 |
: secret code, hashed and salted off-chain |
id |
uint256 |
: game id |
function sendFeedback(uint8 CC, uint8 NC, uint256 id) external nonpayable
allow the codemaker to send a feedback about the last guess
Name |
Type |
Description |
CC |
uint8 |
: number of colors belonging to the last guess in the correct position |
NC |
uint8 |
: number of colors belonging to the last guess, but not in the correc: game id positions |
id |
uint256 |
: game id |
function sendGuess(enum Color[4] code, uint256 id) external nonpayable
allow the codebreaker to send the secret code
Name |
Type |
Description |
code |
enum Color[4] |
: proposed secret code |
id |
uint256 |
: game id |
function startDispute(uint256 id, uint8 feedback_id) external nonpayable
allow the codebreaker to start a dispute on a given feedback
Name |
Type |
Description |
id |
uint256 |
: game id |
feedback_id |
uint8 |
: reference to the disputed feedback |
function submitSolution(uint256 id, enum Color[4] code, uint8[5] salt) external nonpayable
allow the codemaker to reveal the solution <code, salt>. Starts dispute timer.
Name |
Type |
Description |
id |
uint256 |
: game id |
code |
enum Color[4] |
: secret code he choose at the beginning |
salt |
uint8[5] |
: numeric code to improve robustness |
function updateScore(uint256 id) external nonpayable
after the dispute time update points and, if all turns have been played, draw winner
Name |
Type |
Description |
id |
uint256 |
: game id |
event AFKStart(uint256 indexed id, address who)
Name |
Type |
Description |
id indexed |
uint256 |
undefined |
who |
address |
undefined |
event AFKStop(uint256 indexed id)
Name |
Type |
Description |
id indexed |
uint256 |
undefined |
event Dispute(uint256 indexed id, uint8 feedback_id)
Name |
Type |
Description |
id indexed |
uint256 |
undefined |
feedback_id |
uint8 |
undefined |
event FeedbackSent(uint256 indexed id, address who, uint8 CC, uint8 NC)
Name |
Type |
Description |
id indexed |
uint256 |
undefined |
who |
address |
undefined |
CC |
uint8 |
undefined |
NC |
uint8 |
undefined |
event GameClosed(uint256 indexed id)
Name |
Type |
Description |
id indexed |
uint256 |
undefined |
event GameCreated(address indexed who, uint256 indexed id, address indexed challenger)
Name |
Type |
Description |
who indexed |
address |
undefined |
id indexed |
uint256 |
undefined |
challenger indexed |
address |
undefined |
event GameJoined(address indexed who, uint256 indexed id)
Name |
Type |
Description |
who indexed |
address |
undefined |
id indexed |
uint256 |
undefined |
event GameLeft(uint256 indexed id, address who)
Name |
Type |
Description |
id indexed |
uint256 |
undefined |
who |
address |
undefined |
event GuessSent(uint256 indexed id, address who, enum Color[4] code)
Name |
Type |
Description |
id indexed |
uint256 |
undefined |
who |
address |
undefined |
code |
enum Color[4] |
undefined |
event PointsUpdated(uint256 indexed id, uint8 points)
Name |
Type |
Description |
id indexed |
uint256 |
undefined |
points |
uint8 |
undefined |
event Punished(uint256 indexed id, address who)
Name |
Type |
Description |
id indexed |
uint256 |
undefined |
who |
address |
undefined |
event SecretCodeSent(uint256 indexed id, address who)
Name |
Type |
Description |
id indexed |
uint256 |
undefined |
who |
address |
undefined |
event Shuffled(uint256 indexed id, address _codemaker, address _codebreaker)
Name |
Type |
Description |
id indexed |
uint256 |
undefined |
_codemaker |
address |
undefined |
_codebreaker |
address |
undefined |
event SolutionSubmitted(uint256 indexed id, enum Color[4] code, uint8[5] salt)
Name |
Type |
Description |
id indexed |
uint256 |
undefined |
code |
enum Color[4] |
undefined |
salt |
uint8[5] |
undefined |
event StakeDeclared(uint256 indexed id, address who, uint256 _stake)
Name |
Type |
Description |
id indexed |
uint256 |
undefined |
who |
address |
undefined |
_stake |
uint256 |
undefined |
event StakePut(uint256 indexed id, address who, uint256 _stake)
Name |
Type |
Description |
id indexed |
uint256 |
undefined |
who |
address |
undefined |
_stake |
uint256 |
undefined |
event Tie(uint256 indexed id)
Name |
Type |
Description |
id indexed |
uint256 |
undefined |
event Transfered(uint256 indexed id, address who, uint256 howmuch)
Name |
Type |
Description |
id indexed |
uint256 |
undefined |
who |
address |
undefined |
howmuch |
uint256 |
undefined |
event Winning(uint256 indexed id, address player)
Name |
Type |
Description |
id indexed |
uint256 |
undefined |
player |
address |
undefined |