Fix: On company closure, only sell shares back after all company value calculations are done #9921
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation / Problem
When a company closes, shares are sold. To get the value of these shares, company value calculations are issued. But the way it's currently implemented, it sells the share, increasing the value of that company. This is done in a loop.
If another share value is required involving the same company which recently got its value increased, the value is now different. In essence, what I'm trying to say is that the same company can have different values while the closure command is still running, skewing subsequent share sells.
Description
Limitations
This may not be an issue at all, depending on who you ask. After all, the calculations that are in place can be seen as multiple 'Sell 25% shares' happening in a sequence, meaning that having different company values is fine. However, since the execution order of which shares are sold first is not controlled by the player, I still went with this solution.
Checklist for review
Some things are not automated, and forgotten often. This list is a reminder for the reviewers.