This document provides an overview of the tables affected by various functions within the MatchSystem contract. Each section describes the function, the affected tables, and the values set in those tables.
function joinQueue(bytes32 boardEntity, bytes32 gameModeEntity) public override;-
MatchPool: Adds the player entity to the match pool.
- Key:
queueEntity - Value: The player entity.
- Key:
-
MatchPlayers: Adds the player entity to the match.
- Key:
matchEntity - Value: The player entity.
- Key:
-
MatchPlayerStatus: Sets the player status to
Matched.- Key:
matchEntity,playerEntity - Value:
MatchPlayerStatusTypes.Matched
- Key:
-
MatchStatus: If a new match is created, sets the match status to
Preparing.- Key:
matchEntity - Value:
MatchStatusTypes.Preparing
- Key:
-
MatchConfig: If a new match is created, sets the match configuration with the given parameters.
- Key:
matchEntity - Value: The match configuration.
- Key:
-
PlayerQueue: Sets the queue entity for the player.
- Key:
playerEntity - Value: The queue entity.
- Key:
-
PlayerStatus: Sets the player status to
Queueing.- Key:
playerEntity - Value:
PlayerStatusTypes.Queueing
- Key:
-
- Calls
_tryCreateMatchif there are enough players in the queue to start a match.
- Calls
function setPlayerReadyAndStart(bytes32 matchEntity) public-
MatchPlayerStatus: Sets the player status to
Ready.- Key:
matchEntity,matchPlayerEntity - Value:
MatchPlayerStatusTypes.Ready
- Key:
-
MatchStatus: Sets the match status to
Activeif all players are ready.- Key:
matchEntity - Value:
MatchStatusTypes.Active
- Key:
-
Inventory: Initializes the player's inventory with
GOLD_BALANCEif the match starts.- Key:
matchEntity,matchPlayerEntity - Value:
GOLD_BALANCE
- Key:
-
MatchPreparationTime: Sets the preparation time for the match.
- Key:
matchEntity - Value: The current timestamp plus
BUY_PREP_TIME
- Key:
-
- Sets the match status to
Activeif all players are ready and initializes their inventories.
- Sets the match status to
function leave() public override;- PlayerStatus: Sets the player status to
Noneif the player leaves the queue.- Key:
playerEntity - Value:
PlayerStatusTypes.None
- Key:
- PlayerQueue: Clears the queue entity for the player.
- Key:
playerEntity - Value:
bytes32(0)
- Key:
- MatchStatus: Sets the match status to
Cancelledif the player leaves an ongoing match.- Key:
matchEntity - Value:
MatchStatusTypes.Cancelled
- Key:
- MatchPlayerSurrenders: Sets the surrender status for the player if they leave an active match.
- Key:
matchEntity,playerEntity - Value:
true
- Key:
Calls _leaveQueue if the player is in the queue.
Calls _cancelMatch if the player is in an ongoing match.
Calls _surrender if the player is in an active match
function claimVictory(bytes32 matchEntity) public;- MatchWinner: Sets the match winner after a player claims victory.
- Key:
matchEntity - Value:
playerEntity
- Key:
- MatchPlayerSurrenders: Sets the surrender status for the opponent.
- Key:
matchEntity,opponentEntity - Value:
true
- Key:
- Calls
_isOpponentActiveto verify the opponent's status. - Calls
_setMatchWinnerAfterSurrenderto set the match winner and update surrender status.