add link to calculating palico
This commit is contained in:
13
db/calculating_palico_weapon_list.json
Normal file
13
db/calculating_palico_weapon_list.json
Normal file
File diff suppressed because one or more lines are too long
28
db/mk_cp_weapon_map.py
Executable file
28
db/mk_cp_weapon_map.py
Executable file
@@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
"""
|
||||||
|
Parse the weapon list data from calculating palico, and use it to
|
||||||
|
generate another JSON file mapping the weapon name to the the weapon
|
||||||
|
class qualified id (CLASS.WEAPON_ID) that is used when passing weapon
|
||||||
|
setups in the query parameter.
|
||||||
|
|
||||||
|
See https://github.com/mrmin123/the-calculating-palico
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os.path
|
||||||
|
import json
|
||||||
|
|
||||||
|
import _pathfix
|
||||||
|
from _pathfix import db_path, project_path
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
inpath = os.path.join(db_path, "calculating_palico_weapon_list.json")
|
||||||
|
outpath = os.path.join(project_path, "web", "data",
|
||||||
|
"calculating_palico_weapon_map.json")
|
||||||
|
|
||||||
|
with open(inpath) as f:
|
||||||
|
weapon_list = json.load(f)
|
||||||
|
weapon_map = dict()
|
||||||
|
for weapon in weapon_list:
|
||||||
|
weapon_map[weapon["name"]] = "%s.%s" % (weapon["class"], weapon["id"])
|
||||||
|
with open(outpath, "w") as f:
|
||||||
|
json.dump(weapon_map, f)
|
||||||
1
web/data/calculating_palico_weapon_map.json
Normal file
1
web/data/calculating_palico_weapon_map.json
Normal file
File diff suppressed because one or more lines are too long
@@ -5,6 +5,9 @@ WEAPON_NAME_IDX = {};
|
|||||||
// ["name", "wtype", "final", "element", "element_2", "awaken"]
|
// ["name", "wtype", "final", "element", "element_2", "awaken"]
|
||||||
WEAPON_ID_IDX = {};
|
WEAPON_ID_IDX = {};
|
||||||
|
|
||||||
|
// maps weapon name name -> calculating palico id string
|
||||||
|
PALICO_ID = {};
|
||||||
|
|
||||||
_ITEM_NAME_SPECIAL = {
|
_ITEM_NAME_SPECIAL = {
|
||||||
"welldonesteak": "Well-done Steak",
|
"welldonesteak": "Well-done Steak",
|
||||||
"lrgelderdragonbone": "Lrg ElderDragon Bone",
|
"lrgelderdragonbone": "Lrg ElderDragon Bone",
|
||||||
@@ -154,6 +157,17 @@ function load_weapon_data(ready_fn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function load_calculating_palico_data(ready_fn) {
|
||||||
|
var DATA_PATH = get_base_path() + "/data/";
|
||||||
|
$.getJSON(DATA_PATH + "calculating_palico_weapon_map.json",
|
||||||
|
function(data) {
|
||||||
|
PALICO_ID = data;
|
||||||
|
ready_fn();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function setup_weapon_autocomplete(weapon_selector, predicate_fn, ready_fn,
|
function setup_weapon_autocomplete(weapon_selector, predicate_fn, ready_fn,
|
||||||
change_fn) {
|
change_fn) {
|
||||||
load_weapon_data(function() {
|
load_weapon_data(function() {
|
||||||
@@ -235,3 +249,32 @@ function set_horn_melodies_title(weapon_data) {
|
|||||||
});
|
});
|
||||||
weapon_data["horn_melodies_title"] = lines.join(" ");
|
weapon_data["horn_melodies_title"] = lines.join(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function get_calculating_palico_setup(weapon_data) {
|
||||||
|
// NB: load_calculating_palico_data must be called first
|
||||||
|
var name = weapon_data["name"];
|
||||||
|
if (! name in PALICO_ID) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
var setup = [];
|
||||||
|
setup.push(PALICO_ID[name]);
|
||||||
|
var sharpness_plus = weapon_data["sharpness_plus"];
|
||||||
|
var max_sharpness = -1;
|
||||||
|
for (var i=0; i < sharpness_plus.length; i++) {
|
||||||
|
if (sharpness_plus[i] == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
max_sharpness = i;
|
||||||
|
}
|
||||||
|
setup.push(max_sharpness);
|
||||||
|
setup.push("3.1.awk,shp");
|
||||||
|
return setup.join(".");
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_calculating_palico_uri(setups) {
|
||||||
|
// m=31 is Great Jaggi
|
||||||
|
var base = "http://minyoung.ch/calculatingpalico/?m=31&s=";
|
||||||
|
return base + encodeURIComponent(JSON.stringify(setups));
|
||||||
|
}
|
||||||
|
|||||||
@@ -90,6 +90,10 @@
|
|||||||
z-index: 10;
|
z-index: 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#cp_div {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
@@ -98,7 +102,9 @@
|
|||||||
var template_row = new EJS({ url: "templates/weaponrow.ejs" });
|
var template_row = new EJS({ url: "templates/weaponrow.ejs" });
|
||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
load_weapon_data(init_page);
|
load_weapon_data(function() {
|
||||||
|
load_calculating_palico_data(init_page);
|
||||||
|
});
|
||||||
|
|
||||||
$("#sharpness_popup").on("click", function(evt) {
|
$("#sharpness_popup").on("click", function(evt) {
|
||||||
$(this).html("").offset({top:0, left:0}).hide();
|
$(this).html("").offset({top:0, left:0}).hide();
|
||||||
@@ -211,6 +217,7 @@
|
|||||||
|
|
||||||
function update_weapon_list(state) {
|
function update_weapon_list(state) {
|
||||||
var match_count = 0;
|
var match_count = 0;
|
||||||
|
var cp_setups = [];
|
||||||
var comps = state["weapon_component_text"].split("|");
|
var comps = state["weapon_component_text"].split("|");
|
||||||
console.log("updating weapon list: " + JSON.stringify(state));
|
console.log("updating weapon list: " + JSON.stringify(state));
|
||||||
$("#weapon_table").empty();
|
$("#weapon_table").empty();
|
||||||
@@ -238,10 +245,30 @@
|
|||||||
data["ELEMENT_ABBR"] = ELEMENT_ABBR;
|
data["ELEMENT_ABBR"] = ELEMENT_ABBR;
|
||||||
var html = template_row.render(data);
|
var html = template_row.render(data);
|
||||||
$("#weapon_table").append(html);
|
$("#weapon_table").append(html);
|
||||||
|
var setup = get_calculating_palico_setup(data);
|
||||||
|
console.log("setup for " + weapon_id + ": "
|
||||||
|
+ setup);
|
||||||
|
if (setup.length) {
|
||||||
|
cp_setups.push(setup);
|
||||||
|
}
|
||||||
|
update_cp_link(cp_setups);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
console.log("match count: " + match_count);
|
console.log("match count: " + match_count);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function update_cp_link(setups) {
|
||||||
|
if (setups.length == 0) {
|
||||||
|
console.log("no matches or no cp setups, hiding cp link");
|
||||||
|
$("#cp_div").hide();
|
||||||
|
} else {
|
||||||
|
var href = get_calculating_palico_uri(setups);
|
||||||
|
console.log("cp link: " + href);
|
||||||
|
$("#cp_link").prop("href", href);
|
||||||
|
$("#cp_div").show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
@@ -304,6 +331,11 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="cp_div">
|
||||||
|
<a id="cp_link"
|
||||||
|
href="http://minyoung.ch/calculatingpalico/"
|
||||||
|
>Compare weapons (Calculating Palico)</a>
|
||||||
|
</div>
|
||||||
<table id="weapon_table">
|
<table id="weapon_table">
|
||||||
</table>
|
</table>
|
||||||
<div id="sharpness_popup"></div>
|
<div id="sharpness_popup"></div>
|
||||||
|
|||||||
Reference in New Issue
Block a user