From 0a08ea3386dfa4b4d7aa6b9d1943d5cc7441d674 Mon Sep 17 00:00:00 2001 From: nayfaan Date: Mon, 18 Sep 2023 20:34:12 -0700 Subject: [PATCH] v.7.1. - Added support for range --- index.html | 27 ++++++++++++++++++++------- web/static/index.css | 4 ++++ web/static/index.js | 39 ++++++++++++++++++++++++++++++++++++--- web/static/puni-color.js | 27 +++++++++++++++++++++++++-- web/static/zipPerm.js | 24 +++++++++++++++++++++--- 5 files changed, 106 insertions(+), 15 deletions(-) diff --git a/index.html b/index.html index ca02674..f9dffeb 100644 --- a/index.html +++ b/index.html @@ -53,8 +53,7 @@ Spirit Bottle with only (Jewel) added but not (Elixir), etc.
For detailed information on what you can get (especially high quality rare items like dragon's eye) from - different values of punis stats, translate this + different values of punis stats, translate this Japanese site with Google Translate (or ChatGPT if you like). @@ -78,20 +77,33 @@ + - + + + + + + + + +
Const. Luster Mood = Puni
Max = Puni +
Min = Puni +
-
Stats need to be ordered? +
Stats range?
+ +
Stats need to be ordered? (?) 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? @@ -134,9 +146,10 @@
References:
diff --git a/web/static/index.css b/web/static/index.css index a3b876d..0cd1191 100644 --- a/web/static/index.css +++ b/web/static/index.css @@ -12,6 +12,10 @@ width: 2.5em; } +.stat_range { + display: none; +} + .vertical-center { margin: 0; position: absolute; diff --git a/web/static/index.js b/web/static/index.js index e63f18d..eda2618 100644 --- a/web/static/index.js +++ b/web/static/index.js @@ -1,4 +1,6 @@ var submit_button = $("#submit"), + range_checkbox = $("#range"), + ordered_checkbox = $("#ordered"), results_table = $("#results-table"); function start_zip_worker() { @@ -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(); @@ -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); diff --git a/web/static/puni-color.js b/web/static/puni-color.js index 2cf8792..3ef0f97 100644 --- a/web/static/puni-color.js +++ b/web/static/puni-color.js @@ -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 = { @@ -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; @@ -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 }); }); diff --git a/web/static/zipPerm.js b/web/static/zipPerm.js index 6c3240c..5cde314 100644 --- a/web/static/zipPerm.js +++ b/web/static/zipPerm.js @@ -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 = []; @@ -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);