Skip to content

Latest commit

 

History

History
51 lines (30 loc) · 1.47 KB

File metadata and controls

51 lines (30 loc) · 1.47 KB

TurnSystem Smart Contract

The TurnSystem contract enables players in a match to end or skip their turn.

endTurn

function endTurn(bytes32 _matchEntity) external;

Ends the turn for the current player in a match. This function ensures that only the active player can end their turn and records the player's actions for that turn.

  • The function verifies whether the sender is the active player for the match. If the sender is not the active player, the function reverts with an error.

  • Parameters:

    • matchEntity: The unique identifier for the match.
  • Sample Code:

bytes32 matchEntity = 0x000000000000000000000000000000000000000000000000000000000000beef;

world.tacticsWar__endTurn(matchEntity);

Note: Only the active player in the match can call this function. If any other player tries to call it, the function will revert with an error.


surrender

function surrender(bytes32 _matchEntity) external;

Allows the player calling this function to surrender from the specified match.

  • Parameters:

    • matchEntity: The unique identifier for the match in which the player is surrendering.
  • Sample Code:

bytes32 matchEntity = 0x000000000000000000000000000000000000000000000000000000000000beef;

world.tacticsWar__surrender(matchEntity);

Note: If only one player remains after others have surrendered, that player will be declared the winner and the game will end automatically.