play_round: Play a Round of the Card Game

View source: R/game_mgmt.R

play_roundR Documentation

Play a Round of the Card Game

Description

This function simulates a single round of the card game, where both the computer and the player are dealt a card. The function returns the updated state of the game after the round.

Usage

play_round(
  cdeck,
  plyr_cv,
  plyr_vv,
  plyr_ic = NULL,
  comp_cv,
  comp_vv,
  comp_ic = NULL
)

Arguments

cdeck

A dataframe representing the current deck of cards.

plyr_cv

A character vector storing the cards dealt to the player so far.

plyr_vv

A numeric vector storing the values of the cards dealt to the player so far.

plyr_ic

A character vector storing the image cards dealt to the player. Default is NULL.

comp_cv

A character vector storing the cards dealt to the computer so far.

comp_vv

A numeric vector storing the values of the cards dealt to the computer so far.

comp_ic

A character vector storing the image cards dealt to the computer. Default is NULL.

Value

A list containing:

  • updated_deck: A dataframe representing the updated deck of cards after the round.

  • plyr_cv: Updated character vector of cards dealt to the player.

  • plyr_vv: Updated numeric vector of values of cards dealt to the player.

  • plyr_ic: Updated character vector of image cards dealt to the player.

  • comp_cv: Updated character vector of cards dealt to the computer.

  • comp_vv: Updated numeric vector of values of cards dealt to the computer.

  • comp_ic: Updated character vector of image cards dealt to the computer.

Examples

# Simulate a round of the game with a sample deck
deck <- mmcards::shuffle_deck()
plyr_cards <- character(0)
plyr_values <- numeric(0)
comp_cards <- character(0)
comp_values <- numeric(0)
round_result <- play_round(deck, plyr_cv = plyr_cards, plyr_vv = plyr_values,
                           comp_cv = comp_cards, comp_vv = comp_values)


bootwar documentation built on Oct. 1, 2023, 5:07 p.m.