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.
"To sell or not to sell" That is the question myself (and probably most users using the tool) have each day. You need to take a decision: sell now and lose opportunity if the price increases in the next days, or wait for that better price that may not come.
To be precise, the question can be better asked as "What is the probability that I'll have a same or higher price at least once in the following days/periods?". And that probability can be calculated with the chart information and today's price.
This pull request adds this indicator, with a 'yes/probablyyes/no/probablyno' label as well as the probability used to take the decision (in case the user want to be safe and sell even with a probability of 60%).
Note: I have enabled github pages over my repository in order to easily review the changes live. I'll disable it if the pull request is merged: https://trianguloy.github.io/ac-nh-turnip-prices/
Probability
Calculating the probability is rather easy. The code+comments should be almost self-explanatory, but here I'll explain it with examples.
First we need to have a base price to compare, and days to check. Althoug the code is able to use any price and any days, the user will probably only be interestes in the result with today's price and the next days. The other input is the list of possible patterns and its ranges, to be precise the table the page shows (except for the first row). Now it is just a matter of calculating the probabilty, however as it is usual on these cases, in order to calculate the probability of 'at least one same-or-better price' (which will require calculate the probability of only one, plus only two, plus only three, etc) it is easier and more precise to calculate the probability of all worse prices, and then take the opposite.
Some examples of corner cases are:
Special cases
Pull request details
The pull request consists only of added code, nothing existing is modified. To be precise: the function that calculates the probability, the html to display this information, and the required strings for localization. I tried to follow the same code style, however I found some multiple styles so I just followed the most common one. I'm open to suggestions and changes (and possibly fixes) before merging.