+ self.mods = {}
+ self.upgrades = {"attrs":None, "mods":None}
+
+ def is_compatible(self, other):
+ return self.kind==other.kind
+
+ def compare_mods(self, other):
+ result = 0
+ for n, v in self.mods.items():
+ ov = other.mods.get(n, 0)
+ if v<ov:
+ return -1
+ elif v>ov:
+ result = 1
+
+ for on, ov in other.mods.items():
+ v = self.mods.get(on, 0)
+ if v<ov:
+ return -1
+ elif v>ov:
+ result = 1
+
+ return result
+
+ def compare_attrs(self, other):
+ return 0
+
+ def check_upgrade(self, other):
+ 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
+ if not other.upgrades["attrs"]:
+ if attrs>0 or (attrs==0 and mods>0):
+ other.upgrades["attrs"] = self