The MatchSystem contract handles the creation and management of matches. It manages queues for matchmaking, allows players to mark themselves as ready, starts matches when all players are ready, and handles match cancellations.
function joinQueue(bytes32 boardEntity, bytes32 gameModeEntity) public override;Adds a player to the matchmaking queue based on a specific board and game mode. If a match exists with one player already in the queue, a new match is created. If no match exists, the player is added to the match pool.
-
boardEntity: A unique identifier for the board entity. This will be a 32-byte hash (e.g., 0xa3b5c8...e0f9).gameModeEntity: A unique identifier for the game mode entity, which is also a 32-byte hash (e.g., 0x5a6b7c...f2e1).
bytes32 boardEntity = 0x0000000000000000000000000000000000000000000000000000000000000001;
bytes32 gameModeEntity = 0x0000000000000000000000000000000000000000000000000000000000000002;
world.tacticsWar__joinQueue(boardEntity, gameModeEntity);Note: The
boardEntityandgameModeEntityare 32-byte hashes that represent unique identifiers for the game board and game mode respectively.
function setPlayerReadyAndStart(bytes32 matchEntity) public;Marks a player as ready in a match and starts the match if all players are ready.
-
matchEntity: A 32-byte identifier that uniquely identifies the match
bytes32 matchEntity = 0x000000000000000000000000000000000000000000000000000000000000beef;
world.tacticsWar__setPlayerReadyAndStart(matchEntity);Note:
- The
matchEntityis a 32-byte identifier that represents the match where players are marked as ready.Only a player in the matchcan call this function to set themselves as ready. If all players in the match are ready, this function will start the match.
Allows a player to leave the matchmaking queue or an ongoing match. The behavior of this function depends on the player's current status:
-
If the player is in the queue, they will be removed from the queue.
-
If the player is in an ongoing match, the match will be canceled.
-
If the player is in an active match, the player will surrender, and the match will be finished.
world.tacticsWar__leave();Note: The function takes no parameters and determines the player's state internally.
Allows a player to claim victory in a match if the opponent is inactive.
-
matchEntity: A 32-byte identifier that uniquely identifies the match
bytes32 matchEntity = 0x000000000000000000000000000000000000000000000000000000000000beef;
world.tacticsWar__claimVictory(matchEntity);Note: Only a player who is part of the match can call this function to claim victory.