Skip to contents

Handles the main logic of the UNO game by processing each player's turn. This includes checking playable cards, handling drawing from the deck, applying special actions (skip, reverse, +2, wild), and checking for a winner.

Usage

play_turns_loop(hands, deck, discard, direction, turn)

Arguments

hands

A named list of tibbles representing each player's hand.

deck

A tibble of remaining cards to draw from.

discard

A tibble representing the current discard pile.

direction

An integer (1 or -1) to indicate the direction of play.

turn

The starting player number (typically 1).

Value

A list containing:

winner

Name of the winning player (e.g. "Player_3") or NULL if the game ends in a draw

hands

A named list of each player's final hand

discard

A tibble showing the final discard pile, including the full play history. Note: For wild and wild_draw4 cards, the color column reflects the color the player chose when playing the card (e.g. "green wild" means the player played a wild card and chose green).

Details

This function is not typically called directly by the user. Instead, use play_game to run a full game.