This document provides an overview of the tables affected by various functions within the CombatSystem contract. Each section describes the function, the affected tables, and the values set in those tables.
function moveOrAttack(
bytes32 _matchEntity,
bytes32 _entity,
PositionData[] memory path
) external;- Position: Updates the positions of the piece entities.
- Key:
matchEntity,entity - Value: The new position of the piece.
- Key:
- EntityAtPosition: Updates the entity's position on the board.
- Key:
matchEntity,x,y - Value: The entity that occupies the new position.
- Key:
- ActionStatus: Updates the action status for the active player.
- Key:
matchEntity,playerEntity - Values:
movesExecuted: Incremented by 1 if the last position in the path is unoccupied.
- Key:
- ActivePlayer: Updates the active player for the match.
- Key:
matchEntity - Value: The next player in the turn order if the move and attack actions are consumed or if the player ends their turn.
- Key:
- 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.
- Calls
_moveif the target position is unoccupied. (Refer to MoveSystem Affected Tables for detailed information on the tables affected by the_movefunction.)
function attack(
bytes32 _matchEntity,
bytes32 _entity,
bytes32 _target
) external;- Battle: Updates the battle status of the target entity.
- Key:
matchEntity,targetEntity - Value: The updated battle data of the target entity.
- Key:
- LastAttack: Records the details of the last attack made.
- Key:
matchEntity,targetEntity - Values:
attackerPieceEntity: The piece entity that initiated the attack.targetPieceCurrentHealth: The current health of the target entity after the attack.attackerPlayerAddress: The address of the player who initiated the attack.attackerPlayerEntity: The player entity that initiated the attack.
- Key:
- ActivePlayer: Updates the active player for the match.
- Key:
matchEntity - Value: The next player in the turn order if the move and attack actions are consumed or if the player ends their turn.
- Key:
- EntityAtPosition: Removes the entity from the board if the entity is destroyed.
- Key:
matchEntity,x,y - Value: The entity that no longer occupies the position.
- Key:
- Position: Removes the position record if the entity is destroyed.
- Key:
matchEntity,entity - Value: The position that the entity no longer occupies.
- Key:
- ActionStatus: Updates the action status for the active player.
- Key:
matchEntity,playerEntity - Values:
battlesExecuted: Incremented by 1
- Key:
- Initiates a combat action between two entities. This function validates the target, updates the battle status of the target entity, and records the details of the attack.
- The function checks if it is the player's turn and if the target is valid before allowing the attack. It updates the battle data and records the attack details in the LastAttack table.
- The active player is updated if the move and attack actions are consumed or if the player ends their turn.
Note: The entity represents the attacker, while the target represents the entity being attacked.