From 85dc27df729642f07962068abfdd7dfc006da73c Mon Sep 17 00:00:00 2001 From: Bryce Allen Date: Sat, 28 Mar 2015 17:51:15 -0500 Subject: [PATCH] add error for items with no reward data --- bin/genrewards.py | 4 +--- bin/mhrewards.py | 4 +--- mhapi/rewards.py | 12 ++++++++++++ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/bin/genrewards.py b/bin/genrewards.py index e1f5b8f..0a7385f 100755 --- a/bin/genrewards.py +++ b/bin/genrewards.py @@ -64,6 +64,4 @@ if __name__ == '__main__': if item_row is None: sys.exit(os.EX_DATAERR) ir = rewards.ItemRewards(db, item_row) - ir.print_recommended_hunts(out) - ir.print_monsters(out) - ir.print_quests(out) + ir.print_all(out) diff --git a/bin/mhrewards.py b/bin/mhrewards.py index ed8beb6..9cf4ed1 100755 --- a/bin/mhrewards.py +++ b/bin/mhrewards.py @@ -35,6 +35,4 @@ if __name__ == '__main__': if item_row is None: sys.exit(os.EX_DATAERR) ir = rewards.ItemRewards(db, item_row) - ir.print_recommended_hunts(out) - ir.print_monsters(out) - ir.print_quests(out) + ir.print_all(out) diff --git a/mhapi/rewards.py b/mhapi/rewards.py index 9043004..9f8666a 100644 --- a/mhapi/rewards.py +++ b/mhapi/rewards.py @@ -519,6 +519,9 @@ class ItemRewards(object): self._find_hunt_items() self._find_quest_items() + def is_empty(self): + return (not self._hunt_items and not self._quest_items) + def _find_hunt_items(self): monsters = self.db.get_item_monsters(self.item_id) @@ -658,3 +661,12 @@ class ItemRewards(object): if shiny_ev: out.write(" %20s %5.2f / 100\n" % ("Shiny", shiny_ev)) out.write("\n") + + def print_all(self, out): + if self.is_empty(): + # TODO: this happens for Wymporium tradeable monster parts. + out.write("ERROR: data for this item is not yet available\n") + return + self.print_recommended_hunts(out) + self.print_monsters(out) + self.print_quests(out)