handle wyporium items by listing trade item data
This commit is contained in:
@@ -8,7 +8,7 @@ import sqlite3
|
|||||||
|
|
||||||
|
|
||||||
class Quest(object):
|
class Quest(object):
|
||||||
def __init__(self, quest_row, quest_rewards):
|
def __init__(self, quest_row, quest_rewards=None):
|
||||||
self._row = quest_row
|
self._row = quest_row
|
||||||
self.rewards = quest_rewards
|
self.rewards = quest_rewards
|
||||||
|
|
||||||
@@ -87,6 +87,13 @@ class MHDB(object):
|
|||||||
""", name)
|
""", name)
|
||||||
return v[0] if v else None
|
return v[0] if v else None
|
||||||
|
|
||||||
|
def get_wyporium_trade(self, item_id):
|
||||||
|
v = self._get_memoized("wyporium", """
|
||||||
|
SELECT * FROM wyporium
|
||||||
|
WHERE item_in_id=?
|
||||||
|
""", item_id)
|
||||||
|
return v[0] if v else None
|
||||||
|
|
||||||
def search_item_name(self, term, item_type):
|
def search_item_name(self, term, item_type):
|
||||||
"""
|
"""
|
||||||
Search for items containing @term somewhere in the name. Returns
|
Search for items containing @term somewhere in the name. Returns
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ from __future__ import print_function
|
|||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
from mhapi import stats
|
from mhapi import stats
|
||||||
|
from mhapi.db import Quest
|
||||||
|
|
||||||
SKILL_CARVING = "carving"
|
SKILL_CARVING = "carving"
|
||||||
SKILL_CAP = "cap"
|
SKILL_CAP = "cap"
|
||||||
@@ -497,6 +498,19 @@ class ItemRewards(object):
|
|||||||
self.item_row = item_row
|
self.item_row = item_row
|
||||||
self.item_id = item_row["_id"]
|
self.item_id = item_row["_id"]
|
||||||
|
|
||||||
|
wyp_row = db.get_wyporium_trade(self.item_id)
|
||||||
|
if wyp_row is not None:
|
||||||
|
self.trade_unlock_quest = Quest(
|
||||||
|
db.get_quest(wyp_row["unlock_quest_id"]))
|
||||||
|
self.trade_item_row = self.item_row
|
||||||
|
self.trade_item_id = self.item_id
|
||||||
|
self.item_id = wyp_row["item_out_id"]
|
||||||
|
self.item_row = db.get_item(wyp_row["item_out_id"])
|
||||||
|
else:
|
||||||
|
self.trade_item_row = None
|
||||||
|
self.trade_item_id = None
|
||||||
|
self.trade_unlock_quest = None
|
||||||
|
|
||||||
self.rank_skill_sets = OrderedDict()
|
self.rank_skill_sets = OrderedDict()
|
||||||
for rank in "G HR LR".split():
|
for rank in "G HR LR".split():
|
||||||
self.rank_skill_sets[rank] = OrderedDict([
|
self.rank_skill_sets[rank] = OrderedDict([
|
||||||
@@ -664,9 +678,16 @@ class ItemRewards(object):
|
|||||||
|
|
||||||
def print_all(self, out):
|
def print_all(self, out):
|
||||||
if self.is_empty():
|
if self.is_empty():
|
||||||
# TODO: this happens for Wymporium tradeable monster parts.
|
|
||||||
out.write("ERROR: data for this item is not yet available\n")
|
out.write("ERROR: data for this item is not yet available\n")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if self.trade_unlock_quest:
|
||||||
|
item_name = self.item_row["name"]
|
||||||
|
out.write("*** Wyporium trade for '%s'\n" % item_name)
|
||||||
|
out.write(" Unlocked by quest '%s'\n"
|
||||||
|
% unicode(self.trade_unlock_quest).split("\n")[0])
|
||||||
|
out.write("\n")
|
||||||
|
|
||||||
self.print_recommended_hunts(out)
|
self.print_recommended_hunts(out)
|
||||||
self.print_monsters(out)
|
self.print_monsters(out)
|
||||||
self.print_quests(out)
|
self.print_quests(out)
|
||||||
|
|||||||
Reference in New Issue
Block a user