working mhgen weapon list and planner

This commit is contained in:
Bryce Allen
2016-07-24 15:23:39 -05:00
parent cbcf694106
commit 4bb929e826
7 changed files with 75 additions and 30 deletions

View File

@@ -144,7 +144,9 @@ function setup_item_autocomplete(selector) {
function load_weapon_data(ready_fn) {
var DATA_PATH = get_base_path() + "/jsonapi/";
if (typeof DATA_PATH == "undefined") {
DATA_PATH = get_base_path() + "/jsonapi/";
}
$.getJSON(DATA_PATH + "weapon/_index_name.json",
function(data) {
WEAPON_NAME_IDX = data;

View File

@@ -246,8 +246,8 @@
if (weapon_predicate(state, weapon_data)) {
weapon_data["id"] = i;
weapon_data["sharpness_width"] = 2;
// TODO: link to planner
weapon_data["url"] = null;
weapon_data["url"] = "weaponplanner.html?weapon="
+ encodeURIComponent(weapon_data["name"]);
weapon_data["bug_type"] = null;
weapon_data["arc_type"] = null;
match_count += 1;

View File

@@ -7,9 +7,9 @@
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/themes/smoothness/jquery-ui.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/jquery-ui.min.js"></script>
<script type="text/javascript" src="js/ejs_production.js"></script>
<script type="text/javascript" src="/js/ejs_production.js"></script>
<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript" src="/js/common.js"></script>
<style>
label {
@@ -85,10 +85,10 @@
</style>
<script type="text/javascript">
var DATA_PATH = get_base_path() + "/jsonapi/";
var DATA_PATH = "/jsonapi/mhgen/";
var template_path = new EJS({ url: "templates/weaponpath.ejs" });
var template_stats = new EJS({ url: "templates/weaponstats.ejs" });
var template_path = new EJS({ url: "/templates/weaponpath.ejs" });
var template_stats = new EJS({ url: "/templates/weaponstats.ejs" });
$(document).ready(function(){
setup_weapon_autocomplete("#weapon", autocomplete_predicate,
@@ -135,7 +135,7 @@
}
function save_state(state, replace) {
var url = "/weaponplanner.html?" + encode_qs(state);
var url = "/mhgen/weaponplanner.html?" + encode_qs(state);
if (replace) {
window.history.replaceState(state, "", url);
} else {
@@ -170,6 +170,7 @@
}
function show_trees(weapon_name) {
console.log("show_trees '" + weapon_name + "'");
if (!weapon_name) return;
weapon_id = WEAPON_NAME_IDX[weapon_name][0];
console.log("show_trees(" + weapon_name + "): " + weapon_id);
@@ -180,6 +181,13 @@
function(data) {
set_sharpness_titles(data);
set_horn_melodies_title(data);
if (data["parent_id"]) {
var parent_obj = WEAPON_ID_IDX[data["parent_id"]][0];
data["parent_name"] = parent_obj["name"];
} else {
data["parent_name"] = null;
}
data["sharpness_width"] = 2;
var html = template_stats.render(data);
$("#weapon_stats").html(html);
});

View File

@@ -22,41 +22,65 @@
<td>
<% if (awaken) { %>
(<img style="height:.8em" title="Awaken <%= awaken %>"
src="img/<%= awaken %>.png" /><%= awaken_attack %> <%= awaken %>)
src="/img/<%= awaken %>.png" /><%= awaken_attack %> <%= awaken %>)
<% } else if (element) { %>
<img style="height:.8em" title="<%= element %>"
src="img/<%= element %>.png" /> <%= element_attack %>
src="/img/<%= element %>.png" /> <%= element_attack %>
<%= element %>
<% if (element_2) { %>
<img style="height:.8em" title="<%= element_2 %>"
src="img/<%= element_2 %>.png" /> <%= element_2_attack %>
src="/img/<%= element_2 %>.png" /> <%= element_2_attack %>
<%= element_2 %>
<% } %>
<% } %>
</td>
<td>
<td id="sharpness_td"
data-sharpness="<%= sharpness_all_title %>"
data-id="<%= id %>">
<% if (sharpness) { %>
<div class="sharpness-bar" title="<%= sharpness_all_title %>">
<span style="width:<%= sharpness[0] %>px" class="red"></span>
<span style="width:<%= sharpness[1] %>px" class="orange"></span>
<span style="width:<%= sharpness[2] %>px" class="yellow"></span>
<span style="width:<%= sharpness[3] %>px" class="green"></span>
<span style="width:<%= sharpness[4] %>px" class="blue"></span>
<span style="width:<%= sharpness[5] %>px" class="white"></span>
<span style="width:<%= sharpness[6] %>px" class="purple"></span>
<span style="width:<%= sharpness[0] * sharpness_width %>px" class="red"></span>
<span style="width:<%= sharpness[1] * sharpness_width %>px" class="orange"></span>
<span style="width:<%= sharpness[2] * sharpness_width %>px" class="yellow"></span>
<span style="width:<%= sharpness[3] * sharpness_width %>px" class="green"></span>
<span style="width:<%= sharpness[4] * sharpness_width %>px" class="blue"></span>
<span style="width:<%= sharpness[5] * sharpness_width %>px" class="white"></span>
<% if (sharpness.length > 6) { %>
<span style="width:<%= sharpness[6] * sharpness_width %>px" class="purple"></span>
<% } %>
</div>
<div class="sharpness-bar" title="<%= sharpness_all_title %>">
<span style="width:<%= sharpness_plus[0] %>px" class="red"></span>
<span style="width:<%= sharpness_plus[1] %>px" class="orange"></span>
<span style="width:<%= sharpness_plus[2] %>px" class="yellow"></span>
<span style="width:<%= sharpness_plus[3] %>px" class="green"></span>
<span style="width:<%= sharpness_plus[4] %>px" class="blue"></span>
<span style="width:<%= sharpness_plus[5] %>px" class="white"></span>
<span style="width:<%= sharpness_plus[6] %>px" class="purple"></span>
<span style="width:<%= sharpness_plus[0] * sharpness_width %>px" class="red"></span>
<span style="width:<%= sharpness_plus[1] * sharpness_width %>px" class="orange"></span>
<span style="width:<%= sharpness_plus[2] * sharpness_width %>px" class="yellow"></span>
<span style="width:<%= sharpness_plus[3] * sharpness_width %>px" class="green"></span>
<span style="width:<%= sharpness_plus[4] * sharpness_width %>px" class="blue"></span>
<span style="width:<%= sharpness_plus[5] * sharpness_width %>px" class="white"></span>
<% if (sharpness.length > 6) { %>
<span style="width:<%= sharpness_plus[6] * sharpness_width %>px" class="purple"></span>
<% } %>
</div>
<% if (sharpness_plus2) { %>
<div class="sharpness-bar" title="<%= sharpness_all_title %>">
<span style="width:<%= sharpness_plus2[0] * sharpness_width %>px" class="red"></span>
<span style="width:<%= sharpness_plus2[1] * sharpness_width %>px" class="orange"></span>
<span style="width:<%= sharpness_plus2[2] * sharpness_width %>px" class="yellow"></span>
<span style="width:<%= sharpness_plus2[3] * sharpness_width %>px" class="green"></span>
<span style="width:<%= sharpness_plus2[4] * sharpness_width %>px" class="blue"></span>
<span style="width:<%= sharpness_plus2[5] * sharpness_width %>px" class="white"></span>
<% if (sharpness.length > 6) { %>
<span style="width:<%= sharpness_plus2[6] * sharpness_width %>px" class="purple"></span>
<% } %>
</div>
<% } %>
<% } %>
</td>
<td style="text-align:right"><% if (defense) { %>+<%= defense %> Def<% } %>
<% if (parent_name) { %>
<a href="weaponplanner.html?weapon=<%= encodeURIComponent(parent_name) %>"
title="<%= parent_name %>">(parent)</a>
<% } %>
</td>
<td style="text-align:right"><% if (defense) { %>+<%= defense %> Def<% } %></td>
</tr>
</table>
<% if (children.length) { %>
@@ -70,3 +94,4 @@
</td></tr>
</table>
<% } %>

View File

@@ -180,6 +180,14 @@
function(data) {
set_sharpness_titles(data);
set_horn_melodies_title(data);
data["sharpness_plus2"] = null;
data["sharpness_width"] = 1;
if (data["parent_id"]) {
var parent_obj = WEAPON_ID_IDX[data["parent_id"]][0];
data["parent_name"] = parent_obj["name"];
} else {
data["parent_name"] = null;
}
var html = template_stats.render(data);
$("#weapon_stats").html(html);
});