add weapon tree compare tool
This commit is contained in:
29
mhapi/db.py
29
mhapi/db.py
@@ -290,20 +290,31 @@ class MHDB(object):
|
||||
LEFT JOIN items ON weapons._id = items._id
|
||||
""", model_cls=model.Weapon)
|
||||
|
||||
def get_weapon(self, weapon_id):
|
||||
return self._query_one("weapon", """
|
||||
def _add_components(self, item_data):
|
||||
ccomps = self.get_item_components(item_data.id, "Create")
|
||||
ucomps = self.get_item_components(item_data.id, "Improve")
|
||||
item_data.set_components(ccomps, ucomps)
|
||||
|
||||
def get_weapon(self, weapon_id, get_components=False):
|
||||
weapon = self._query_one("weapon", """
|
||||
SELECT * FROM weapons
|
||||
LEFT JOIN items ON weapons._id = items._id
|
||||
WHERE weapons._id=?
|
||||
""", (weapon_id,), model_cls=model.Weapon)
|
||||
if weapon and get_components:
|
||||
self._add_components(weapon)
|
||||
return weapon
|
||||
|
||||
def get_weapon_by_name(self, name):
|
||||
return self._query_one("weapon", """
|
||||
def get_weapon_by_name(self, name, get_components=False):
|
||||
weapon = self._query_one("weapon", """
|
||||
SELECT items._id, items.name, items.buy, weapons.*
|
||||
FROM weapons
|
||||
LEFT JOIN items ON weapons._id = items._id
|
||||
WHERE items.name=?
|
||||
""", (name,), model_cls=model.Weapon)
|
||||
if weapon and get_components:
|
||||
self._add_components(weapon)
|
||||
return weapon
|
||||
|
||||
def get_armors(self):
|
||||
return self._query_all("armors", """
|
||||
@@ -427,3 +438,13 @@ class MHDB(object):
|
||||
WHERE monster_id=?
|
||||
AND (condition LIKE 'Break %' OR condition = 'Tail Carve')
|
||||
""", (monster_id,), model_cls=model)
|
||||
|
||||
def get_item_components(self, item_id, method="Create"):
|
||||
return self._query_all("item_components", """
|
||||
SELECT items._id, items.name, items.type,
|
||||
components.quantity, components.type AS method
|
||||
FROM components
|
||||
LEFT JOIN items
|
||||
ON items._id = components.component_item_id
|
||||
WHERE created_item_id=? AND components.type=?
|
||||
""", (item_id, method), model_cls=model.ItemComponent)
|
||||
|
||||
@@ -152,13 +152,14 @@ class SharpnessLevel(EnumBase):
|
||||
PURPLE: "Purple",
|
||||
}
|
||||
|
||||
# source: http://kiranico.com/en/mh4u/wiki/weapons
|
||||
_modifier = {
|
||||
RED: (0.50, 0.25),
|
||||
ORANGE: (0.75, 0.50),
|
||||
YELLOW: (1.00, 0.75),
|
||||
GREEN: (1.05, 1.00),
|
||||
BLUE: (1.20, 1.06),
|
||||
WHITE: (1.32, 1.12),
|
||||
GREEN: (1.125, 1.00),
|
||||
BLUE: (1.25, 1.0625),
|
||||
WHITE: (1.32, 1.125),
|
||||
PURPLE: (1.44, 1.20),
|
||||
}
|
||||
|
||||
@@ -303,13 +304,19 @@ class SkillTree(RowModel):
|
||||
|
||||
class Weapon(RowModel):
|
||||
_list_fields = ["id", "wtype", "name"]
|
||||
_indexes = { "name": ["id"],
|
||||
_indexes = { "name": "id",
|
||||
"wtype": ["id", "name"] }
|
||||
|
||||
def __init__(self, weapon_item_row):
|
||||
super(Weapon, self).__init__(weapon_item_row)
|
||||
|
||||
self._parse_sharpness()
|
||||
self.create_components = []
|
||||
self.upgrade_components = []
|
||||
|
||||
def set_components(self, create_components, upgrade_components):
|
||||
self.create_components = create_components
|
||||
self.upgrade_components = upgrade_components
|
||||
|
||||
def _parse_sharpness(self):
|
||||
"""
|
||||
@@ -327,6 +334,17 @@ class Weapon(RowModel):
|
||||
self._data["sharpness"] = WeaponSharpness(normal)
|
||||
self._data["sharpness_plus"] = WeaponSharpness(plus)
|
||||
|
||||
def as_data(self):
|
||||
data = super(Weapon, self).as_data()
|
||||
if self.create_components is not None:
|
||||
data["create_components"] = dict((item.name, item.quantity)
|
||||
for item in self.create_components)
|
||||
if self.upgrade_components is not None:
|
||||
data["upgrade_components"] = dict((item.name, item.quantity)
|
||||
for item in self.upgrade_components)
|
||||
return data
|
||||
|
||||
|
||||
|
||||
class Monster(RowModel):
|
||||
_list_fields = ["id", "class", "name"]
|
||||
@@ -338,6 +356,12 @@ class Item(RowModel):
|
||||
"type": ["id", "name"] }
|
||||
|
||||
|
||||
class ItemComponent(RowModel):
|
||||
_list_fields = ["id", "name"]
|
||||
_indexes = { "method": ["id", "name"] }
|
||||
|
||||
|
||||
|
||||
class Location(RowModel):
|
||||
pass
|
||||
|
||||
|
||||
Reference in New Issue
Block a user