home · contact · privacy
Add terrain editing access control via passwords.
[plomrogue2] / plomrogue / tasks.py
index 99bb41f516249e81dc3470caa09444e18c21047d..55669eccb85e6f4ae738f566d8c96b9761debe03 100644 (file)
@@ -1,4 +1,4 @@
-from plomrogue.errors import PlayError
+from plomrogue.errors import PlayError, GameError
 from plomrogue.mapping import YX
 
 
@@ -48,10 +48,14 @@ class Task_MOVE(Task):
 
 class Task_WRITE(Task):
     todo = 1
-    argtypes = 'string:char'
+    argtypes = 'string:char string'
 
     def check(self):
-        pass
+        tile_class = self.thing.game.map_control[self.thing.position]
+        if tile_class in self.thing.game.map_control_passwords:
+            tile_pw = self.thing.game.map_control_passwords[tile_class]
+            if self.args[1] != tile_pw:
+                raise GameError('wrong password for tile')
 
     def do(self):
         self.thing.game.map[self.thing.position] = self.args[0]