Update the menu.
[koperkapel.git] / koperkapel / world.py
index befc1a0a6b6d22ac51c9a46133a01309315c42ae..7115194c87e57d6cc299eda89850714172615126 100644 (file)
@@ -80,7 +80,7 @@ class World:
         roach.update(kw)
         return roach
 
-    def _apply_set(self, updates):
+    def _apply_set(self, action, updates):
         for name, value in updates.items():
             parts = name.split(".")
             obj = self._state
@@ -93,6 +93,12 @@ class World:
                     raise KeyError("%r not found in world" % (name,))
             obj[parts[-1]] = value
 
+    def _apply_reset(self, action):
+        self._state = self._build_initial_state()
+
+    def _apply_unknown(self, action, *args, **kw):
+        raise ValueError("Unknown world event action: %r" % (action,))
+
     def proxy(self):
         return WorldDictProxy(self._state)
 
@@ -105,9 +111,8 @@ class World:
                 break
 
     def apply_event(self, action, *args, **kw):
-        if action == "set":
-            return self._apply_set(*args, **kw)
-        raise ValueError("Unknown world event action: %r" % (action,))
+        handler = getattr(self, "_apply_%s" % (action,))
+        return handler(action, *args, **kw)
 
 
 def _maybe_subproxy(proxy, name, value):