]> git.tdb.fi Git - poefilter.git/commitdiff
Allow lower level items to be considered as upgrades
authorMikko Rasa <tdb@tdb.fi>
Thu, 16 Aug 2018 14:45:00 +0000 (17:45 +0300)
committerMikko Rasa <tdb@tdb.fi>
Thu, 16 Aug 2018 14:45:00 +0000 (17:45 +0300)
But only if it doesn't downgrade anything

scrape-item-data.py

index f5f67b488593515d4b708d3d30351d5df0cd9170..ab8bc097d4ecc8383cddf993a2abf378bb3a824f 100755 (executable)
@@ -38,14 +38,15 @@ class Item:
                return 0
 
        def check_upgrade(self, other):
-               if self.droplevel<=other.droplevel:
-                       return
                if not self.is_compatible(other):
                        return
 
                mods = self.compare_mods(other)
                attrs = self.compare_attrs(other)
 
+               if self.droplevel<other.droplevel and (mods<0 or attrs<0):
+                       return
+
                if not other.upgrades["mods"]:
                        if mods>0 or (mods==0 and attrs>0):
                                other.upgrades["mods"] = self
@@ -150,6 +151,10 @@ class ItemDataParser(html.parser.HTMLParser):
                                        self.current_item.check_upgrade(it)
                elif tag=="h1":
                        self.in_heading = False
+               elif tag=="html":
+                       for i in range(1, len(self.items)):
+                               for j in range(i):
+                                       self.items[j].check_upgrade(self.items[i])
 
        def handle_data(self, data):
                data = data.strip()