Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: resources not being used up correctly when there are missing items #757

Merged
merged 1 commit into from
Dec 26, 2024

Conversation

raoulvdberge
Copy link
Contributor

We always have to add the resulting output
resources to the internal storage, even if there
are missing resources.
If we would not do this, then, in the case of
missing resources, it would re-calculate
the same ingredient from scratch everytime and
use way too much resources.

However, if we always add resulting resources,
even if there are missing items, we must still
use up the yields from the recursive calculation.
Otherwise, if we would not use up the yields
from the recursive calculation, the crafting
calculation would incorrectly use up resources
from the internal storage for other ingredients.

What is the difference between not adding the yields in case of missing resources and using up the recursive yields when there were missing resources?
The difference lies in the fact that, when we do not add any yields, the crafting calculation would start from scratch everytime for each ingredient.
Only using up what we needed in the first place from the recursive yield ensures that any leftover yields can still be used up by other ingredients that happen to need the same resource.
So, the difference lies in not having any yields at all versus still allowing access to the leftovers.

We always have to add the resulting output
resources to the internal storage, even if there
are missing resources.
If we would not do this, then, in the case of
missing resources, it would re-calculate
the same ingredient from scratch everytime and
use way too much resources.

However, if we always add resulting resources,
even if there are missing items, we must still
use up the yields from the recursive calculation.
Otherwise, if we would not use up the yields
from the recursive calculation, the crafting
calculation would incorrectly use up resources
from the internal storage for other ingredients.

What is the difference between not adding the yields
in case of missing resources and using up the recursive
yields when there were missing resources?
The difference lies in the fact that, when we do not
add *any* yields, the crafting calculation would start
from scratch everytime for each ingredient.
Only using up what we needed in the first place from the
recursive yield ensures that any _leftover_ yields
can still be used up by other ingredients that happen
to need the same resource.
So, the difference lies in not having any yields at
all versus still allowing access to the leftovers.
@raoulvdberge raoulvdberge force-pushed the fix/NO-ISSUE/calculation-bug branch from e581dec to 7cb2e3a Compare December 26, 2024 20:59
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
74.2% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@raoulvdberge raoulvdberge merged commit 5eeea4c into develop Dec 26, 2024
6 of 7 checks passed
@raoulvdberge raoulvdberge deleted the fix/NO-ISSUE/calculation-bug branch December 26, 2024 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant