RankifyInstanceGameMastersFacet#
Facet handling game master functionality for Rankify instances
Notice
Implements game master specific operations like vote submission and game management
OverTime#
event OverTime(uint256 gameId)
ProposalScore#
event ProposalScore(uint256 gameId, uint256 turn, string proposalHash, string proposal, uint256 score)
TurnEnded#
event TurnEnded(uint256 gameId, uint256 turn, address[] players, uint256[] scores, string[] newProposals, uint256[] proposerIndices, uint256[][] votes)
LastTurn#
event LastTurn(uint256 gameId)
GameOver#
event GameOver(uint256 gameId, address[] players, uint256[] scores)
ProposalSubmitted#
event ProposalSubmitted(uint256 gameId, uint256 turn, address proposer, bytes32 commitmentHash, string proposalEncryptedByGM)
ProposalParams#
struct ProposalParams {
uint256 gameId;
string encryptedProposal;
bytes32 commitmentHash;
address proposer;
}
VoteSubmitted#
event VoteSubmitted(uint256 gameId, uint256 turn, address player, string votesHidden)
submitVote#
function submitVote(uint256 gameId, string encryptedVotes, address voter) public
Notice
Submits a vote for a game. gameId
is the ID of the game. encryptedVotes
is the encrypted votes. voter
is the address of the voter.
Notice
Emits a VoteSubmitted event.
Notice
Requirements:
Notice
- The caller must be a game master of the game with
gameId
. - The game with
gameId
must exist. - The game with
gameId
must have started. - The game with
gameId
must not be over. voter
must be in the game withgameId
.- The current turn of the game with
gameId
must be greater than 1.
submitProposal#
function submitProposal(struct RankifyInstanceGameMastersFacet.ProposalParams proposalData) public
Notice
Submits a proposal for a game. proposalData
is the proposal data.
Notice
Requirements:
Notice
- The game with
proposalData.gameId
must exist. - The caller must be a game master of the game with
proposalData.gameId
.
endTurn#
function endTurn(uint256 gameId, uint256[][] votes, string[] newProposals, uint256[] proposerIndices) public
Notice
Ends the current turn of a game with the provided game ID. gameId
is the ID of the game. votes
is the array of votes.
newProposals
is the array of new proposals for the upcoming voting round.
proposerIndices
is the array of indices of the proposers in the previous voting round.
Notice
emits a ProposalScore event for each player if the turn is not the first. emits a TurnEnded event.
Notice
Modifies:
Notice
- Calls the
_nextTurn
function withgameId
andnewProposals
. - Resets the number of commitments of the game with
gameId
to 0. - Resets the proposal commitment hash and ongoing proposal of each player in the game with
gameId
.
Notice
Requirements:
Notice
- The caller must be a game master of the game with
gameId
. - The game with
gameId
must have started. - The game with
gameId
must not be over. - newProposals array MUST be sorted randomly to ensure privacy votes and proposerIndices MUST correspond to players array from game.getPlayers()