Skip to content

Latest commit

 

History

History
111 lines (84 loc) · 3.7 KB

File metadata and controls

111 lines (84 loc) · 3.7 KB

MatchSystem Affected Tables

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.

joinQueue

function joinQueue(bytes32 boardEntity, bytes32 gameModeEntity) public override;

Affected Tables:

  • MatchPool: Adds the player entity to the match pool.

    • Key: queueEntity
    • Value: The player entity.
  • MatchPlayers: Adds the player entity to the match.

    • Key: matchEntity
    • Value: The player entity.
  • MatchPlayerStatus: Sets the player status to Matched.

    • Key: matchEntity, playerEntity
    • Value: MatchPlayerStatusTypes.Matched
  • MatchStatus: If a new match is created, sets the match status to Preparing.

    • Key: matchEntity
    • Value: MatchStatusTypes.Preparing
  • MatchConfig: If a new match is created, sets the match configuration with the given parameters.

    • Key: matchEntity
    • Value: The match configuration.
  • PlayerQueue: Sets the queue entity for the player.

    • Key: playerEntity
    • Value: The queue entity.
  • PlayerStatus: Sets the player status to Queueing.

    • Key: playerEntity
    • Value: PlayerStatusTypes.Queueing
  • Scenario:

    • Calls _tryCreateMatch if there are enough players in the queue to start a match.

setPlayerReadyAndStart

function setPlayerReadyAndStart(bytes32 matchEntity) public

Affected Tables:

  • MatchPlayerStatus: Sets the player status to Ready.

    • Key: matchEntity, matchPlayerEntity
    • Value: MatchPlayerStatusTypes.Ready
  • MatchStatus: Sets the match status to Active if all players are ready.

    • Key: matchEntity
    • Value: MatchStatusTypes.Active
  • Inventory: Initializes the player's inventory with GOLD_BALANCE if the match starts.

    • Key: matchEntity, matchPlayerEntity
    • Value: GOLD_BALANCE
  • MatchPreparationTime: Sets the preparation time for the match.

    • Key: matchEntity
    • Value: The current timestamp plus BUY_PREP_TIME
  • Scenario:

    • Sets the match status to Active if all players are ready and initializes their inventories.

leave

function leave() public override;

Affected Tables:

  • PlayerStatus: Sets the player status to None if the player leaves the queue.
    • Key: playerEntity
    • Value: PlayerStatusTypes.None
  • PlayerQueue: Clears the queue entity for the player.
    • Key: playerEntity
    • Value: bytes32(0)
  • MatchStatus: Sets the match status to Cancelled if the player leaves an ongoing match.
    • Key: matchEntity
    • Value: MatchStatusTypes.Cancelled
  • MatchPlayerSurrenders: Sets the surrender status for the player if they leave an active match.
    • Key: matchEntity, playerEntity
    • Value: true

Scenario:

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

claimVictory

function claimVictory(bytes32 matchEntity) public;

Affected Tables:

  • MatchWinner: Sets the match winner after a player claims victory.
    • Key: matchEntity
    • Value: playerEntity
  • MatchPlayerSurrenders: Sets the surrender status for the opponent.
    • Key: matchEntity, opponentEntity
    • Value: true

Scenario:

  • Calls _isOpponentActive to verify the opponent's status.
  • Calls _setMatchWinnerAfterSurrender to set the match winner and update surrender status.