initial mhgen support
This commit is contained in:
@@ -178,6 +178,9 @@ def parse_args(argv):
|
|||||||
parser.add_argument("-x", "--monster-hunter-cross", action="store_true",
|
parser.add_argument("-x", "--monster-hunter-cross", action="store_true",
|
||||||
default=False,
|
default=False,
|
||||||
help="Assume weapons are true attack, use MHX values")
|
help="Assume weapons are true attack, use MHX values")
|
||||||
|
parser.add_argument("-g", "--monster-hunter-gen", action="store_true",
|
||||||
|
default=False,
|
||||||
|
help="Assume weapons are true attack, use MHGen values")
|
||||||
parser.add_argument("-m", "--match", nargs="*",
|
parser.add_argument("-m", "--match", nargs="*",
|
||||||
help="WEAPON_TYPE,ELEMENT_OR_STATUS_OR_RAW"
|
help="WEAPON_TYPE,ELEMENT_OR_STATUS_OR_RAW"
|
||||||
+" Include all matching weapons in their final form."
|
+" Include all matching weapons in their final form."
|
||||||
@@ -324,10 +327,15 @@ def print_damage_percent_diff(names, damage_map_base, weapon_damage_map, parts):
|
|||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
args = parse_args(None)
|
args = parse_args(None)
|
||||||
|
|
||||||
|
game_uses_true_raw = False
|
||||||
if args.monster_hunter_cross:
|
if args.monster_hunter_cross:
|
||||||
db = MHDBX()
|
db = MHDBX()
|
||||||
|
game_uses_true_raw = True
|
||||||
|
elif args.monster_hunter_gen:
|
||||||
|
db = MHDB(game="gen")
|
||||||
|
game_uses_true_raw = True
|
||||||
else:
|
else:
|
||||||
db = MHDB()
|
db = MHDB(game="4u")
|
||||||
motiondb = MotionValueDB(_pathfix.motion_values_path)
|
motiondb = MotionValueDB(_pathfix.motion_values_path)
|
||||||
|
|
||||||
monster = db.get_monster_by_name(args.monster)
|
monster = db.get_monster_by_name(args.monster)
|
||||||
@@ -409,7 +417,7 @@ if __name__ == '__main__':
|
|||||||
artillery_level=skill_args.artillery,
|
artillery_level=skill_args.artillery,
|
||||||
limit_parts=args.parts,
|
limit_parts=args.parts,
|
||||||
frenzy_bonus=skill_args.frenzy,
|
frenzy_bonus=skill_args.frenzy,
|
||||||
is_true_attack=args.monster_hunter_cross,
|
is_true_attack=game_uses_true_raw,
|
||||||
blunt_power=skill_args.blunt_power)
|
blunt_power=skill_args.blunt_power)
|
||||||
print "%-20s: %4.0f %2.0f%%" % (name, wd.attack, wd.affinity),
|
print "%-20s: %4.0f %2.0f%%" % (name, wd.attack, wd.affinity),
|
||||||
if wd.etype:
|
if wd.etype:
|
||||||
|
|||||||
@@ -174,8 +174,8 @@ def weapon_json(db, path):
|
|||||||
mkdirs_p(path)
|
mkdirs_p(path)
|
||||||
write_list_file(path, weapons)
|
write_list_file(path, weapons)
|
||||||
|
|
||||||
|
all_data = []
|
||||||
melodies = {}
|
melodies = {}
|
||||||
|
|
||||||
indexes = {}
|
indexes = {}
|
||||||
for w in weapons:
|
for w in weapons:
|
||||||
weapon_path = file_path(path, w)
|
weapon_path = file_path(path, w)
|
||||||
@@ -193,6 +193,8 @@ def weapon_json(db, path):
|
|||||||
]
|
]
|
||||||
data["horn_melodies"] = melodies[w.horn_notes]
|
data["horn_melodies"] = melodies[w.horn_notes]
|
||||||
|
|
||||||
|
all_data.append(data)
|
||||||
|
|
||||||
with open(weapon_path, "w") as f:
|
with open(weapon_path, "w") as f:
|
||||||
json.dump(data, f, cls=model.ModelJSONEncoder, indent=2)
|
json.dump(data, f, cls=model.ModelJSONEncoder, indent=2)
|
||||||
|
|
||||||
@@ -205,6 +207,7 @@ def weapon_json(db, path):
|
|||||||
json.dump(costs, f, cls=model.ModelJSONEncoder, indent=2)
|
json.dump(costs, f, cls=model.ModelJSONEncoder, indent=2)
|
||||||
|
|
||||||
write_index_file(path, indexes)
|
write_index_file(path, indexes)
|
||||||
|
write_all_file(path, all_data)
|
||||||
|
|
||||||
|
|
||||||
def item_json(db, path):
|
def item_json(db, path):
|
||||||
|
|||||||
BIN
db/mhgen.db
Normal file
BIN
db/mhgen.db
Normal file
Binary file not shown.
37
mhapi/db.py
37
mhapi/db.py
@@ -2,7 +2,7 @@
|
|||||||
Module for accessing the sqlite monster hunter db from
|
Module for accessing the sqlite monster hunter db from
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os.path
|
import os
|
||||||
import sqlite3
|
import sqlite3
|
||||||
import json
|
import json
|
||||||
|
|
||||||
@@ -19,10 +19,10 @@ def field_model(key):
|
|||||||
return model_fn
|
return model_fn
|
||||||
|
|
||||||
|
|
||||||
def _db_path():
|
def _db_path(game=None):
|
||||||
module_path = os.path.dirname(__file__)
|
module_path = os.path.dirname(__file__)
|
||||||
project_path = os.path.abspath(os.path.join(module_path, ".."))
|
project_path = os.path.abspath(os.path.join(module_path, ".."))
|
||||||
return os.path.join(project_path, "db", "mh4u.db")
|
return os.path.join(project_path, "db", "mh%s.db" % game)
|
||||||
|
|
||||||
|
|
||||||
class MHDB(object):
|
class MHDB(object):
|
||||||
@@ -46,7 +46,7 @@ class MHDB(object):
|
|||||||
|
|
||||||
# sell has the a value, but not used at the moment
|
# sell has the a value, but not used at the moment
|
||||||
_decoration_select = """
|
_decoration_select = """
|
||||||
SELECT items._id, items.type, items.name, items.name_jp,
|
SELECT items._id, items.type, items.name,
|
||||||
items.rarity, decorations.*
|
items.rarity, decorations.*
|
||||||
FROM decorations
|
FROM decorations
|
||||||
LEFT JOIN items ON decorations._id = items._id
|
LEFT JOIN items ON decorations._id = items._id
|
||||||
@@ -54,13 +54,13 @@ class MHDB(object):
|
|||||||
|
|
||||||
# buy has the armor cost, sell is empty
|
# buy has the armor cost, sell is empty
|
||||||
_armor_select = """
|
_armor_select = """
|
||||||
SELECT items._id, items.type, items.name, items.name_jp,
|
SELECT items._id, items.type, items.name,
|
||||||
items.rarity, items.buy, armor.*
|
items.rarity, items.buy, armor.*
|
||||||
FROM armor
|
FROM armor
|
||||||
LEFT JOIN items ON armor._id = items._id
|
LEFT JOIN items ON armor._id = items._id
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, path=None, use_cache=False,
|
def __init__(self, game=None, path=None, use_cache=False,
|
||||||
include_item_components=False):
|
include_item_components=False):
|
||||||
"""
|
"""
|
||||||
If use_cache=True, a lot of memory could be used. No attempt is
|
If use_cache=True, a lot of memory could be used. No attempt is
|
||||||
@@ -70,8 +70,12 @@ class MHDB(object):
|
|||||||
database should make in-memory caching unnecessary for most use
|
database should make in-memory caching unnecessary for most use
|
||||||
cases.
|
cases.
|
||||||
"""
|
"""
|
||||||
|
if game is None:
|
||||||
|
game = os.environ.get("MHAPI_GAME")
|
||||||
|
assert game in ("4u", "gen")
|
||||||
|
self.game = game
|
||||||
if path is None:
|
if path is None:
|
||||||
path = _db_path()
|
path = _db_path(game)
|
||||||
self.conn = sqlite3.connect(path)
|
self.conn = sqlite3.connect(path)
|
||||||
self.conn.row_factory = sqlite3.Row
|
self.conn.row_factory = sqlite3.Row
|
||||||
self.use_cache = use_cache
|
self.use_cache = use_cache
|
||||||
@@ -315,9 +319,10 @@ class MHDB(object):
|
|||||||
def get_weapons(self):
|
def get_weapons(self):
|
||||||
# Note: weapons only available via JP DLC have no localized
|
# Note: weapons only available via JP DLC have no localized
|
||||||
# name, filter them out.
|
# name, filter them out.
|
||||||
return self._query_all("weapons", MHDB._weapon_select + """
|
q = MHDB._weapon_select
|
||||||
WHERE items.name != items.name_jp""",
|
if self.game == "4u":
|
||||||
model_cls=model.Weapon)
|
q += "\nWHERE items.name != items.name_jp",
|
||||||
|
return self._query_all("weapons", q, model_cls=model.Weapon)
|
||||||
|
|
||||||
def get_weapons_by_query(self, wtype=None, element=None,
|
def get_weapons_by_query(self, wtype=None, element=None,
|
||||||
final=None):
|
final=None):
|
||||||
@@ -329,7 +334,11 @@ class MHDB(object):
|
|||||||
@final should be string '1' or '0'
|
@final should be string '1' or '0'
|
||||||
"""
|
"""
|
||||||
q = MHDB._weapon_select
|
q = MHDB._weapon_select
|
||||||
|
if self.game == "4u":
|
||||||
|
# filter out non-localized japanese DLC
|
||||||
where = ["items.name != items.name_jp"]
|
where = ["items.name != items.name_jp"]
|
||||||
|
else:
|
||||||
|
where = []
|
||||||
args = []
|
args = []
|
||||||
if wtype is not None:
|
if wtype is not None:
|
||||||
where.append("wtype = ?")
|
where.append("wtype = ?")
|
||||||
@@ -365,8 +374,7 @@ class MHDB(object):
|
|||||||
""", (parent_id,), model_cls=model.Weapon)
|
""", (parent_id,), model_cls=model.Weapon)
|
||||||
|
|
||||||
def get_armors(self):
|
def get_armors(self):
|
||||||
return self._query_all("armors", MHDB._armor_select + """
|
return self._query_all("armors", MHDB._armor_select,
|
||||||
WHERE items.name != items.name_jp""",
|
|
||||||
model_cls=model.Armor)
|
model_cls=model.Armor)
|
||||||
|
|
||||||
def get_armor(self, armor_id):
|
def get_armor(self, armor_id):
|
||||||
@@ -404,7 +412,7 @@ class MHDB(object):
|
|||||||
|
|
||||||
def get_skill_trees(self):
|
def get_skill_trees(self):
|
||||||
return self._query_all("skill_trees", """
|
return self._query_all("skill_trees", """
|
||||||
SELECT _id, name, name_jp FROM skill_trees
|
SELECT _id, name FROM skill_trees
|
||||||
""", model_cls=model.SkillTree)
|
""", model_cls=model.SkillTree)
|
||||||
|
|
||||||
def get_skill_tree_id(self, skill_tree_name):
|
def get_skill_tree_id(self, skill_tree_name):
|
||||||
@@ -419,7 +427,7 @@ class MHDB(object):
|
|||||||
def get_skills(self):
|
def get_skills(self):
|
||||||
return self._query_all("skills", """
|
return self._query_all("skills", """
|
||||||
SELECT _id, skill_tree_id, required_skill_tree_points,
|
SELECT _id, skill_tree_id, required_skill_tree_points,
|
||||||
name, name_jp, description
|
name, description
|
||||||
FROM skills
|
FROM skills
|
||||||
""", model_cls=model.Skill)
|
""", model_cls=model.Skill)
|
||||||
|
|
||||||
@@ -456,7 +464,6 @@ class MHDB(object):
|
|||||||
AND item_to_skill_tree.skill_tree_id IN (%s)
|
AND item_to_skill_tree.skill_tree_id IN (%s)
|
||||||
AND item_to_skill_tree.point_value > 0
|
AND item_to_skill_tree.point_value > 0
|
||||||
AND armor.hunter_type IN ('Both', ?)
|
AND armor.hunter_type IN ('Both', ?)
|
||||||
AND items.name != items.name_jp
|
|
||||||
GROUP BY item_to_skill_tree.item_id
|
GROUP BY item_to_skill_tree.item_id
|
||||||
""" % placeholders, tuple(args), model_cls=model.Armor)
|
""" % placeholders, tuple(args), model_cls=model.Armor)
|
||||||
|
|
||||||
|
|||||||
@@ -192,6 +192,10 @@ class WeaponSharpness(ModelBase):
|
|||||||
self.value_list = db_string_or_list
|
self.value_list = db_string_or_list
|
||||||
else:
|
else:
|
||||||
self.value_list = [int(s) for s in db_string_or_list.split(".")]
|
self.value_list = [int(s) for s in db_string_or_list.split(".")]
|
||||||
|
# For MHX, Gen, no purple sharpness, but keep model the same for
|
||||||
|
# simplicity
|
||||||
|
if len(self.value_list) < SharpnessLevel.PURPLE + 1:
|
||||||
|
self.value_list.append(0)
|
||||||
self._max = None
|
self._max = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -210,7 +214,7 @@ class WeaponSharpness(ModelBase):
|
|||||||
|
|
||||||
|
|
||||||
class ItemCraftable(RowModel):
|
class ItemCraftable(RowModel):
|
||||||
_list_fields = ["id", "name", "name_jp"]
|
_list_fields = ["id", "name"]
|
||||||
|
|
||||||
def __init__(self, item_row):
|
def __init__(self, item_row):
|
||||||
super(ItemCraftable, self).__init__(item_row)
|
super(ItemCraftable, self).__init__(item_row)
|
||||||
@@ -320,7 +324,7 @@ class ItemSkill(RowModel):
|
|||||||
|
|
||||||
|
|
||||||
class SkillTree(RowModel):
|
class SkillTree(RowModel):
|
||||||
_list_fields = ["id", "name", "name_jp"]
|
_list_fields = ["id", "name"]
|
||||||
|
|
||||||
def __init__(self, skill_tree_row):
|
def __init__(self, skill_tree_row):
|
||||||
super(SkillTree, self).__init__(skill_tree_row)
|
super(SkillTree, self).__init__(skill_tree_row)
|
||||||
@@ -343,7 +347,7 @@ class SkillTree(RowModel):
|
|||||||
|
|
||||||
|
|
||||||
class Skill(RowModel):
|
class Skill(RowModel):
|
||||||
_list_fields = ["id", "name", "name_jp"]
|
_list_fields = ["id", "name"]
|
||||||
_indexes = { "skill_tree_id":
|
_indexes = { "skill_tree_id":
|
||||||
["id", "required_skill_tree_points", "name", "description"] }
|
["id", "required_skill_tree_points", "name", "description"] }
|
||||||
|
|
||||||
@@ -386,26 +390,30 @@ class Weapon(ItemCraftable):
|
|||||||
self.sharpness_plus2 = WeaponSharpness(
|
self.sharpness_plus2 = WeaponSharpness(
|
||||||
self._row["sharpness_plus2"] + [0])
|
self._row["sharpness_plus2"] + [0])
|
||||||
else:
|
else:
|
||||||
# 4U data from db
|
# 4U or gen data from db
|
||||||
parts = self._row["sharpness"].split(" ")
|
parts = self._row["sharpness"].split(" ")
|
||||||
if len(parts) != 2:
|
if len(parts) == 2:
|
||||||
|
normal, plus = parts
|
||||||
|
plus2 = plus
|
||||||
|
elif len(parts) == 3:
|
||||||
|
normal, plus, plus2 = parts
|
||||||
|
else:
|
||||||
raise ValueError("Bad sharpness value in db: '%s'"
|
raise ValueError("Bad sharpness value in db: '%s'"
|
||||||
% self._row["sharpness"])
|
% self._row["sharpness"])
|
||||||
normal, plus = parts
|
|
||||||
self._data["sharpness"] = WeaponSharpness(normal)
|
self._data["sharpness"] = WeaponSharpness(normal)
|
||||||
self._data["sharpness_plus"] = WeaponSharpness(plus)
|
self._data["sharpness_plus"] = WeaponSharpness(plus)
|
||||||
self._data["sharpness_plus2"] = WeaponSharpness(plus)
|
self._data["sharpness_plus2"] = WeaponSharpness(plus2)
|
||||||
|
|
||||||
def is_not_localized(self):
|
def is_not_localized(self):
|
||||||
return (self.name == self.name_jp)
|
return (self.name == self.name_jp)
|
||||||
|
|
||||||
|
|
||||||
class Monster(RowModel):
|
class Monster(RowModel):
|
||||||
_list_fields = ["id", "class", "name", "name_jp"]
|
_list_fields = ["id", "class", "name"]
|
||||||
|
|
||||||
|
|
||||||
class Item(RowModel):
|
class Item(RowModel):
|
||||||
_list_fields = ["id", "type", "name", "name_jp"]
|
_list_fields = ["id", "type", "name"]
|
||||||
_indexes = { "name": ["id"],
|
_indexes = { "name": ["id"],
|
||||||
"type": ["id", "name"] }
|
"type": ["id", "name"] }
|
||||||
|
|
||||||
|
|||||||
337
web/mhgen/weaponlist.html
Normal file
337
web/mhgen/weaponlist.html
Normal file
@@ -0,0 +1,337 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Poogie's Weapon List (MHGen)</title>
|
||||||
|
|
||||||
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
|
||||||
|
|
||||||
|
<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/common.js"></script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
label {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
font-family: sans, sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
td.plus {
|
||||||
|
background-color: LightCyan;
|
||||||
|
}
|
||||||
|
|
||||||
|
td.minus {
|
||||||
|
background-color: LightPink;
|
||||||
|
}
|
||||||
|
|
||||||
|
td.num {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*@media (max-width: 600) {*/
|
||||||
|
.flexbox {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sharpness-bar {
|
||||||
|
border: 1px #a9a9a9 solid;
|
||||||
|
min-width: 90px;
|
||||||
|
height: 7px;
|
||||||
|
background-color: #a9a9a9;
|
||||||
|
float: left;
|
||||||
|
clear: both;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sharpness-bar span {
|
||||||
|
display: inline-block;
|
||||||
|
height: 100%;
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sharpness-bar .red {
|
||||||
|
background-color: #C00C38 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sharpness-bar .orange {
|
||||||
|
background-color: #E85018 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sharpness-bar .yellow {
|
||||||
|
background-color: #F0C830 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sharpness-bar .green {
|
||||||
|
background-color: #58D000 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sharpness-bar .blue {
|
||||||
|
background-color: #3068E8 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sharpness-bar .white {
|
||||||
|
background-color: #F0F0F0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sharpness-bar .purple {
|
||||||
|
/* no purple in mhx */
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
#sharpness_popup {
|
||||||
|
position: absolute;
|
||||||
|
display: none;
|
||||||
|
border: 1px solid;
|
||||||
|
background: rgba(204, 204, 204, 0.9);
|
||||||
|
z-index: 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
#cp_div {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
var WEAPON_LIST = null;
|
||||||
|
var HORN_MELODY_MAP = null;
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: "/jsonapi/mhgen/weapon/_all.json",
|
||||||
|
async: false,
|
||||||
|
dataType: "json",
|
||||||
|
success: function (data) {
|
||||||
|
WEAPON_LIST = data;
|
||||||
|
console.log("weapon count " + WEAPON_LIST.length);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: "/jsonapi/mhgen/horn_melody/_index_notes.json",
|
||||||
|
async: false,
|
||||||
|
dataType: "json",
|
||||||
|
success: function (data) {
|
||||||
|
HORN_MELODY_MAP = data;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
var template_row = new EJS({ url: "/templates/weaponrow.ejs" });
|
||||||
|
|
||||||
|
$(document).ready(function(){
|
||||||
|
init_page();
|
||||||
|
|
||||||
|
$("#sharpness_popup").on("click", function(evt) {
|
||||||
|
$(this).html("").offset({top:0, left:0}).hide();
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#weapon_table").on("click", "#sharpness_td", function(evt) {
|
||||||
|
var td_obj = $(evt.currentTarget);
|
||||||
|
var offset = td_obj.offset();
|
||||||
|
var sharpness = td_obj.data("sharpness");
|
||||||
|
$("#sharpness_popup").html(sharpness).offset(offset).show();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function init_page() {
|
||||||
|
var qs = load_qs();
|
||||||
|
$(window).on("popstate", function(e) {
|
||||||
|
var oe = e.originalEvent;
|
||||||
|
if (oe.state !== null) {
|
||||||
|
console.log("popState:" + JSON.stringify(oe.state));
|
||||||
|
update_weapon_list(oe.state);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$("#search").click(function(evt) {
|
||||||
|
var state = get_ui_state();
|
||||||
|
save_state(state);
|
||||||
|
update_weapon_list(state);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (qs) {
|
||||||
|
update_weapon_list(qs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function load_qs() {
|
||||||
|
if ($.QueryString["weapon_type"]) {
|
||||||
|
load_state($.QueryString);
|
||||||
|
return $.QueryString;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_ui_state() {
|
||||||
|
return { "weapon_type": $("#weapon_type").val(),
|
||||||
|
"weapon_element": $("#weapon_element").val(),
|
||||||
|
"weapon_final": $("#weapon_final").is(":checked"),
|
||||||
|
"weapon_name_text": $("#weapon_name_text").val() };
|
||||||
|
}
|
||||||
|
|
||||||
|
function load_state(state) {
|
||||||
|
$("#weapon_type").val(state["weapon_type"]);
|
||||||
|
$("#weapon_element").val(state["weapon_element"]);
|
||||||
|
$("#weapon_final").prop("checked", state["weapon_final"]);
|
||||||
|
$("#weapon_name_text").val(state["weapon_name_text"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function save_state(state, replace) {
|
||||||
|
var url = "weaponlist.html?" + encode_qs(state);
|
||||||
|
if (replace) {
|
||||||
|
window.history.replaceState(state, "", url);
|
||||||
|
} else {
|
||||||
|
window.history.pushState(state, "", url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function weapon_predicate(state, weapon_data) {
|
||||||
|
var weapon_type = state["weapon_type"];
|
||||||
|
var weapon_element = state["weapon_element"];
|
||||||
|
var final_only = state["weapon_final"];
|
||||||
|
var weapon_names = state["weapon_name_text"].split("|");
|
||||||
|
|
||||||
|
if (final_only && weapon_data["final"] != 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (weapon_type != "All" && weapon_type != weapon_data["wtype"]) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (weapon_element != "All"
|
||||||
|
&& weapon_element != weapon_data["element"]
|
||||||
|
&& weapon_element != weapon_data["element_2"]
|
||||||
|
&& weapon_element != weapon_data["awaken"]
|
||||||
|
&& weapon_element != weapon_data["phial"]) {
|
||||||
|
if (weapon_element != "None"
|
||||||
|
|| (weapon_data["element"] != null && weapon_data["element"] != "")
|
||||||
|
|| (weapon_data["awaken"] != null && weapon_data["awaken"] != "")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (weapon_names && !list_match(weapon_names, [weapon_data["name"]])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function list_match(needles, string_list) {
|
||||||
|
var found = false;
|
||||||
|
for (var i=0; i<string_list.length; i++) {
|
||||||
|
for (var j=0; j<needles.length; j++) {
|
||||||
|
if (string_list[i].search(needles[j]) >= 0) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (found) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
|
||||||
|
function update_weapon_list(state) {
|
||||||
|
var match_count = 0;
|
||||||
|
console.log("updating weapon list: " + JSON.stringify(state));
|
||||||
|
var results = [];
|
||||||
|
$.each(WEAPON_LIST, function(i, weapon_data) {
|
||||||
|
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["bug_type"] = null;
|
||||||
|
weapon_data["arc_type"] = null;
|
||||||
|
match_count += 1;
|
||||||
|
set_sharpness_titles(weapon_data);
|
||||||
|
set_bow_values(weapon_data);
|
||||||
|
set_horn_melodies_title(weapon_data, HORN_MELODY_MAP);
|
||||||
|
weapon_data["wtype_short"] =
|
||||||
|
WEAPON_TYPE_ABBR[weapon_data["wtype"]];
|
||||||
|
weapon_data["ELEMENT_ABBR"] = ELEMENT_ABBR;
|
||||||
|
var html = template_row.render(weapon_data);
|
||||||
|
results.push([weapon_data, html]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
results.sort(function (a, b) {
|
||||||
|
avals = get_weapon_sort_values(a[0]);
|
||||||
|
bvals = get_weapon_sort_values(b[0]);
|
||||||
|
return cmp_arrays(bvals, avals);
|
||||||
|
});
|
||||||
|
$("#weapon_table").empty();
|
||||||
|
$.each(results, function(i, pair) {
|
||||||
|
$("#weapon_table").append(pair[1]);
|
||||||
|
});
|
||||||
|
console.log("match count: " + match_count);
|
||||||
|
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td><label for="weapon_type"
|
||||||
|
title="Only show weapons of this type"
|
||||||
|
>Type:</label></td>
|
||||||
|
<td><select id="weapon_type">
|
||||||
|
<option value="All">All</option>
|
||||||
|
<option value="Great Sword">Great Sword</option>
|
||||||
|
<option value="Long Sword">Long Sword</option>
|
||||||
|
<option value="Sword and Shield">Sword and Shield</option>
|
||||||
|
<option value="Dual Blades">Dual Blades</option>
|
||||||
|
<option value="Hammer">Hammer</option>
|
||||||
|
<option value="Hunting Horn">Hunting Horn</option>
|
||||||
|
<option value="Lance">Lance</option>
|
||||||
|
<option value="Gunlance">Gunlance</option>
|
||||||
|
<option value="Switch Axe">Switch Axe</option>
|
||||||
|
<option value="Charge Blade">Charge Blade</option>
|
||||||
|
<option value="Insect Glaive">Insect Glaive</option>
|
||||||
|
<!--option value="Light Bowgun">Light Bowgun</option-->
|
||||||
|
<!--option value="Heavy Bowgun">Heavy Bowgun</option-->
|
||||||
|
<option value="Bow">Bow</option>
|
||||||
|
</select></td>
|
||||||
|
<td><label for="weapon_element"
|
||||||
|
title="Only show weapons with this element (native or requiring awaken)"
|
||||||
|
>Element:</label></td>
|
||||||
|
<td><select id="weapon_element">
|
||||||
|
<option value="All">All</option>
|
||||||
|
<option value="None">None</option>
|
||||||
|
<option value="Fire">Fire</option>
|
||||||
|
<option value="Water">Water</option>
|
||||||
|
<option value="Thunder">Thunder</option>
|
||||||
|
<option value="Ice">Ice</option>
|
||||||
|
<option value="Dragon">Dragon</option>
|
||||||
|
<option value="Poison">Poison</option>
|
||||||
|
<option value="Paralysis">Paralysis</option>
|
||||||
|
<option value="Sleep">Sleep</option>
|
||||||
|
<option value="Blast">Blast</option>
|
||||||
|
</select></td>
|
||||||
|
<td><label for="weapon_final"
|
||||||
|
title="Only show weapons with no furthur upgrades"
|
||||||
|
>Final?</label></td>
|
||||||
|
<td><input id="weapon_final" type="checkbox" /></td>
|
||||||
|
<td><button id="search">Search</button></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="7">
|
||||||
|
<label for="weapon_name_text"
|
||||||
|
title="Show only weapons with a match in the name. List of strings separated by '|' (vertical bar)."
|
||||||
|
>Name:</label>
|
||||||
|
<input id="weapon_name_text" size="15" />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<table id="weapon_table">
|
||||||
|
</table>
|
||||||
|
<div id="sharpness_popup"></div>
|
||||||
|
</body>
|
||||||
267
web/mhgen/weaponplanner.html
Normal file
267
web/mhgen/weaponplanner.html
Normal file
@@ -0,0 +1,267 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Poogie's Weapon Planner</title>
|
||||||
|
|
||||||
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
|
||||||
|
|
||||||
|
<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/common.js"></script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
label {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
font-family: sans, sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
td.plus {
|
||||||
|
background-color: LightCyan;
|
||||||
|
}
|
||||||
|
|
||||||
|
td.minus {
|
||||||
|
background-color: LightPink;
|
||||||
|
}
|
||||||
|
|
||||||
|
td.num {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*@media (max-width: 600) {*/
|
||||||
|
.flexbox {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sharpness-bar {
|
||||||
|
border: 1px #d3d3d3 solid;
|
||||||
|
min-width: 92px;
|
||||||
|
height: 10px;
|
||||||
|
background-color: #d3d3d3;
|
||||||
|
float: left;
|
||||||
|
clear: both;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sharpness-bar span {
|
||||||
|
display: inline-block;
|
||||||
|
height: 100%;
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sharpness-bar .red {
|
||||||
|
background-color: #C00C38 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sharpness-bar .orange {
|
||||||
|
background-color: #E85018 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sharpness-bar .yellow {
|
||||||
|
background-color: #F0C830 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sharpness-bar .green {
|
||||||
|
background-color: #58D000 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sharpness-bar .blue {
|
||||||
|
background-color: #3068E8 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sharpness-bar .white {
|
||||||
|
background-color: #F0F0F0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sharpness-bar .purple {
|
||||||
|
background-color: #c3c !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
var DATA_PATH = get_base_path() + "/jsonapi/";
|
||||||
|
|
||||||
|
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,
|
||||||
|
init_page, update_search);
|
||||||
|
});
|
||||||
|
|
||||||
|
function init_page() {
|
||||||
|
load_qs();
|
||||||
|
$("#search").click(update_search);
|
||||||
|
$(window).on("popstate", function(e) {
|
||||||
|
var oe = e.originalEvent;
|
||||||
|
if (oe.state !== null) {
|
||||||
|
console.log("popState:" + JSON.stringify(oe.state));
|
||||||
|
$("#weapon_type").val(oe.state["weapon_type"]);
|
||||||
|
$("#weapon_type").change();
|
||||||
|
show_trees(oe.state["weapon"]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$("#weapon_type").change(function(evt) {
|
||||||
|
update_weapon_autocomplete("#weapon", autocomplete_predicate,
|
||||||
|
update_search);
|
||||||
|
$("#weapon").val("");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function load_qs() {
|
||||||
|
var wtype = $.QueryString["weapon_type"];
|
||||||
|
var weapon = $.QueryString["weapon"];
|
||||||
|
if (!wtype) {
|
||||||
|
wtype = "All";
|
||||||
|
}
|
||||||
|
$("#weapon_type").val(wtype);
|
||||||
|
$("#weapon_type").change();
|
||||||
|
if (weapon) {
|
||||||
|
show_trees(weapon);
|
||||||
|
console.log("replaceState: " + weapon);
|
||||||
|
save_state(get_state(), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_state() {
|
||||||
|
return { "weapon": $("#weapon").val(),
|
||||||
|
"weapon_type": $("#weapon_type").val() };
|
||||||
|
}
|
||||||
|
|
||||||
|
function save_state(state, replace) {
|
||||||
|
var url = "/weaponplanner.html?" + encode_qs(state);
|
||||||
|
if (replace) {
|
||||||
|
window.history.replaceState(state, "", url);
|
||||||
|
} else {
|
||||||
|
window.history.pushState(state, "", url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function autocomplete_predicate(weapon_data) {
|
||||||
|
var weapon_type = $("#weapon_type").val();
|
||||||
|
|
||||||
|
if (weapon_type != "All" && weapon_type != weapon_data["wtype"]) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function update_search() {
|
||||||
|
var weapon_name = $("#weapon").val();
|
||||||
|
|
||||||
|
if (!weapon_name) return;
|
||||||
|
|
||||||
|
if (window.history.state
|
||||||
|
&& window.history.state["weapon"] == weapon_name) {
|
||||||
|
console.log("weapon not changed, skipping update");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
show_trees(weapon_name);
|
||||||
|
console.log("pushState: " + weapon_name);
|
||||||
|
save_state(get_state(), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
function show_trees(weapon_name) {
|
||||||
|
if (!weapon_name) return;
|
||||||
|
weapon_id = WEAPON_NAME_IDX[weapon_name][0];
|
||||||
|
console.log("show_trees(" + weapon_name + "): " + weapon_id);
|
||||||
|
$("#weapon").val(weapon_name);
|
||||||
|
$("#results").html("");
|
||||||
|
$("#weapon_stats").html("");
|
||||||
|
$.getJSON(DATA_PATH + "weapon/" + weapon_id + ".json",
|
||||||
|
function(data) {
|
||||||
|
set_sharpness_titles(data);
|
||||||
|
set_horn_melodies_title(data);
|
||||||
|
var html = template_stats.render(data);
|
||||||
|
$("#weapon_stats").html(html);
|
||||||
|
});
|
||||||
|
|
||||||
|
$.getJSON(DATA_PATH + "weapon/" + weapon_id + "_tree.json",
|
||||||
|
function(data) {
|
||||||
|
// first pass: collect all components and sort them
|
||||||
|
var all_dict = {};
|
||||||
|
for (i=0; i<data.length; i++) {
|
||||||
|
var components = Object.keys(data[i]["components"]);
|
||||||
|
for (j=0; j<components.length; j++) {
|
||||||
|
all_dict[components[j]] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var all_components = Object.keys(all_dict);
|
||||||
|
all_components.sort();
|
||||||
|
// second pass: generate the fieldset for each weapon
|
||||||
|
// path. Note that the template uses all components
|
||||||
|
// to order the components and make them line up
|
||||||
|
for (i=0; i<data.length; i++) {
|
||||||
|
delta = {};
|
||||||
|
path = data[i];
|
||||||
|
components = path["components"]
|
||||||
|
path_string = "";
|
||||||
|
for (j=0; j<path["path"].length; j++) {
|
||||||
|
if (j != 0) {
|
||||||
|
path_string += " -> ";
|
||||||
|
}
|
||||||
|
path_string += path["path"][j]["name"];
|
||||||
|
}
|
||||||
|
path["path_string"] = path_string.replace(/"/g,
|
||||||
|
'"');
|
||||||
|
path["all_components"] = all_components;
|
||||||
|
path["component_list"] = Object.keys(components);
|
||||||
|
if (i > 0) {
|
||||||
|
prev_comps = data[i-1]["components"];
|
||||||
|
$.each(components, function(name, quantity) {
|
||||||
|
if (name in prev_comps) {
|
||||||
|
delta[name] = components[name]
|
||||||
|
- prev_comps[name];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
path["delta"] = delta;
|
||||||
|
path["component_list"].sort();
|
||||||
|
var html = template_path.render(path);
|
||||||
|
$("#results").append(html);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td><label for="weapon_type">Type:</label></td>
|
||||||
|
<td><select id="weapon_type">
|
||||||
|
<option value="All">All</option>
|
||||||
|
<option value="Great Sword">Great Sword</option>
|
||||||
|
<option value="Long Sword">Long Sword</option>
|
||||||
|
<option value="Sword and Shield">Sword and Shield</option>
|
||||||
|
<option value="Dual Blades">Dual Blades</option>
|
||||||
|
<option value="Hammer">Hammer</option>
|
||||||
|
<option value="Hunting Horn">Hunting Horn</option>
|
||||||
|
<option value="Lance">Lance</option>
|
||||||
|
<option value="Gunlance">Gunlance</option>
|
||||||
|
<option value="Switch Axe">Switch Axe</option>
|
||||||
|
<option value="Charge Blade">Charge Blade</option>
|
||||||
|
<option value="Insect Glaive">Insect Glaive</option>
|
||||||
|
<option value="Light Bowgun">Light Bowgun</option>
|
||||||
|
<option value="Heavy Bowgun">Heavy Bowgun</option>
|
||||||
|
<option value="Bow">Bow</option>
|
||||||
|
</select></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><label for="weapon">Weapon:</label></td>
|
||||||
|
<td><input id="weapon" name="weapon" size="20" />
|
||||||
|
<button id="search">Ask Poogie</button></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div id="weapon_stats"></div>
|
||||||
|
<div id="results" class="flexbox"></div>
|
||||||
|
</body>
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Poogie's Weapon List</title>
|
<title>Poogie's Weapon List (MHX)</title>
|
||||||
|
|
||||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user