Most of the large steps are taken. Time to dive into two specific Chance and Community Chest cards where the charged amount needs to be calculated. We have ignored these up to now, but today we will make sure these payments can also be made properly.
It concerns these two cards:
You are assessed for street repair
- € 4,000 per house
- € 11,000 per hotel
Make general repairs on all your property
- € 2,500 per house
- € 10,000 per hotel
The most logical solution is to add specific fields on the Rule object for amounts per house and per hotel. In the flow in which we execute the Rule, we must count the number of houses and hotels a player has when they draw a card that has amounts in these fields. After that we must mutiply these amounts by the numbers of houses and hotels.
First let's make the custom fields
To add these fields we'll choose to use Schema Builder.

Next we need to add then to the Lightning Page Manually.

And let's populate the fields right away on these two rules.

The flow
The flow we’re going to modify is SCR – Execute Rule, which we built in part 5. Under the Pay Money path, we’ll add a Decision element to check whether the Amount per house and Amount per hotel fields of the corresponding Rule contain values.

Counting the Player's houses and hotels can be considered as a standalone process, so we'll do this in a subflow that we can embed here.
The subflow to count houses and hotels
This will be an autolaunched flow and the only input we need is the Id of the Player for whom we must count. Because it is just as easy to use the whole record as an input variable and this offers us more flexibility to expand the flow's functionality if we want to, we shall use the inputPlayer variable once again.
We need output variables too: two numbers with 0 decimals.

- The first step is to get all the Assets owned by the inputPlaye.
- Next we'll evaluate each Asset in a Loop
- Then we'll use a Decision to determine if the Asset has a hotel, 1 to 4 houses or no buildings at all.
- When there is a hotel on the Asset, we add 1 to the
outputNumberOfHotelsvariable - If there are houses on the Asset, then we'll add that number to our
outputNumberOfHousesvariable
We'll configure these elements of the flow as follows:


Adding 1 to outputNumberOfHotels is straightforward, but to add the correct number of houses, we need a formula that converts the value of the Buildings__c field into a number. The values are “1 house”, “2 houses”, “3 houses”, and “4 houses”. The formula below isolates the first character and converts it from text (string) to a number. Since it's a picklist value, you need to convert it to text before you can use a text function like LEFT on it.
Here we work from the inside out as it were.
- The innermost formula transforms the picklist value to text (string)
- The second formula shortens this text to only the first character
- The outermost formula turns that number that at this point is still considered as a string into an actual number value. (a number without any decimals is also called an integer)

And this formula is what we'll use to add the correct number of houses to outputNumberOfHouses .

We'll save this flow as ALF – Count Player’s Houses and Hotels and activate it immediately.
Back to the main flow
Did you still have the Flow Builder tab with SCR – Execute Rule open? If so, first click Save and refresh the tab using the F5 key. Only after refreshing will the flow ‘know’ about the existence of the new subflow.
We'll insert the subflow under the Calculated Amount branch that we just made.

We'll use an Assigment element to update the Player's Cash Balance becaus ethis let's us use the Subtract operator.
The formula that calculates the amounts that needs to be paid, looks as follows.
{!Count_Player_s_Houses_and_Hotels.outputNumberOfHotels} * {!inputRule.Amount_per_hotel__c} +
{!Count_Player_s_Houses_and_Hotels.outputNumberOfHouses} * {!inputRule.Amount_per_house__c}
The Assignment to subtract the amount from the active player's cash balance and add it to the cash balance of receiving player (the bank) is nearly the same as the one that we already have for fixed amounts. The difference is that we'll use the formula shown above for the amount.

Next we rejoin the existing route of the flow to use the same Update element and screen. In the screen we need to add a bit of logic to show the right amount.

In the screen, we copy the contents of the Display Text element and paste it into a second Display Text. We adjust the field for the amount. For both Display Text elements, we set conditional visibility by referencing the outcomes of the decision.

Nou, dat viel best wel mee, toch? Volgende keer gaan we werken aan de mogelijkheid om huizen te kopen. In juli en augustus even een onderbreking dus dat volgende deel zal verschijnen op 11 september.