RankifyInstanceMainFacet#

Main facet for the Rankify protocol that handles game creation and management

Notice

Implements core game functionality, ERC token receivers, and reentrancy protection

createGame#

This function: - Validates the contract is initialized - Processes input parameters - Creates a new game with specified settings

function createGame(struct IRankifyInstance.NewGameParamsInput params) public
Input Type Description
params struct IRankifyInstance.NewGameParamsInput Input parameters for creating a new game

Notice

External function to create a new game

cancelGame#

This function: - Calls the `enforceIsGameCreator` function with `msg.sender`. - Cancels the game. - Emits a GameClosed event.

function cancelGame(uint256 gameId) public
Input Type Description
gameId uint256 The ID of the game.

Notice

Cancels a game with the provided game ID. gameId is the ID of the game.

leaveGame#

This function: - Calls the `quitGame` function with `msg.sender`, `true`, and `onPlayerQuit`.

function leaveGame(uint256 gameId) public
Input Type Description
gameId uint256 The ID of the game.

Notice

Allows a player to leave a game with the provided game ID. gameId is the ID of the game.

openRegistration#

This function: - Calls the `enforceIsGameCreator` function with `msg.sender`. - Calls the `enforceIsPreRegistrationStage` function. - Calls the `openRegistration` function. - Emits a RegistrationOpen event.

function openRegistration(uint256 gameId) public
Input Type Description
gameId uint256 The ID of the game.

Notice

Opens registration for a game with the provided game ID. gameId is the ID of the game.

joinGame#

This function: - Calls the `joinGame` function with `msg.sender`. - Calls the `fund` function with `bytes32(gameId)`. - Emits a PlayerJoined event.

function joinGame(uint256 gameId) public payable
Input Type Description
gameId uint256 The ID of the game.

Notice

Allows a player to join a game with the provided game ID. gameId is the ID of the game.

startGame#

This function: - Calls the `enforceGameExists` function. - Calls the `startGameEarly` function. - Emits a GameStarted event.

function startGame(uint256 gameId) public
Input Type Description
gameId uint256 The ID of the game.

Notice

Starts a game with the provided game ID early. gameId is the ID of the game.

onERC1155Received#

function onERC1155Received(address operator, address, uint256, uint256, bytes) public view returns (bytes4)

onERC1155BatchReceived#

function onERC1155BatchReceived(address operator, address, uint256[], uint256[], bytes) external view returns (bytes4)

onERC721Received#

function onERC721Received(address operator, address, uint256, bytes) external view returns (bytes4)

getContractState#

function getContractState() public pure returns (struct LibRankify.InstanceState)
Output Type Description
0 struct LibRankify.InstanceState LibRankify.InstanceState The current state of the contract

Notice

Returns the current state of the contract

getTurn#

function getTurn(uint256 gameId) public view returns (uint256)
Input Type Description
gameId uint256 The ID of the game
Output
0 uint256 uint256 The current turn of the game

Notice

Returns the current turn of the game with the specified ID

getGM#

function getGM(uint256 gameId) public view returns (address)
Input Type Description
gameId uint256 The ID of the game
Output
0 address address The game master of the game

Notice

Returns the game master of the game with the specified ID

getScores#

function getScores(uint256 gameId) public view returns (address[], uint256[])
Input Type Description
gameId uint256 The ID of the game
Output
0 address[] address[] The players in the game
1 uint256[] uint256[] The scores of the players

Notice

Returns the scores of the game with the specified ID

isOvertime#

function isOvertime(uint256 gameId) public view returns (bool)
Input Type Description
gameId uint256 The ID of the game
Output
0 bool bool Whether the game is in overtime

Notice

Returns whether the game with the specified ID is in overtime

isGameOver#

function isGameOver(uint256 gameId) public view returns (bool)
Input Type Description
gameId uint256 The ID of the game
Output
0 bool bool Whether the game is over

Notice

Returns whether the game with the specified ID is over

getPlayersGame#

function getPlayersGame(address player) public view returns (uint256)
Input Type Description
player address The address of the player
Output
0 uint256 uint256 The ID of the game

Notice

Returns the game ID of the game that the specified player is in

isLastTurn#

function isLastTurn(uint256 gameId) public view returns (bool)
Input Type Description
gameId uint256 The ID of the game
Output
0 bool bool Whether the game is in the last turn

Notice

Returns whether the game with the specified ID is in the last turn

isRegistrationOpen#

function isRegistrationOpen(uint256 gameId) public view returns (bool)
Input Type Description
gameId uint256 The ID of the game
Output
0 bool bool Whether registration is open

Notice

Returns whether registration is open for the game with the specified ID

gameCreator#

function gameCreator(uint256 gameId) public view returns (address)
Input Type Description
gameId uint256 The ID of the game
Output
0 address address The creator of the game

Notice

Returns the creator of the game with the specified ID

getGameRank#

function getGameRank(uint256 gameId) public view returns (uint256)
Input Type Description
gameId uint256 The ID of the game
Output
0 uint256 uint256 The rank of the game

Notice

Returns the rank of the game with the specified ID

estimateGamePrice#

function estimateGamePrice(uint128 minGameTime) public pure returns (uint256)
Input Type Description
minGameTime uint128 The minimum game time
Output
0 uint256 uint256 The estimated price of the game

Notice

Estimates the price of a game with the specified minimum game time

getPlayers#

function getPlayers(uint256 gameId) public view returns (address[])
Input Type Description
gameId uint256 The ID of the game
Output
0 address[] address[] The players in the game

Notice

Returns the players in the game with the specified ID

canStartGame#

function canStartGame(uint256 gameId) public view returns (bool)
Input Type Description
gameId uint256 The ID of the game
Output
0 bool bool Whether the game can be started early

Notice

Returns whether the game with the specified ID can be started early

canEndTurn#

function canEndTurn(uint256 gameId) public view returns (bool)
Input Type Description
gameId uint256 The ID of the game
Output
0 bool bool Whether the turn can be ended early

Notice

Returns whether the turn can be ended early for the game with the specified ID

isPlayerTurnComplete#

function isPlayerTurnComplete(uint256 gameId, address player) public view returns (bool)
Input Type Description
gameId uint256 The ID of the game
player address The address of the player
Output
0 bool bool Whether the player has completed their turn

Notice

Returns whether the player has completed their turn in the game with the specified ID

getPlayerVotedArray#

function getPlayerVotedArray(uint256 gameId) public view returns (bool[])
Input Type Description
gameId uint256 The ID of the game
Output
0 bool[] bool[] The voted array

Notice

Returns the voted array for the game with the specified ID

getPlayersMoved#

function getPlayersMoved(uint256 gameId) public view returns (bool[], uint256)
Input Type Description
gameId uint256 The ID of the game
Output
0 bool[] bool[] The players who have moved
1 uint256 uint256 The number of players who have moved

Notice

Returns the players who have moved in the game with the specified ID

isActive#

function isActive(uint256 gameId, address player) public view returns (bool)

getGameState#

function getGameState(uint256 gameId) public view returns (struct IRankifyInstance.GameStateOutput state)