mikebryant / ac-nh-turnip-prices

Price calculator/predictor for Turnip prices
https://turnipprophet.io
Apache License 2.0
1.45k stars 245 forks source link

Input values overridden by values from other tab #199

Open buhh1 opened 4 years ago

buhh1 commented 4 years ago

Somehow values entered in one tab overwrite values in another tab. Not sure but i think this also affects the calculation of the predictions, because in one tab the values seem to be ignored and the result of another tab is shown.

stephannv commented 4 years ago

I think this is a intended behavior, because values is stored on localStorage, so if you change values on input in specific tab, you are changing localStorage values for all tabs too. You can open a private tab (you will lost values when you close it) or open another browser.

theRTC204 commented 4 years ago

It's the result of using Local Storage, yes. The app is not meant to be used to track prices on multiple islands, so we aren't likely to address this.

You can open the page in a private browsing session as previously mentioned, or you can use the permalink feature to create a session that is not persistent - Local Storage is disabled while a query string is present in the URL.

buhh1 commented 4 years ago

Thank you for the tip with the permaLink!

Maybe i could create a link for our group from our google-document.

theRTC204 commented 4 years ago

@buhh1 if you're using a shared Google Sheet spreadsheet, you can probably adapt this algorithm to produce what you're looking for.

=HYPERLINK(CONCATENATE("https://turnipprophet.io?prices=", ENCODEURL(JOIN(".", B5:N5)), IF (ISBLANK(O4), "", CONCATENATE("&pattern=", LOWER(SUBSTITUTE(O4, " ", "-"))))), "Turnip Prophet")

It's expecting a row of values, the first cell being the buy price, followed by 12 cells of sell prices, and ending with a cell for the previous week's pattern (note the previous week pattern references to row above, as it's meant to get last week's value.

Edit: Updated Sheets script to account for hyphens in pattern names.

buhh1 commented 4 years ago

@theRTC204 Thank you again. Added a the link to my spreadsheet and it works fine (after some adaptions to my layout). Have fun playing ;)

Generic42 commented 4 years ago

For the pattern on the URL I cannot get either &pattern=smallspike or &pattern=small%20spike to work, what's the proper format there?

theRTC204 commented 4 years ago

@Generic42 keys are hyphonated, so in this case small-spike. I would recommend that you use the "copy permalink" button to grab examples of the URL structure.

Edit: I just realized my example URL generator for the spreadsheet doesn't properly account for the hypon in small-spike and large-spike. 🤔

Edit 2: Script in previous post has been updated to account for hyphens.

Generic42 commented 4 years ago

I tried that, the perma-link uses &pattern=0,1,2,3 not the phrasing. This will get me going, thanks.

Generic42 commented 4 years ago

You can account for the hyphen with - (SUBSTITUTE(O3," ","-")

=HYPERLINK(CONCATENATE("https://turnipprophet.io?prices=", ENCODEURL(JOIN(".", B4:N4)), IF (ISBLANK(O3), "", CONCATENATE("&pattern=", LOWER(SUBSTITUTE(O3," ","-")))), "Turnip Prophet")

mikebryant commented 4 years ago

@Generic42 Yeah, the permalink generates using the low-level pattern number, but we also support the names small-spike, large-spike, fluctuating and decreasing

buhh1 commented 4 years ago

here is what i came up with for google spreadsheet: =HYPERLINK(CONCATENATE("https://turnipprophet.io?prices="; ENCODEURL(JOIN("."; C3; D3:D14)); IF (ISBLANK(VLOOKUP(C15;B29:C33;2;false)); ""; CONCATENATE("&pattern="; VLOOKUP(C15;B29:C33;2;false)))); "Turnip Prophet")

i made a lookup table of the pattern to get the number and used the number for the link

lchoward commented 4 years ago

This is awesome! @theRTC204 thank you very much, sir