5. Calculate operations and purchase costs
Calculate a batch purchase cost before spending.
Goal: Calculate a batch purchase cost before spending.
Before you start: The Normal wallet and error handling.
The idea you will use
Cost sums the unit prices; Current Owned shifts the starting price. Calculating does not spend resources.
Predict before running
With starting price 100 and increment 50, do three units cost 300 or 450?
Build and check
In this exercise, you will check individual calculations and a purchase with increasing prices. Use the BP_MiNumero you created earlier; you do not need additional assets or sample files.
- Open its EventGraph and keep the flow calculate → Is Success → Branch → show value or error.
- Search for an operation from the table in the graph menu. Create its inputs with Make Scientific Number; leave Exponent at 0 for these values.
- Connect the result to the checking flow. Compile, press Play, and compare with the table. Stop Play before changing the operation.
- If the node returns a bool and Out Error, check the bool with Branch and use Out Error on the failure branch. Connect white pins when the node has execution pins.
| Operation | Inputs | Expected standalone result |
|---|---|---|
| Subtract | 3000, 2000 | 1000 |
| Multiply | 2000, 3000 | 6000000 |
| Divide | 3000, 3 | 1000 |
| Power | Base 2, Exponent 10 | 1024 |
| Square Root | 144 | 12 |
| Apply Production | Current Value 1000, Production Per Second 25, Delta Seconds 4 | 1100 |
| Arithmetic Purchase Cost | Num Items 3, Price Start 100, Price Add 50, Current Owned 0 | 450 |
| Max Affordable Arithmetic | Resources Available 1000, Price Start 100, Price Add 50, Current Owned 0 | 5 |
The cost of three units is 100 + 150 + 200 = 450. With 1000, you can buy 5: they cost 1000 total; six would cost 1350.
When finished: you should be able to change an input, repeat the calculation, and explain its result before applying a format.
Check your reasoning
See the explanation
450: 100 + 150 + 200. With Current Owned = 2, the next three cost 200 + 250 + 300 = 750.
Your turn: Set Current Owned to 2 and predict the cost of three units before running.
Ready to continue when: you can separate calculation, affordability and the actual deduction.
Progress is saved only in this browser and carries over when you switch language.