Skip to content

Latest commit

 

History

History
38 lines (27 loc) · 1.6 KB

File metadata and controls

38 lines (27 loc) · 1.6 KB

MoveSystem Smart Contract

The MoveSystem contract enables players in a match to move pieces within the game.

move

function move(
    bytes32 _matchEntity,
    bytes32 _entity,
    PositionData[] memory _path
) external;
  • Moves a piece on the board along a specified path. This function handles player turn validation, updates the active player status, and ensures that a piece is moved according to the game rules.

  • The function checks if it is the player's turn before allowing the move. It updates the active player data and resets player actions if necessary. The function then moves the piece along the provided path and updates the player's actions.

  • Parameters:

    • matchEntity: The unique identifier for the match.
    • entity: The unique identifier for the piece to be moved.
    • path: An array of PositionData representing the path to move along. Each PositionData object contains the x and y coordinates that define the piece's movement on the board.`
  • Sample Code:

bytes32 matchEntity = 0x0000000000000000000000000000000000000000000000000000000000000001;
bytes32 entity = 0x0000000000000000000000000000000000000000000000000000000000000002;

PositionData[] path = new PositionData[](3)
path[0] = PositionData(1, 1);
path[1] = PositionData(2, 1);
path[2] = PositionData(2, 2);

world.tacticsWar__move(matchEntity, entity, path);

Note: Movement should adhere to square patterns. For example, a move from (1,1) to (2,2) should follow a path such as (1,1) → (2,1) → (2,2). A direct diagonal move (e.g., from (1,1) to (2,2) in a single step) is not allowed.