def undo(self, mod: modules.Module): props = mod.get_exposed_props() if self.before and self.before.keys() == props.keys() \ and props() == self.after: mod.set_exposed_props(self.before) return mod else: print("tried to undo, but the target props are", self.before, "while the current are", props) return None
def do(self, mod: modules.Module, pos: base.Vec2d) -> modules.Module: self.pos = pos self.before = mod_props = mod.get_exposed_props() for name, change in self.changes.items(): if name in mod_props and self.type_test(change): mod_props[name] = change else: return mod self.after = mod_props mod.set_exposed_props(mod_props) return mod