There are a few ways to get sent to jail in Monopoly, and a few ways to get out again.
- In episode 4, you read about how players are sent to jail if they roll doubles three times in a row.
- In episode 5, we set it up so that any player who lands on the “Go to Jail” space is immediately moved there. This flow uses a Rule, which we linked to that board space back in episode 3.
- The third possibility is a Chance or Community Chest card that sends you directly to jail. We added this in episode 6.
So ending up in jail can already be done in all the ways this can happen in the real game, but how can you get out?
That can also be achieved in three ways:
- Rolling a double
- Paying € 5,000
- Use a Get out of jail free card
Rolling a double
You may try this up to 3 times. If you fail to roll a double on the third attempt, you must pay € 5,000 and move the number of steps you rolled. Therefore it is important to keep track of how long a player has been in jail.
To support this, we’re introducing a new field called Number of turns in jail on the Player object. It’s a numeric field with one digit before and zero digits after the decimal point, and a default value of 0. No profiles will have access to it, as we’ll manage that through Permission Sets. The exact placement on the Page Layout and Lightning Page will be decided later.
Paying € 5,000
While the option to roll doubles is only available if you haven’t already tried and failed three times, and you must actually possess a Get Out of Jail Free card to use one, the option to simply pay €5,000 is always available. No special setup is required for this.
After we made our preparations for the Chance card, we will build a flow to handle this scenario.
Get out of jail free
This card appears once in both decks of cards. Different from other rules in the Chance and Community Chest decks, we have not thought of an 'Action' for these yet.
This means that when you draw either of these cards, nothing will happen. But what should happen is that you get to hold on to this card and that it is not available for other users to draw from the deck anymore.
To resolve this, we should take care of the following:
- It should be possible to link a Rule to a Player
- The flow must populate this relationship when a player draws this particular card
- As long as the Rule is in a player's hard, it should not be available for others to draw from the deck
- After the Player has used the card it should be placed back in the deck
The first step is to create a lookup relationship to the Player object on the Rule Object. This enables us to exclude this card from the ones that other players can draw and allows a player to hold on to it and later use it to leave jail.
Here too, it's important to ensure that other components aren’t affected by what happens with the Rule in this particular instance. In episode 9, we linked various objects to an overarching Game to handle this, but we haven’t done that yet for Rules.
Step 1 is to add a Game lookup on the Rule object.
Step 2 is to add a Player lookup with a lookup filter that defines that Player and Rule must belong to the same game.

In this screenshot, you can see how we also define the name of the Related List on the Player object where the Rules can be stored. We’re calling it Rules in Hand. This refers specifically to the API name of the Child Relationship, which cannot contain spaces. In Step 7, you can set the label of the Related List, and spaces are allowed there.
For both new fields, I’m once again not granting access via profiles—instead, we’ll add them to our Permission Sets. The exact placement of the fields on the Lightning Page, along with any conditional visibility settings, will be handled later in a sort of final cleanup round.
While we’re already in the Object Manager for the Rule object, we’ll go ahead and add a fifth picklist value to the Action field: Save for Later.
Don’t forget to also update the Action field to Save for Later on the Rules for Get Out of Jail Free.

Save for later
First, we’ll add handling for the new Save for Later scenario in the SCR – Execute Rule flow. To do this, we’ll add a fifth outcome to the Rule Action Decision.

There, we populate the In Player’s Hand relationship with the ID of the active player, and we save this update to the inputRule using an Update Records element.
We'll save the flow as a new version with a note inthe Description that explains what we changed compared to the previous version. We'll also activate this version right away.

In the SCR – Check for and Execute Position Rule flow, we need to update the first Get Records element. A third condition should be added to ensure that the Rule is not currently in a player’s hand. However, this Get fetches a Position Rule, and In Player’s Hand is a field on Position, so we can only filter on it if we create a formula field on the Position Rule object.
The formula field is_in_a_Player_s_hand__c on the Position Rule object returns true if the lookup to the parent Position is empty.

And this is the modified Get records element.

The prisoner's turn
Since a prisoner’s turn works largely the same as a regular turn, we’re adding all the necessary elements for handling a prisoner’s turn directly into the existing player turn flow: the SCR – Roll and Move flow.
Right at the beginning, we need a Decision element, since players starting their turn in jail are shown a completely different initial screen. Additionally, we need to determine whether the player has a Get Out of Jail Free card before displaying the first screen.


At the start of a turn that begins in jail, the player is always given a choice: attempt to roll doubles, or decide in advance to pay €5,000. If the player has a Get Out of Jail Free card, a third option is also available.
On this screen, we therefore include two versions of the choice list: one that includes the option to use the Get Out of Jail Free card, and one without it. Each version has its own conditional visibility settings. For every new screen we’re adding now, I’ve copied and modified the existing first screen from this flow to ensure consistent text formatting across all screens throughout the flow.

After this we have the next 3 elements in common with players playing a regular 'non-jail' turn. After that we branch off again using a Decision immediately followed by another Decision element for the further handling based on the choice the player made.

In the conditions for the Roll a Double decision outcome, we also need to determine which set of radio buttons the player saw and interacted with. That’s why we again check whether the player had a Get Out of Jail Free card, and based on that, we refer to their selection from either the first or the second list of options.

Get out of jail free
When the player chooses to use their Get out of jail free card, the following needs to happen.
- The player returns the card to the apropriate discard pile
- The player rolls the dice
- The player moves to the right Position
Rolling the dice and determining to which Position to ga has already happened at this point in the flow elements that we shar with a regular turn.
Half of the discarding of the Get out of jail free card has actually already happened.
When the Player drew this card, the index of all related Position Rules was already set to 999, making it unavailable for anyone else to draw. It is also shuffled when the last card in the deck is drawn. So for this part we do not need to do anything now.
However, we do need to clear the relationship to the Player on the Rule (In_Player_s_Hand__c). This ensures that the player can’t reuse the same card incorrectly, and it allows other players to draw the card again after the discard pile has been reshuffled.
For this we first get this card.

In the Remove from Player’s Hand assignment, we clear the In_Player_s_Hand__c field on this record, and the Update Rule element saves this change to the Rule in the database.
Before we continue the flow's regular path from here, we must show the player a screen where they can see where they are going. For this we'll use the same screen used for a non-double roll in a regular turn.

After this, just like with the other outcomes where the player leaves jail—and just like in a regular turn—the player’s new Position is assigned and updated using the same Update Records element that was already present in the flow.

Rolling a double
If the player chose to try and roll a double, we need to follow different routes depending on whether their attempt was succesful,
If the roll is successful, the player is allowed to move forward by the number of spaces equal to the value of the roll. We then display a screen and proceed to the Assign Player’s New Position – double element, which is also used in the earlier part of the flow for handling a double roll.

After this, the player must roll again. The fact that in this situation we can continue along the normal flow path is the main reason we’re adding all these elements to the existing flow rather than creating a separate new one. After all, the player is entitled to roll again following a double, and for that roll, the process already established in SCR – Roll and Move applies.
By clicking the text at the end of the connector, the element where this connector leads to is highlighted.

Let's also copy counting the number of double rolls t before this connector.

If the player fails to roll doubles, they must remain in jail—unless this is already their third turn there. We determine this using the Number of turns in jail field on the Player record. The first time, this field has a value of 0; the second time, 1; and the third time, 2. If the value is less than 2, the player must stay in jail.

After this, we need to increment the Number of turns in jail by 1 to ensure the correct decision can be made on the next turn. Then, we display a screen to the player and finish by starting the next player’s turn.

We do still need to reset the Number of turns in jail to 0 when the player leaves jail. To do that, we’ll add an extra field assignment to those assignments.

When the player chose to try and roll a double a third time and did not succeed, then they must pay € 5,000 and mve the number of steps they rolled. For this we'll connect immediately to the Pay € 5,000 branch of the decision and use the same Assignment element to subtracht € 5,000 from the Player’s Cash Balance and also that same screen.


This path also leads us to the assignment that updates the Player’s record with the new Position—just like when a Get Out of Jail Free card is used.

We've come a long way making our Monopoly app. In the next episodes we shall work on the following aspects of the game.
- Chance cards with calculated amounts
- Huizen en hotels bouwen
- Trading with other players
- Out of cash, now what?
- Seeing what other players are doing
Thanks for you time. Do you have any questions or suggestions, leave them in the comments.