|
@@ -54,6 +54,19 @@
|
|
|
"ehp": <?=$page->unit->effective_hp?>,
|
|
"ehp": <?=$page->unit->effective_hp?>,
|
|
|
"dmg": <?=$page->unit->effective_dmg?>
|
|
"dmg": <?=$page->unit->effective_dmg?>
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ var base_stats = {
|
|
|
|
|
+ "attack": <?=$page->unit->attack?>,
|
|
|
|
|
+ "defense": <?=$page->unit->defense?>,
|
|
|
|
|
+ "hp": <?=$page->unit->hp?>,
|
|
|
|
|
+ "speed": <?=$page->unit->speed?>,
|
|
|
|
|
+ "crit_rate": <?=$page->unit->crit_rate?>,
|
|
|
|
|
+ "crit_damage": <?=$page->unit->crit_damage?>,
|
|
|
|
|
+ "accuracy": <?=$page->unit->accuracy?>,
|
|
|
|
|
+ "resistance": <?=$page->unit->resistance?>,
|
|
|
|
|
+ "ehp": <?=$page->unit->effective_hp?>,
|
|
|
|
|
+ "dmg": <?=$page->unit->effective_dmg?>
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
<?php
|
|
<?php
|
|
|
// Get current rune sets
|
|
// Get current rune sets
|
|
@@ -129,8 +142,7 @@
|
|
|
*
|
|
*
|
|
|
* Checks for error in the combination of the parameters, and
|
|
* Checks for error in the combination of the parameters, and
|
|
|
* shows an error window if there is an invalid conbination. If
|
|
* shows an error window if there is an invalid conbination. If
|
|
|
- * not, builds the url to calculate the new rune combinations,
|
|
|
|
|
- * and presents th received response.
|
|
|
|
|
|
|
+ * not, builds the url to fetch all candidate runes.
|
|
|
*
|
|
*
|
|
|
* @return false on error, true on success.
|
|
* @return false on error, true on success.
|
|
|
*/
|
|
*/
|
|
@@ -231,6 +243,7 @@
|
|
|
if (this.readyState == 4){
|
|
if (this.readyState == 4){
|
|
|
document.getElementById('apply').removeAttribute('disabled');
|
|
document.getElementById('apply').removeAttribute('disabled');
|
|
|
document.getElementById('wait').style.display = 'none';
|
|
document.getElementById('wait').style.display = 'none';
|
|
|
|
|
+ //console.log(this.response);
|
|
|
if (this.status == 200) {
|
|
if (this.status == 200) {
|
|
|
time = ((+ new Date()) - timestamp) / 1000;
|
|
time = ((+ new Date()) - timestamp) / 1000;
|
|
|
showOptimizations(this.response, time);
|
|
showOptimizations(this.response, time);
|
|
@@ -261,11 +274,199 @@
|
|
|
timestamp = + new Date();
|
|
timestamp = + new Date();
|
|
|
|
|
|
|
|
// Make the request
|
|
// Make the request
|
|
|
- xhttp.open('POST', '/action/optimize/', true);
|
|
|
|
|
|
|
+ xhttp.open('POST', '/action/optimize_get_rune_list/', true);
|
|
|
xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
|
|
xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
|
|
|
xhttp.send(params);
|
|
xhttp.send(params);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ function valid_set(candidates){
|
|
|
|
|
+
|
|
|
|
|
+ // Debug section: Look out for current runes
|
|
|
|
|
+ if (
|
|
|
|
|
+ candidates[0].ID == '18127229790' //&&
|
|
|
|
|
+ //candidates[1].ID == '16037693193' &&
|
|
|
|
|
+ //candidates[2].ID == '18831259497' &&
|
|
|
|
|
+ //candidates[3].ID == '19634059762' &&
|
|
|
|
|
+ //candidates[4].ID == '19057400217' &&
|
|
|
|
|
+ //candidates[5].ID == '20095751566'
|
|
|
|
|
+ ){
|
|
|
|
|
+ console.log("CURRENT SET!!");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // Number of applied sets with the current candidates.
|
|
|
|
|
+ var sets = {
|
|
|
|
|
+ 'RUNE_SET_<?=RUNE_SET_ID::ENERGY?>': 0, // ENERGY
|
|
|
|
|
+ 'RUNE_SET_<?=RUNE_SET_ID::GUARD?>': 0, // GUARD
|
|
|
|
|
+ 'RUNE_SET_<?=RUNE_SET_ID::SWIFT?>': 0, // SWIFT
|
|
|
|
|
+ 'RUNE_SET_<?=RUNE_SET_ID::BLADE?>': 0, // BLADE
|
|
|
|
|
+ 'RUNE_SET_<?=RUNE_SET_ID::RAGE?>': 0, // RAGE
|
|
|
|
|
+ 'RUNE_SET_<?=RUNE_SET_ID::FOCUS?>': 0, // FOCUS
|
|
|
|
|
+ 'RUNE_SET_<?=RUNE_SET_ID::ENDURE?>': 0, // ENDURE
|
|
|
|
|
+ 'RUNE_SET_<?=RUNE_SET_ID::FATAL?>': 0, // FATAL
|
|
|
|
|
+ 'RUNE_SET_<?=RUNE_SET_ID::DESPAIR?>': 0, // DESPAIR
|
|
|
|
|
+ 'RUNE_SET_<?=RUNE_SET_ID::VAMPIRE?>': 0, // VAMPIRE
|
|
|
|
|
+ 'RUNE_SET_<?=RUNE_SET_ID::VIOLENT?>': 0, // VIOLENT
|
|
|
|
|
+ 'RUNE_SET_<?=RUNE_SET_ID::NEMESIS?>': 0, // NEMESIS
|
|
|
|
|
+ 'RUNE_SET_<?=RUNE_SET_ID::WILL?>': 0, // WILL
|
|
|
|
|
+ 'RUNE_SET_<?=RUNE_SET_ID::SHIELD?>': 0, // SHIELD
|
|
|
|
|
+ 'RUNE_SET_<?=RUNE_SET_ID::REVENGE?>': 0, // REVENGE
|
|
|
|
|
+ 'RUNE_SET_<?=RUNE_SET_ID::DESTROY?>': 0, // DESTROY
|
|
|
|
|
+ 'RUNE_SET_<?=RUNE_SET_ID::FIGHT?>': 0, // FIGHT
|
|
|
|
|
+ 'RUNE_SET_<?=RUNE_SET_ID::DETERMINATION?>': 0, // DETERMINATION
|
|
|
|
|
+ 'RUNE_SET_<?=RUNE_SET_ID::ENHANCE?>': 0, // ENHANCE
|
|
|
|
|
+ 'RUNE_SET_<?=RUNE_SET_ID::ACCURACY?>': 0, // ACCURACY
|
|
|
|
|
+ 'RUNE_SET_<?=RUNE_SET_ID::TOLERANCE?>': 0 // TOLERANCE
|
|
|
|
|
+ };
|
|
|
|
|
+ for (var i = 0; i <= 5; i ++){
|
|
|
|
|
+ sets['RUNE_SET_' + candidates[i].TYPE] ++;
|
|
|
|
|
+ }
|
|
|
|
|
+ for (var i = 0; i < sets.length; i ++){
|
|
|
|
|
+ switch (i){
|
|
|
|
|
+ case <?=RUNE_SET_ID::ENERGY?>:
|
|
|
|
|
+ case <?=RUNE_SET_ID::GUARD?>:
|
|
|
|
|
+ case <?=RUNE_SET_ID::NEMESIS?>:
|
|
|
|
|
+ case <?=RUNE_SET_ID::BLADE?>:
|
|
|
|
|
+ case <?=RUNE_SET_ID::FOCUS?>:
|
|
|
|
|
+ case <?=RUNE_SET_ID::ENDURE?>:
|
|
|
|
|
+ case <?=RUNE_SET_ID::WILL?>:
|
|
|
|
|
+ case <?=RUNE_SET_ID::SHIELD?>:
|
|
|
|
|
+ case <?=RUNE_SET_ID::REVENGE?>:
|
|
|
|
|
+ case <?=RUNE_SET_ID::DESTROY?>:
|
|
|
|
|
+ case <?=RUNE_SET_ID::FIGHT?>:
|
|
|
|
|
+ case <?=RUNE_SET_ID::DETERMINATION?>:
|
|
|
|
|
+ case <?=RUNE_SET_ID::ENHANCE?>:
|
|
|
|
|
+ case <?=RUNE_SET_ID::ACCURACY?>:
|
|
|
|
|
+ case <?=RUNE_SET_ID::TOLERANCE?>:
|
|
|
|
|
+ if (sets[i] % 2 != 0){
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+
|
|
|
|
|
+ case <?=RUNE_SET_ID::DESPAIR?>:
|
|
|
|
|
+ case <?=RUNE_SET_ID::SWIFT?>:
|
|
|
|
|
+ case <?=RUNE_SET_ID::RAGE?>:
|
|
|
|
|
+ case <?=RUNE_SET_ID::FATAL?>:
|
|
|
|
|
+ case <?=RUNE_SET_ID::VAMPIRE?>:
|
|
|
|
|
+ case <?=RUNE_SET_ID::VIOLENT?>:
|
|
|
|
|
+ if (sets[i] != 4 && sets[i] != 0){
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // Its a valid set, but does it match the requested sets?
|
|
|
|
|
+ var requested_sets = {
|
|
|
|
|
+ 'RUNE_SET_<?=RUNE_SET_ID::ENERGY?>': 0, // ENERGY
|
|
|
|
|
+ 'RUNE_SET_<?=RUNE_SET_ID::GUARD?>': 0, // GUARD
|
|
|
|
|
+ 'RUNE_SET_<?=RUNE_SET_ID::SWIFT?>': 0, // SWIFT
|
|
|
|
|
+ 'RUNE_SET_<?=RUNE_SET_ID::BLADE?>': 0, // BLADE
|
|
|
|
|
+ 'RUNE_SET_<?=RUNE_SET_ID::RAGE?>': 0, // RAGE
|
|
|
|
|
+ 'RUNE_SET_<?=RUNE_SET_ID::FOCUS?>': 0, // FOCUS
|
|
|
|
|
+ 'RUNE_SET_<?=RUNE_SET_ID::ENDURE?>': 0, // ENDURE
|
|
|
|
|
+ 'RUNE_SET_<?=RUNE_SET_ID::FATAL?>': 0, // FATAL
|
|
|
|
|
+ 'RUNE_SET_<?=RUNE_SET_ID::DESPAIR?>': 0, // DESPAIR
|
|
|
|
|
+ 'RUNE_SET_<?=RUNE_SET_ID::VAMPIRE?>': 0, // VAMPIRE
|
|
|
|
|
+ 'RUNE_SET_<?=RUNE_SET_ID::VIOLENT?>': 0, // VIOLENT
|
|
|
|
|
+ 'RUNE_SET_<?=RUNE_SET_ID::NEMESIS?>': 0, // NEMESIS
|
|
|
|
|
+ 'RUNE_SET_<?=RUNE_SET_ID::WILL?>': 0, // WILL
|
|
|
|
|
+ 'RUNE_SET_<?=RUNE_SET_ID::SHIELD?>': 0, // SHIELD
|
|
|
|
|
+ 'RUNE_SET_<?=RUNE_SET_ID::REVENGE?>': 0, // REVENGE
|
|
|
|
|
+ 'RUNE_SET_<?=RUNE_SET_ID::DESTROY?>': 0, // DESTROY
|
|
|
|
|
+ 'RUNE_SET_<?=RUNE_SET_ID::FIGHT?>': 0, // FIGHT
|
|
|
|
|
+ 'RUNE_SET_<?=RUNE_SET_ID::DETERMINATION?>': 0, // DETERMINATION
|
|
|
|
|
+ 'RUNE_SET_<?=RUNE_SET_ID::ENHANCE?>': 0, // ENHANCE
|
|
|
|
|
+ 'RUNE_SET_<?=RUNE_SET_ID::ACCURACY?>': 0, // ACCURACY
|
|
|
|
|
+ 'RUNE_SET_<?=RUNE_SET_ID::TOLERANCE?>': 0 // TOLERANCE
|
|
|
|
|
+ };
|
|
|
|
|
+ var selected_1 = document.getElementById('set_1').options[document.getElementById('set_1').selectedIndex].value;
|
|
|
|
|
+ var selected_2 = document.getElementById('set_2').options[document.getElementById('set_2').selectedIndex].value;
|
|
|
|
|
+ var selected_3 = document.getElementById('set_3').options[document.getElementById('set_3').selectedIndex].value;
|
|
|
|
|
+ var requested_values = [
|
|
|
|
|
+ document.getElementById('set_1').options[document.getElementById('set_1').selectedIndex].value,
|
|
|
|
|
+ document.getElementById('set_2').options[document.getElementById('set_2').selectedIndex].value,
|
|
|
|
|
+ document.getElementById('set_3').options[document.getElementById('set_3').selectedIndex].value
|
|
|
|
|
+ ];
|
|
|
|
|
+ for (var i = 0; i < 3; i ++){
|
|
|
|
|
+ switch (requested_values[i]){
|
|
|
|
|
+ case '<?=RUNE_SET_ID::ENERGY?>':
|
|
|
|
|
+ case '<?=RUNE_SET_ID::GUARD?>':
|
|
|
|
|
+ case '<?=RUNE_SET_ID::NEMESIS?>':
|
|
|
|
|
+ case '<?=RUNE_SET_ID::BLADE?>':
|
|
|
|
|
+ case '<?=RUNE_SET_ID::FOCUS?>':
|
|
|
|
|
+ case '<?=RUNE_SET_ID::ENDURE?>':
|
|
|
|
|
+ case '<?=RUNE_SET_ID::WILL?>':
|
|
|
|
|
+ case '<?=RUNE_SET_ID::SHIELD?>':
|
|
|
|
|
+ case '<?=RUNE_SET_ID::REVENGE?>':
|
|
|
|
|
+ case '<?=RUNE_SET_ID::DESTROY?>':
|
|
|
|
|
+ case '<?=RUNE_SET_ID::FIGHT?>':
|
|
|
|
|
+ case '<?=RUNE_SET_ID::DETERMINATION?>':
|
|
|
|
|
+ case '<?=RUNE_SET_ID::ENHANCE?>':
|
|
|
|
|
+ case '<?=RUNE_SET_ID::ACCURACY?>':
|
|
|
|
|
+ case '<?=RUNE_SET_ID::TOLERANCE?>':
|
|
|
|
|
+ requested_sets['RUNE_SET_' + requested_values[i]] += 2;
|
|
|
|
|
+ break;
|
|
|
|
|
+ case '<?=RUNE_SET_ID::DESPAIR?>':
|
|
|
|
|
+ case '<?=RUNE_SET_ID::SWIFT?>':
|
|
|
|
|
+ case '<?=RUNE_SET_ID::RAGE?>':
|
|
|
|
|
+ case '<?=RUNE_SET_ID::FATAL?>':
|
|
|
|
|
+ case '<?=RUNE_SET_ID::VAMPIRE?>':
|
|
|
|
|
+ case '<?=RUNE_SET_ID::VIOLENT?>':
|
|
|
|
|
+ requested_sets['RUNE_SET_' + i] += 4;
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //console.log("VALID SET!");
|
|
|
|
|
+ if (JSON.stringify(sets) !== JSON.stringify(requested_sets)){
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ //console.log("VALID REQUESTED SET!");
|
|
|
|
|
+
|
|
|
|
|
+ // Compare with filters
|
|
|
|
|
+ var new_stats = {
|
|
|
|
|
+ "ATK": base_stats["attack"],
|
|
|
|
|
+ "DEF": base_stats["defense"],
|
|
|
|
|
+ "HP": base_stats["hp"],
|
|
|
|
|
+ "SPD": base_stats["speed"],
|
|
|
|
|
+ "CRR": base_stats["crit_rate"],
|
|
|
|
|
+ "CRD": base_stats["crit_damage"],
|
|
|
|
|
+ "ACC": base_stats["accuracy"],
|
|
|
|
|
+ "RES": base_stats["resistance"],
|
|
|
|
|
+ "EHP": 0,
|
|
|
|
|
+ "DMG": 0
|
|
|
|
|
+ }
|
|
|
|
|
+ for (var i = 0; i <= 5; i ++){
|
|
|
|
|
+ new_stats["ATK"] += candidates[i].ATK;
|
|
|
|
|
+ new_stats["DEF"] += candidates[i].DEF;
|
|
|
|
|
+ new_stats["HP"] += candidates[i].HP;
|
|
|
|
|
+ new_stats["SPD"] += candidates[i].SPD;
|
|
|
|
|
+ new_stats["CRR"] += candidates[i].CRR;
|
|
|
|
|
+ new_stats["CRD"] += candidates[i].CRD;
|
|
|
|
|
+ new_stats["ACC"] += candidates[i].ACC;
|
|
|
|
|
+ new_stats["RES"] += candidates[i].RES;
|
|
|
|
|
+ }
|
|
|
|
|
+ new_stats["EHP"] = Math.ceil((((new_stats["DEF"] * 3.5) + 1140) * new_stats["HP"]) / 1000);
|
|
|
|
|
+ new_stats["DMG"] = Math.ceil((new_stats["ATK"] * (100 - new_stats["CRR"]) / 100) + ((new_stats["ATK"] + (new_stats["ATK"] * new_stats["CRD"] / 100)) * new_stats["CRR"] / 100));
|
|
|
|
|
+ //console.log("HP " + new_stats["HP"] + "/" + document.getElementById('min_hp').value);
|
|
|
|
|
+ if (
|
|
|
|
|
+ new_stats["ATK"] >= document.getElementById('min_attack').value &&
|
|
|
|
|
+ new_stats["DEF"] >= document.getElementById('min_defense').value &&
|
|
|
|
|
+ new_stats["HP"] >= document.getElementById('min_hp').value &&
|
|
|
|
|
+ new_stats["SPD"] >= document.getElementById('min_speed').value &&
|
|
|
|
|
+ new_stats["CRR"] >= document.getElementById('min_crit_rate').value &&
|
|
|
|
|
+ new_stats["CRD"] >= document.getElementById('min_crit_damage').value &&
|
|
|
|
|
+ new_stats["ACC"] >= document.getElementById('min_accuracy').value &&
|
|
|
|
|
+ new_stats["RES"] >= document.getElementById('min_resistance').value &&
|
|
|
|
|
+ new_stats["EHP"] >= document.getElementById('min_ehp').value &&
|
|
|
|
|
+ new_stats["DMG"] >= document.getElementById('min_dmg').value
|
|
|
|
|
+ ){
|
|
|
|
|
+ //console.log("IMPROVING SET!");
|
|
|
|
|
+ return true
|
|
|
|
|
+ }
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* Parses the received content and creates the HTML with the new
|
|
* Parses the received content and creates the HTML with the new
|
|
|
* rune options.
|
|
* rune options.
|
|
@@ -275,6 +476,175 @@
|
|
|
function showOptimizations(content, time){
|
|
function showOptimizations(content, time){
|
|
|
var container = document.getElementById('optimizations');
|
|
var container = document.getElementById('optimizations');
|
|
|
var data = JSON.parse(content);
|
|
var data = JSON.parse(content);
|
|
|
|
|
+ //console.log(data);
|
|
|
|
|
+ var candidates = [
|
|
|
|
|
+ data[1],
|
|
|
|
|
+ data[2],
|
|
|
|
|
+ data[3],
|
|
|
|
|
+ data[4],
|
|
|
|
|
+ data[5],
|
|
|
|
|
+ data[6]
|
|
|
|
|
+ ];
|
|
|
|
|
+ var total_combinations = data[1].length * data[2].length * data[3].length * data[4].length * data[5].length * data[6].length;
|
|
|
|
|
+ var checked_combinations = 0;
|
|
|
|
|
+ // Valic combinations that match the minimum requeriments
|
|
|
|
|
+ var valid_combinations = [];
|
|
|
|
|
+ console.log("TOTAL COMBINATIONS: " + total_combinations);
|
|
|
|
|
+ // TODO Prevent user on high numbers
|
|
|
|
|
+ // Counters to keep track on array indexes
|
|
|
|
|
+ var counters = [0, 0, 0, 0, 0, 0];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ while (true){
|
|
|
|
|
+
|
|
|
|
|
+ // Check loop exit condition
|
|
|
|
|
+ if (
|
|
|
|
|
+ counters[0] >= candidates[0].length &&
|
|
|
|
|
+ counters[1] >= candidates[1].length &&
|
|
|
|
|
+ counters[2] >= candidates[2].length &&
|
|
|
|
|
+ counters[3] >= candidates[3].length &&
|
|
|
|
|
+ counters[4] >= candidates[4].length &&
|
|
|
|
|
+ counters[5] >= candidates[5].length
|
|
|
|
|
+ ){
|
|
|
|
|
+ console.log("BREAK BY condition");
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // TODO DEBUG Exit a 3
|
|
|
|
|
+ if (checked_combinations >= 3000000){
|
|
|
|
|
+ console.log("BREAK BY hard limit");
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (valid_set([
|
|
|
|
|
+ candidates[0][counters[0]],
|
|
|
|
|
+ candidates[1][counters[1]],
|
|
|
|
|
+ candidates[2][counters[2]],
|
|
|
|
|
+ candidates[3][counters[3]],
|
|
|
|
|
+ candidates[4][counters[4]],
|
|
|
|
|
+ candidates[5][counters[5]]
|
|
|
|
|
+ ])){
|
|
|
|
|
+ valid_combinations.push({
|
|
|
|
|
+ 'score': 0,
|
|
|
|
|
+ 'runes': [
|
|
|
|
|
+ candidates[0][counters[0]],
|
|
|
|
|
+ candidates[1][counters[1]],
|
|
|
|
|
+ candidates[2][counters[2]],
|
|
|
|
|
+ candidates[3][counters[3]],
|
|
|
|
|
+ candidates[4][counters[4]],
|
|
|
|
|
+ candidates[5][counters[5]]
|
|
|
|
|
+ ]
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // Increase counters
|
|
|
|
|
+ checked_combinations ++;
|
|
|
|
|
+ counters[5] ++;
|
|
|
|
|
+ if (counters[5] >= candidates[5].length){
|
|
|
|
|
+ counters[5] = 0;
|
|
|
|
|
+ counters[4] ++;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (counters[4] >= candidates[4].length){
|
|
|
|
|
+ counters[4] = 0;
|
|
|
|
|
+ counters[3] ++;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (counters[3] >= candidates[3].length){
|
|
|
|
|
+ counters[3] = 0;
|
|
|
|
|
+ counters[2] ++;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (counters[2] >= candidates[2].length){
|
|
|
|
|
+ counters[2] = 0;
|
|
|
|
|
+ counters[1] ++;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (counters[1] >= candidates[1].length){
|
|
|
|
|
+ counters[1] = 0;
|
|
|
|
|
+ counters[0] ++;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (counters[0] >= candidates[0].length){
|
|
|
|
|
+ console.log("BREAK BY increments");
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /*if (checked_combinations % 1000 == 0){
|
|
|
|
|
+ console.log("COMBINATIONS CHECKED: " + checked_combinations + " / " + total_combinations + "(" + (checked_combinations * 100 / total_combinations) + "%)");
|
|
|
|
|
+ console.log(" 0: " + counters[0] + "/" + candidates[0].length);
|
|
|
|
|
+ console.log(" 1: " + counters[1] + "/" + candidates[1].length);
|
|
|
|
|
+ console.log(" 2: " + counters[2] + "/" + candidates[2].length);
|
|
|
|
|
+ console.log(" 3: " + counters[3] + "/" + candidates[3].length);
|
|
|
|
|
+ console.log(" 4: " + counters[4] + "/" + candidates[4].length);
|
|
|
|
|
+ console.log(" 5: " + counters[5] + "/" + candidates[5].length);
|
|
|
|
|
+ }*/
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // Foreach valid combination, rate it and sort the array
|
|
|
|
|
+ for (var i = 0; i < valid_combinations.length; i ++){
|
|
|
|
|
+ for (var r = 0; r < 6; r ++){
|
|
|
|
|
+ valid_combinations[i]['score'] += valid_combinations[i]["runes"][r]["ATK"];
|
|
|
|
|
+ valid_combinations[i]['score'] += valid_combinations[i]["runes"][r]["DEF"];
|
|
|
|
|
+ valid_combinations[i]['score'] += (valid_combinations[i]["runes"][r]["HP"] / 15);
|
|
|
|
|
+ valid_combinations[i]['score'] += (valid_combinations[i]["runes"][r]["SPD"] * 1.5);
|
|
|
|
|
+ valid_combinations[i]['score'] += (valid_combinations[i]["runes"][r]["CRR"] * 1.2);
|
|
|
|
|
+ valid_combinations[i]['score'] += (valid_combinations[i]["runes"][r]["CRD"] * 1.2);
|
|
|
|
|
+ valid_combinations[i]['score'] += (valid_combinations[i]["runes"][r]["ACC"] * 1.2);
|
|
|
|
|
+ valid_combinations[i]['score'] += (valid_combinations[i]["runes"][r]["ATK"] * 1.2);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ console.log("CHECKED: " + checked_combinations + "/" + total_combinations);
|
|
|
|
|
+ valid_combinations.sort(function(a, b) {return b['score'] - a['score'];});
|
|
|
|
|
+ valid_combinations = valid_combinations.slice(0, document.getElementById('limit').value);
|
|
|
|
|
+ console.log("SIZE: " + valid_combinations.length);
|
|
|
|
|
+// for (var i = 0; i < valid_combinations.length; i ++){
|
|
|
|
|
+// console.log(valid_combinations[i]['score']);
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+ // Request to fetch the runes.
|
|
|
|
|
+ // TODO
|
|
|
|
|
+ // Make the request
|
|
|
|
|
+ var xhttp = new XMLHttpRequest();
|
|
|
|
|
+ xhttp.onreadystatechange = function() {
|
|
|
|
|
+ if (this.readyState == 4){
|
|
|
|
|
+ console.log("RUNES RECEIVED");
|
|
|
|
|
+ console.log(this.response);
|
|
|
|
|
+ if (this.status == 200) {
|
|
|
|
|
+ //time = ((+ new Date()) - timestamp) / 1000;
|
|
|
|
|
+ presentOptions(this.response, time);
|
|
|
|
|
+ }
|
|
|
|
|
+ /*document.getElementById('apply').removeAttribute('disabled');
|
|
|
|
|
+ document.getElementById('wait').style.display = 'none';
|
|
|
|
|
+ //console.log(this.response);
|
|
|
|
|
+ if (this.status == 200) {
|
|
|
|
|
+ time = ((+ new Date()) - timestamp) / 1000;
|
|
|
|
|
+ showOptimizations(this.response, time);
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (this.status == 413) { // Payload too large
|
|
|
|
|
+ showMessage('Error', 'Too many combination found. Plesase narow your criteria and retry.');
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (this.status == 500) { // Server error
|
|
|
|
|
+ showMessage('Error', 'Too many rune combination found. Plesase narow your criteria and retry.');
|
|
|
|
|
+ }*/
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+ params = 'uid=<?=$UID?>&unit=<?=$page->unit->id?>';
|
|
|
|
|
+ params += '&options=' + JSON.stringify(valid_combinations);
|
|
|
|
|
+ xhttp.open('POST', '/action/optimize_get_options/', true);
|
|
|
|
|
+ xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
|
|
|
|
|
+ xhttp.send(params);
|
|
|
|
|
+ // Send the request
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ return;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ function presentOptions(content, time){
|
|
|
|
|
+ var container = document.getElementById('optimizations');
|
|
|
|
|
+ var data = JSON.parse(content);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
if (Number(data.total) == 0){
|
|
if (Number(data.total) == 0){
|
|
|
showMessage('No results', 'No suitable combination found. Plesase relax your criteria and retry.');
|
|
showMessage('No results', 'No suitable combination found. Plesase relax your criteria and retry.');
|
|
|
return;
|
|
return;
|
|
@@ -290,8 +660,8 @@
|
|
|
var stat_td;
|
|
var stat_td;
|
|
|
var span;
|
|
var span;
|
|
|
var text;
|
|
var text;
|
|
|
- for (i = 0; i < data.options.length; i++){
|
|
|
|
|
- option = data.options[i];
|
|
|
|
|
|
|
+ for (i = 0; i < data.length; i++){
|
|
|
|
|
+ option = data[i];
|
|
|
tr = document.createElement('tr');
|
|
tr = document.createElement('tr');
|
|
|
td = document.createElement('td');
|
|
td = document.createElement('td');
|
|
|
td.setAttribute('class', 'option_stats');
|
|
td.setAttribute('class', 'option_stats');
|
|
@@ -672,6 +1042,10 @@
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ function sortOptions(a, b) {
|
|
|
|
|
+ return b["score"] - a["score"];
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Displays a pop-up message.
|
|
* Displays a pop-up message.
|
|
@@ -691,6 +1065,24 @@
|
|
|
function closeMessage(){
|
|
function closeMessage(){
|
|
|
document.getElementById('message_container').style.display = 'none';
|
|
document.getElementById('message_container').style.display = 'none';
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ function debug(){
|
|
|
|
|
+ document.getElementById('set_1').selectedIndex = 0;
|
|
|
|
|
+ document.getElementById('set_2').selectedIndex = 0;
|
|
|
|
|
+ document.getElementById('set_3').selectedIndex = 1;
|
|
|
|
|
+ removeFilter('attack');
|
|
|
|
|
+ removeFilter('defense');
|
|
|
|
|
+ removeFilter('speed');
|
|
|
|
|
+ removeFilter('crit_rate');
|
|
|
|
|
+ removeFilter('crit_damage');
|
|
|
|
|
+ removeFilter('accuracy');
|
|
|
|
|
+ removeFilter('resistance');
|
|
|
|
|
+ removeFilter('ehp');
|
|
|
|
|
+ removeFilter('dmg');
|
|
|
|
|
+ document.getElementById('lbl_min_hp').value = 13500;
|
|
|
|
|
+ updateMinValue('hp', document.getElementById('lbl_min_hp'));
|
|
|
|
|
+ //apply();
|
|
|
|
|
+ }
|
|
|
</script>
|
|
</script>
|
|
|
</head>
|
|
</head>
|
|
|
<body>
|
|
<body>
|
|
@@ -1297,6 +1689,7 @@
|
|
|
<tr>
|
|
<tr>
|
|
|
<td class='action'>
|
|
<td class='action'>
|
|
|
<input id='apply' type='button' value='Apply' onClick='apply();'/>
|
|
<input id='apply' type='button' value='Apply' onClick='apply();'/>
|
|
|
|
|
+ <input id='apply' type='button' value='DEBUG' onClick='debug();'/>
|
|
|
</td>
|
|
</td>
|
|
|
<td class='empty'>
|
|
<td class='empty'>
|
|
|
<img id='wait' src='<?=URL::IMG["ICON"] . "wait.gif";?>'>
|
|
<img id='wait' src='<?=URL::IMG["ICON"] . "wait.gif";?>'>
|