View source: R/napjack_helpers.R
swapper | R Documentation |
This function allows swapping of cards within a row of a card matrix. It takes a card matrix and the indices of the columns to swap. The function modifies the card matrix in-place and returns the updated matrix.
swapper(cards_matrix, swap_in_row = NULL)
cards_matrix |
A matrix of cards representing the current state of the game. |
swap_in_row |
A vector of length 2 specifying the indices of the columns to
swap within a row. If |
The function performs the following steps:
Initializes a move history attribute if it doesn't exist.
Checks if swap_in_row
is provided and has a length of 2.
Verifies that swapping within a phase has not been performed more than once.
Swaps the cards at the specified column indices within the first row of the matrix.
Updates the move history attribute.
Adds the "swapper" class to the card matrix.
The updated card matrix with the specified cards swapped within a row.
The function modifies the card matrix in-place and returns the updated matrix.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.