Skip to content

Commit

Permalink
better parse error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
MouseyPounds committed Mar 31, 2024
1 parent 1e64f94 commit 02d6d9d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
This app simulates the random number generator used in [Stardew Valley](http://stardewvalley.net/) and makes "predictions" about the game either from the Game ID or by reading the save file. Currently, the information predicted includes special mine levels (e.g. mushroom floor & infestations), random items sold by some vendors, results from cracking geodes, the train schedule, and more.
A useful companion tool is [BlaDe's Map Predictor](https://www.nexusmods.com/stardewvalley/mods/6614) which handles things such as artifact digging, giant crops, and mine ladders.

All changed & added content from version 1.6 should be supported; 1.6-specific features will only appear in the results if either the save is detected to be from that version or the app is launched with a URL id parameter. Please report any bugs, suggestions, or other feedback to [the topic in the Stardew official forums](https://forums.stardewvalley.net/threads/web-apps-stardew-checkup-predictor-and-fair-helper.28393/).
All changed & added content from version 1.6 should be supported; 1.6-specific features will only appear in the results if either the save is detected to be from that version or the app is launched with a URL id parameter.

The app is written in Javascript and uses [jQuery](https://jquery.com/), [JS xxHash](https://github.com/pierrec/js-xxhash) and [BigInteger.js](https://github.com/peterolson/BigInteger.js); it is hosted on GitHub Pages at https://mouseypounds.github.io/stardew-predictor/ and the source code repository is https://github.com/MouseyPounds/stardew-predictor. It is released under the MIT license.

Please report any bugs, suggestions, or other feedback to [the topic in the Stardew official forums](https://forums.stardewvalley.net/threads/web-apps-stardew-checkup-predictor-and-fair-helper.28393/) or to @mouseypounds on Discord.

## Changelog

* 30 Mar 2024 - v5.0.3 - Finally added slightly more friendly error-handling
* 28 Mar 2024 - v5.0.2 - Fixed precision loss bug in enchantment code
* 27 Mar 2024 - v5.0.1 - Update cart item lists for 1.6.3 patch
* 26 Mar 2024 - v5.0.0 - Support for Stardew Valley 1.6
Expand Down
6 changes: 4 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="./jquery-3.2.1.min.js"><\/script>')</script>
<script src="./cs-random.js"></script>
<script src="./stardew-predictor.js?v=5.0.2"></script>
<script src="./stardew-predictor.js?v=5.0.3"></script>
<script src="./BigInteger.min.js"></script>
<script src="./xxhash.min.js"></script>

Expand All @@ -43,7 +43,7 @@ <h2 id="sec_about">About</h2>
<p>Most changed &amp; added content from version 1.6 is supported. <span class="strong note">While the app tries to detect the version in the save and use
prediction logic specific to that version, it will spoil some new features regardless. You have been warned.</span> </p>
<p>The app is written in Javascript and uses <a href="https://jquery.com/">jQuery</a>, <a href="https://github.com/peterolson/BigInteger.js">BigInteger.js</a>, <a href="https://github.com/pierrec/js-xxhash">JS xxHash</a>, and <a href="https://github.com/substack/semver-compare">semver-compare</a>; it is hosted on GitHub Pages at <a href="https://mouseypounds.github.io/stardew-predictor/">https://mouseypounds.github.io/stardew-predictor/</a> and the source code repository is <a href="https://github.com/MouseyPounds/stardew-predictor">https://github.com/MouseyPounds/stardew-predictor</a>.
Please report any bugs, suggestions, or other feedback to <a href="https://forums.stardewvalley.net/threads/web-apps-stardew-checkup-predictor-and-fair-helper.28393/">the topic in the Stardew official forums.</a></p>
Please report any bugs, suggestions, or other feedback to <a href="https://forums.stardewvalley.net/threads/web-apps-stardew-checkup-predictor-and-fair-helper.28393/">the topic in the Stardew official forums</a> or to <span class="code">@mouseypounds</span> on Discord.</p>
</div>

<div id="input-container" class="panel">
Expand Down Expand Up @@ -101,6 +101,7 @@ <h3 id="advanced_usage">Advanced Usage</h3>
<div id="progress-container" class="panel">
<h2 id="sec_working">Working...</h2>
<progress id="progress" value="0" max="100"></progress>
<div id="parse-error"></div>
</div>

<div id="output-container" class="panel">
Expand Down Expand Up @@ -631,6 +632,7 @@ <h3>Feast of the Winter Star Gift Assignments</h3>
<noscript><span class="error">Javascript appears to be unsupported by or disabled in your browser. Stardew Predictor will not work without it.</span></noscript>
<h2 id="sec_changelog">Changelog</h2>
<ul>
<li>30 Mar 2024 - v5.0.3 - Finally added slightly more friendly error-handling</li>
<li>28 Mar 2024 - v5.0.2 - Fixed precision loss bug in enchantment code</li>
<li>27 Mar 2024 - v5.0.1 - Update cart item lists for 1.6.3 patch</li>
<li>26 Mar 2024 - v5.0.0 - Support for Stardew Valley 1.6</li>
Expand Down
1 change: 1 addition & 0 deletions stardew-predictor.css
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ h3 {
.code {
font-family: monospace;
font-weight: bold;
white-space: pre;
}
#footer {
text-align: center;
Expand Down
16 changes: 11 additions & 5 deletions stardew-predictor.js
Original file line number Diff line number Diff line change
Expand Up @@ -8987,9 +8987,16 @@ Object.keys(test).forEach(function(key, index) { if (test[key].s > 0 && test[key
}

function updateOutput(xmlDoc) {
document.getElementById('out-summary').innerHTML = parseSummary(xmlDoc);
$("input[name='tabset']").each(function() { updateTab(this.id.split('-')[1], false); });
$('#output-container').show();
try {
document.getElementById('out-summary').innerHTML = parseSummary(xmlDoc);
$("input[name='tabset']").each(function() { updateTab(this.id.split('-')[1], false); });
document.getElementById('progress').value = 100;
$('#progress-container').hide();
$('#output-container').show();
} catch(error) {
var message = "<h3>Save Parse Error</h3><p>The app was unable to process the save file. This is most likely a bug with the app, so please let the dev know about it. Details below.</p>";
$('#parse-error').html(message + '<p class="code">' + error + '<br/>' + error.stack + '</p>');
}
return;
}

Expand All @@ -9016,9 +9023,8 @@ Object.keys(test).forEach(function(key, index) { if (test[key].s > 0 && test[key
};
reader.onload = function (e) {
var xmlDoc = $.parseXML(e.target.result);
prog.value = 100;
prog.value = 90;
updateOutput(xmlDoc);
$('#progress-container').hide();
};
reader.readAsText(file);
}
Expand Down

0 comments on commit 02d6d9d

Please sign in to comment.