diff --git a/bin/mhdamage.py b/bin/mhdamage.py
index dd2c081..38bfeab 100755
--- a/bin/mhdamage.py
+++ b/bin/mhdamage.py
@@ -178,6 +178,9 @@ def parse_args(argv):
parser.add_argument("-x", "--monster-hunter-cross", action="store_true",
default=False,
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="*",
help="WEAPON_TYPE,ELEMENT_OR_STATUS_OR_RAW"
+" 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__':
args = parse_args(None)
+ game_uses_true_raw = False
if args.monster_hunter_cross:
db = MHDBX()
+ game_uses_true_raw = True
+ elif args.monster_hunter_gen:
+ db = MHDB(game="gen")
+ game_uses_true_raw = True
else:
- db = MHDB()
+ db = MHDB(game="4u")
motiondb = MotionValueDB(_pathfix.motion_values_path)
monster = db.get_monster_by_name(args.monster)
@@ -409,7 +417,7 @@ if __name__ == '__main__':
artillery_level=skill_args.artillery,
limit_parts=args.parts,
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)
print "%-20s: %4.0f %2.0f%%" % (name, wd.attack, wd.affinity),
if wd.etype:
diff --git a/bin/mkjsonapi.py b/bin/mkjsonapi.py
index 87b9c58..23da1f2 100755
--- a/bin/mkjsonapi.py
+++ b/bin/mkjsonapi.py
@@ -174,8 +174,8 @@ def weapon_json(db, path):
mkdirs_p(path)
write_list_file(path, weapons)
+ all_data = []
melodies = {}
-
indexes = {}
for w in weapons:
weapon_path = file_path(path, w)
@@ -193,6 +193,8 @@ def weapon_json(db, path):
]
data["horn_melodies"] = melodies[w.horn_notes]
+ all_data.append(data)
+
with open(weapon_path, "w") as f:
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)
write_index_file(path, indexes)
+ write_all_file(path, all_data)
def item_json(db, path):
diff --git a/db/mhgen.db b/db/mhgen.db
new file mode 100644
index 0000000..61a651b
Binary files /dev/null and b/db/mhgen.db differ
diff --git a/mhapi/db.py b/mhapi/db.py
index d9d4f4f..dcbe447 100644
--- a/mhapi/db.py
+++ b/mhapi/db.py
@@ -2,7 +2,7 @@
Module for accessing the sqlite monster hunter db from
"""
-import os.path
+import os
import sqlite3
import json
@@ -19,10 +19,10 @@ def field_model(key):
return model_fn
-def _db_path():
+def _db_path(game=None):
module_path = os.path.dirname(__file__)
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):
@@ -46,7 +46,7 @@ class MHDB(object):
# sell has the a value, but not used at the moment
_decoration_select = """
- SELECT items._id, items.type, items.name, items.name_jp,
+ SELECT items._id, items.type, items.name,
items.rarity, decorations.*
FROM decorations
LEFT JOIN items ON decorations._id = items._id
@@ -54,13 +54,13 @@ class MHDB(object):
# buy has the armor cost, sell is empty
_armor_select = """
- SELECT items._id, items.type, items.name, items.name_jp,
+ SELECT items._id, items.type, items.name,
items.rarity, items.buy, armor.*
FROM armor
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):
"""
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
cases.
"""
+ if game is None:
+ game = os.environ.get("MHAPI_GAME")
+ assert game in ("4u", "gen")
+ self.game = game
if path is None:
- path = _db_path()
+ path = _db_path(game)
self.conn = sqlite3.connect(path)
self.conn.row_factory = sqlite3.Row
self.use_cache = use_cache
@@ -315,9 +319,10 @@ class MHDB(object):
def get_weapons(self):
# Note: weapons only available via JP DLC have no localized
# name, filter them out.
- return self._query_all("weapons", MHDB._weapon_select + """
- WHERE items.name != items.name_jp""",
- model_cls=model.Weapon)
+ q = MHDB._weapon_select
+ if self.game == "4u":
+ 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,
final=None):
@@ -329,7 +334,11 @@ class MHDB(object):
@final should be string '1' or '0'
"""
q = MHDB._weapon_select
- where = ["items.name != items.name_jp"]
+ if self.game == "4u":
+ # filter out non-localized japanese DLC
+ where = ["items.name != items.name_jp"]
+ else:
+ where = []
args = []
if wtype is not None:
where.append("wtype = ?")
@@ -365,8 +374,7 @@ class MHDB(object):
""", (parent_id,), model_cls=model.Weapon)
def get_armors(self):
- return self._query_all("armors", MHDB._armor_select + """
- WHERE items.name != items.name_jp""",
+ return self._query_all("armors", MHDB._armor_select,
model_cls=model.Armor)
def get_armor(self, armor_id):
@@ -404,7 +412,7 @@ class MHDB(object):
def get_skill_trees(self):
return self._query_all("skill_trees", """
- SELECT _id, name, name_jp FROM skill_trees
+ SELECT _id, name FROM skill_trees
""", model_cls=model.SkillTree)
def get_skill_tree_id(self, skill_tree_name):
@@ -419,7 +427,7 @@ class MHDB(object):
def get_skills(self):
return self._query_all("skills", """
SELECT _id, skill_tree_id, required_skill_tree_points,
- name, name_jp, description
+ name, description
FROM skills
""", 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.point_value > 0
AND armor.hunter_type IN ('Both', ?)
- AND items.name != items.name_jp
GROUP BY item_to_skill_tree.item_id
""" % placeholders, tuple(args), model_cls=model.Armor)
diff --git a/mhapi/model.py b/mhapi/model.py
index 8ce53c4..b8122f3 100644
--- a/mhapi/model.py
+++ b/mhapi/model.py
@@ -192,6 +192,10 @@ class WeaponSharpness(ModelBase):
self.value_list = db_string_or_list
else:
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
@property
@@ -210,7 +214,7 @@ class WeaponSharpness(ModelBase):
class ItemCraftable(RowModel):
- _list_fields = ["id", "name", "name_jp"]
+ _list_fields = ["id", "name"]
def __init__(self, item_row):
super(ItemCraftable, self).__init__(item_row)
@@ -320,7 +324,7 @@ class ItemSkill(RowModel):
class SkillTree(RowModel):
- _list_fields = ["id", "name", "name_jp"]
+ _list_fields = ["id", "name"]
def __init__(self, skill_tree_row):
super(SkillTree, self).__init__(skill_tree_row)
@@ -343,7 +347,7 @@ class SkillTree(RowModel):
class Skill(RowModel):
- _list_fields = ["id", "name", "name_jp"]
+ _list_fields = ["id", "name"]
_indexes = { "skill_tree_id":
["id", "required_skill_tree_points", "name", "description"] }
@@ -386,26 +390,30 @@ class Weapon(ItemCraftable):
self.sharpness_plus2 = WeaponSharpness(
self._row["sharpness_plus2"] + [0])
else:
- # 4U data from db
+ # 4U or gen data from db
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'"
% self._row["sharpness"])
- normal, plus = parts
self._data["sharpness"] = WeaponSharpness(normal)
self._data["sharpness_plus"] = WeaponSharpness(plus)
- self._data["sharpness_plus2"] = WeaponSharpness(plus)
+ self._data["sharpness_plus2"] = WeaponSharpness(plus2)
def is_not_localized(self):
return (self.name == self.name_jp)
class Monster(RowModel):
- _list_fields = ["id", "class", "name", "name_jp"]
+ _list_fields = ["id", "class", "name"]
class Item(RowModel):
- _list_fields = ["id", "type", "name", "name_jp"]
+ _list_fields = ["id", "type", "name"]
_indexes = { "name": ["id"],
"type": ["id", "name"] }
diff --git a/web/mhgen/weaponlist.html b/web/mhgen/weaponlist.html
new file mode 100644
index 0000000..aee68a9
--- /dev/null
+++ b/web/mhgen/weaponlist.html
@@ -0,0 +1,337 @@
+
+
+ Poogie's Weapon List (MHGen)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/web/mhgen/weaponplanner.html b/web/mhgen/weaponplanner.html
new file mode 100644
index 0000000..15e520f
--- /dev/null
+++ b/web/mhgen/weaponplanner.html
@@ -0,0 +1,267 @@
+
+
+ Poogie's Weapon Planner
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/web/mhx/weaponlist.html b/web/mhx/weaponlist.html
index 85792a9..dfb3ce1 100644
--- a/web/mhx/weaponlist.html
+++ b/web/mhx/weaponlist.html
@@ -1,6 +1,6 @@
- Poogie's Weapon List
+ Poogie's Weapon List (MHX)