Skip to content

Commit

Permalink
v.7.1. - Added support for range
Browse files Browse the repository at this point in the history
  • Loading branch information
nayfaan committed Sep 19, 2023
1 parent dfff237 commit 0a08ea3
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 15 deletions.
27 changes: 20 additions & 7 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@
Spirit Bottle with only (Jewel) added but not (Elixir), etc.
<hr>
For detailed information on what you can get (especially high quality rare items like dragon's eye) from
different values of punis stats, translate <a
href="https://wikiwiki.jp/ryza/%E6%94%BB%E7%95%A5%E3%83%A1%E3%83%A2/%E3%81%B7%E3%81%AB%E3%81%A8%E3%81%84%E3%81%A3%E3%81%97%E3%82%87">this
different values of punis stats, translate <a href="https://wikiwiki.jp/ryza/攻略メモ/ぷにといっしょ">this
Japanese site</a> with <a
href="https://wikiwiki-jp.translate.goog/ryza/攻略メモ/ぷにといっしょ?_x_tr_sl=ja&_x_tr_tl=en-US&_x_tr_pto=wapp">Google
Translate</a> (or ChatGPT if you like).
Expand All @@ -78,20 +77,33 @@

<table id="puni-stats-table">
<tr>
<td class="stat_range stat_cell"></td>
<td><u>Const.</u></td>
<td><u>Luster</u></td>
<td><u>Mood</u></td>
<td rowspan="2"> = <img id="puni-img" src="" style="height: 100%;"> <strong><span
id="puni-color"></span></strong> Puni</td>
</tr>
<tr>
<td class="stat_range stat_cell">Max</td>
<td><input type="text" id="const_" value="100"></td>
<td><input type="text" id="luster" value="100"></td>
<td><input type="text" id="mood" value="94"></td>
<td> = <img id="puni-img" src="" style="height: 100%;"> <strong><span id="puni-color"></span></strong> Puni
</td>
</tr>
<tr class="stat_range stat_row">
<td>Min</td>
<td><input type="text" id="const_min" value="0"></td>
<td><input type="text" id="luster_min" value="0"></td>
<td><input type="text" id="mood_min" value="0"></td>
<td> = <img id="puni-img-min" src="" style="height: 100%;"> <strong><span
id="puni-color-min"></span></strong> Puni
</td>
</tr>
</table>

<div>Stats need to be ordered? <input type="checkbox" id="ordered">
<div>Stats range? <input type="checkbox" id="range"></div>

<div id="ordered_div">Stats need to be ordered? <input type="checkbox" id="ordered">
<span class="tooltip">(?)
<span class="tooltiptext">Does the order of which stat has which number matter? Or is it ok that as long
as all three numbers appear in whichever stat?</span>
Expand Down Expand Up @@ -134,9 +146,10 @@
<div id="references">
<b><u>References:</u></b>
<ul>
<li><a href="https://barrelwisdom.com/ryza/puni-raising">https://barrelwisdom.com/ryza/puni-raising</a></li>
<li><a href="https://barrelwisdom.com/ryza/puni-raising">Barrel Wisdom</a></li>
<li><a
href="https://docs.google.com/spreadsheets/d/197q5mN66pSpWmE2NklW4kToYs2cyD4lq8kPNrfkP72Y/edit?usp=sharing">https://docs.google.com/spreadsheets/d/197q5mN66pSpWmE2NklW4kToYs2cyD4lq8kPNrfkP72Y/edit?usp=sharing</a>
href="https://docs.google.com/spreadsheets/d/197q5mN66pSpWmE2NklW4kToYs2cyD4lq8kPNrfkP72Y/edit?usp=sharing">Barrel
Wisdom spreadsheet</a>
</li>
</ul>
</div>
Expand Down
4 changes: 4 additions & 0 deletions web/static/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
width: 2.5em;
}

.stat_range {
display: none;
}

.vertical-center {
margin: 0;
position: absolute;
Expand Down
39 changes: 36 additions & 3 deletions web/static/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
var submit_button = $("#submit"),
range_checkbox = $("#range"),
ordered_checkbox = $("#ordered"),
results_table = $("#results-table");

function start_zip_worker() {
Expand Down Expand Up @@ -267,20 +269,42 @@ function conclude_calc() {
}

function puni_calc(settings) {
let [puni_target, [craftable_only, best_only, ordered, show_icons]] = settings;
let [puni_target, [craftable_only, best_only, ordered, show_icons, is_range], puni_target_min] = settings;

let item_category_matrix = cross_item_category(craftable_only, best_only);

let item_category_rank_matrix = cross_item_category_rank(item_category_matrix, best_only);

start_zip_worker();
w.postMessage([puni_target, ordered, show_icons, item_category_rank_matrix]);
w.postMessage([puni_target, ordered, show_icons, item_category_rank_matrix, is_range, puni_target_min]);
}

function clear_results() {
$("#results-table").text("");
}

var ordered_checkbox_cookie

range_checkbox.on("change", function(){
if (range_checkbox.is(":checked")){
$(".stat_cell").css("display", "table-cell");
$(".stat_row").css("display", "table-row");

ordered_checkbox_cookie = ordered_checkbox.is(":checked")
ordered_checkbox.prop("disabled", true);
ordered_checkbox.prop("checked", true);

$("#ordered_div").css("display", "none");
}else{
$(".stat_range").css("display", "none");

ordered_checkbox.prop("disabled", false);
ordered_checkbox.prop("checked", ordered_checkbox_cookie);

$("#ordered_div").css("display", "inherit");
}
});

submit_button.on("click", function () {
submit_button.prop("disabled", true);
clear_results();
Expand All @@ -292,13 +316,22 @@ submit_button.on("click", function () {
let mood_val = parseInt(
$("#mood").val());

let const_val_min = parseInt(
$("#const_min").val());
let luster_val_min = parseInt(
$("#luster_min").val());
let mood_val_min = parseInt(
$("#mood_min").val());

let craftable_only = $("#craftable_only").is(":checked");
let best_only = $("#best_only").is(":checked");
let ordered = $("#ordered").is(":checked");
let show_icons = $("#show_icons").is(":checked");
let is_range = $("#range").is(":checked");

let puni_target = [const_val, luster_val, mood_val]
let settings = [puni_target, [craftable_only, best_only, ordered, show_icons]]
let puni_target_min = [const_val_min, luster_val_min, mood_val_min]
let settings = [puni_target, [craftable_only, best_only, ordered, show_icons, is_range], puni_target_min]

print_header(show_icons);
puni_calc(settings);
Expand Down
27 changes: 25 additions & 2 deletions web/static/puni-color.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,28 @@ function update_puni_colors() {
let luster_val = parseInt($("#luster").val());
let mood_val = parseInt($("#mood").val());

let const_val_min = parseInt($("#const_min").val());
let luster_val_min = parseInt($("#luster_min").val());
let mood_val_min = parseInt($("#mood_min").val());

let puni_stats = [const_val, luster_val, mood_val];
let puni_stats_min = [const_val_min, luster_val_min, mood_val_min];

let fit_color = check_color_range(puni_stats);
let color = last_color(fit_color);

let fit_color_min = check_color_range(puni_stats_min);
let color_min = last_color(fit_color_min);

if ($("#puni-color").html() != color) {
$("#puni-color").html(color);
$("#puni-img").attr("src", "web/static/images/punis/" + color.toLowerCase() + ".webp");
}

if ($("#puni-color-min").html() != color_min) {
$("#puni-color-min").html(color_min);
$("#puni-img-min").attr("src", "web/static/images/punis/" + color_min.toLowerCase() + ".webp");
}
}

const puni_colors = {
Expand All @@ -64,7 +77,16 @@ const puni_order = ["Shining", "Abyss", "Big", "Flare", "Moon", "Gold", "Silver"
(function ($) {
$.fn.inputFilter = function (callback) {
return this.on("input keydown keyup mousedown mouseup select contextmenu drop focusout", function (e) {
if (callback(this.value)) {
let callback_value = callback(this.value);

// Capping min/max values
let check_min = true;
if (parseInt($("#const_").val()) < parseInt($("#const_min").val()) || parseInt($("#luster").val()) < parseInt($("#luster_min").val()) || parseInt($("#mood").val()) < parseInt($("#mood_min").val())) {
check_min = false;
}

// Processing value
if (callback_value && check_min) {
// Accepted value
this.oldValue = this.value;
this.oldSelectionStart = this.selectionStart;
Expand Down Expand Up @@ -100,7 +122,8 @@ $(document).ready(function () {
update_puni_colors();

$("#puni-stats-table input").inputFilter(function (value) {
return /^\d*$/.test(value); // Allowing digits only
let regex_test = /^\d*$/.test(value);
return regex_test; // Allowing digits only
});
});

Expand Down
24 changes: 21 additions & 3 deletions web/static/zipPerm.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,24 @@ function sum_score(feed_list) {
return total
}

function is_between(puni_target, puni_target_min, total_score){
let between = true;
for(let i = 0; i < 3; i++){
if (!between) continue;
if (!(total_score[i] <= puni_target[i] && puni_target_min[i] <= total_score[i])) between = false;
}
return between;
}

onmessage = function (e) {
[puni_target, ordered, show_icons, item_category_rank_matrix] = e.data
[puni_target, ordered, show_icons, item_category_rank_matrix, is_range, puni_target_min] = e.data

if (!ordered) {
puni_target.sort(function (a, b) { return a - b })
}

let success_match = false;

for (let p of permutation) {
let item_permutation = [];

Expand All @@ -41,12 +52,19 @@ onmessage = function (e) {
}

for (item_combo of item_permutation) {
success_match = false;

let total_score = sum_score(item_combo),
total_score_unsorted = Array.from(total_score);

if (!ordered) total_score.sort(function (a, b) { return a - b });
if (!is_range){
if (!ordered) total_score.sort(function (a, b) { return a - b });
if (JSON.stringify(total_score) == JSON.stringify(puni_target)) success_match = true;
}else{
if (is_between(puni_target, puni_target_min, total_score)) success_match = true;
}

if (JSON.stringify(total_score) == JSON.stringify(puni_target)) postMessage([item_combo, total_score_unsorted, show_icons]);
if (success_match) postMessage([item_combo, total_score_unsorted, show_icons]);
}
}
postMessage(true);
Expand Down

0 comments on commit 0a08ea3

Please sign in to comment.