# List of functions

##

### createDeck()

Used at the start of each round / game to clean the deck, then to create the deck with all the cards. The cards come from the Data Table located in `content/Blackjack/BP/DT/DT_cards`&#x20;

Will populate the var "Deck" based on structure S\_card

### shuffleDeck()

Used at the start of each round / game to shuffle the previously created deck.&#x20;

Use the var "deck"

## removeCardsFromDeck()

Used every time a player (You or Dealer) draw a card to remove the same card from the deck.

Use the var "deck".

### drawCard()

Has two arguments:

* Number, to know how many cards must be drawn
* faceIsUp, to know if the card must be displayed

Take a card from "deck", then, based on faceIsUp, actually create a new struct based on S\_cardInhand to return an array of card that will be passed to addDrawnCards()

### CalculatePoints()

Has two arguments:

* cards, to evaluate the value of those cards
* Player, to give that value to "You" or "Player".

There are two things:

* It does not take into account the value of a non visible card
* Aces can be worth 11 or 1 depending of the score. So we need to count how many aces there are. If value > 21, then, for each aces, remove 10 points while value > 21.

### initYouMoney()

Has one argument:

* youMoney, to give the player "You" a certain amount of $ to play with.

Set up the var Y\_money at the start of the game.

### placeBet()

Has one argument:

* bet, to specify how much you bet before drawing the cards.

Use the "DisableConfirmButton\_UI" from W\_main to prevent the PC player from playing without betting.

This function is only triggered through the widget W\_selectBet (in W\_main, WidgetSwitcher index 0) and its buttons, at the start of the round.&#x20;

Basically, add X money to the var "Y\_currentBet" depending on the clicked button. If you have not enough money, you "all in".&#x20;

Then it calls Event Dispatcher "onBetChanged" to tell W\_youData to update the UI with the bet.&#x20;

### updatePlayerMoney()

Has one argument:

* youMoney, the new amount of money you'll have.

This function update the Y\_money var, then call the Event Dispatcher onMoneyChanged to tell the UI to visually update the money.&#x20;

### clearDrawnCards()

Used at the start of a game / round.

Clear the Y\_drawnCards and the D\_drawnCards arrays so the dealer and You (as a player) have no card in hand.&#x20;

### addDrawnCards()

Has two arguments:

* drawnCards, the cards that have been drawn with the drawCard function
* Player, to specify which array (D\_drawnCards or Y\_drawnCard) should be populated.

Used always right after drawCard ().

### evaluateHand()

Has one argument:

* player, to specify which hand should be evaluated.

Used at the end of a draw / phase to check if a player can keep up drawing or if the round should stop to go to the next phase (mainly the dealer phase).

Has three outputs:

* playing, leads to do nothing (can keep drawing)
* stop\_mightWin, lead to stopping the phase and letting the dealer reveal/draw his card
* stop\_bust, lead to stop the round because the player has lost right away.

### resetBet()

Used at the init of a round / game (phase 2).

Reset the Y\_currentBet var to 0, then call the Event Dispatcher onBetChanged to update the UI, and then call DisableConfirmButton\_UI from W\_main to prevent You from running a round without betting.&#x20;

### resetDeck()

Used at the init of a round / game in createDeck().

Reset the var "Deck" array.

### dismissPopup()

Used at the init of a round / game.

Call the removePopup\_UI from W\_main to remove the popup that spawns at the end of a round / game to inform the player (You) he has won / lost the game or the round.

### revealDealerCards()

Used during the dealer phase.

The dealer has always a card you cannot see during the player phase, when he draws cards. The non visible card is only revealed when the player (You) stands or reaches 21.

So this function basically parses the D\_drawnCard to enable the var isFaceUp for all the cards. Right after, the AC calls the W\_main to repopulate the UI based on the recently modified D\_drawnCards, and now all the cards are revealed.&#x20;

### checkEndGamesStatus()

Used at the end of a round if the player (You) did not bust.

Check the score between the players (you and Dealer) to declare if You Blackjack, Win, Lose, or if it's push and no one wins.&#x20;

### gainCalculation()

Has one argument:

* endGameStatus

Right after the bet phase, the bet value is removed from the player's money (Y\_money).

What happens according to the endGameStatus:

* If You wins, he gets his bet back + the value of his bet.
* If blackjack (21 with 2 cards), he get his bet back + 1.5x the value of his bet
* If the loses, nothing happens since the bet has already been substracted from the money.
* If push, then he gets back his bet and nothing else.&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://easy-blackjack.gitbook.io/easy_blackjack-docs/ac_blackjack-actor-component/list-of-functions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
