home · contact · privacy
Add Thing spawner.
authorChristian Heller <c.heller@plomlompom.de>
Fri, 27 Nov 2020 01:05:57 +0000 (02:05 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Fri, 27 Nov 2020 01:05:57 +0000 (02:05 +0100)
plomrogue/tasks.py
plomrogue/things.py
rogue_chat.py

index 558b1782f3067b70ca033dd2e3426578a8425772..a7bcf3772a4ab8f5e0351d63bb1da6f0e86c2f52 100644 (file)
@@ -87,7 +87,8 @@ class Task_PICK_UP(Task):
             raise PlayError('already carrying something')
         nothing_to_pick_up = True
         for t in [t for t in self.thing.game.things
-                  if t != self.thing and t.position == self.thing.position and
+                  if t.portable
+                  and t != self.thing and t.position == self.thing.position and
                   t.type_ != 'Player']:
             nothing_to_pick_up = False
             break
@@ -96,7 +97,8 @@ class Task_PICK_UP(Task):
 
     def do(self):
         to_pick_up = [t for t in self.thing.game.things
-                      if t != self.thing and t.position == self.thing.position][0]
+                      if t.portable
+                      and t != self.thing and t.position == self.thing.position][0]
         self.thing.carrying = to_pick_up
 
 
index 1618ee65e49c07493fc2cc67f87a22045f4b998c..ca53e87dd057056e655c07df0141c3f27ede3141 100644 (file)
@@ -18,6 +18,7 @@ class ThingBase:
 
 class Thing(ThingBase):
     blocking = False
+    portable = False
     protection = '.'
 
     def __init__(self, *args, **kwargs):
@@ -38,6 +39,20 @@ class Thing(ThingBase):
 
 class Thing_Item(Thing):
     symbol_hint = 'i'
+    portable = True
+
+
+
+class Thing_Spawner(Thing):
+    symbol_hint = 'S'
+
+    def proceed(self):
+        for t in [t for t in self.game.things
+                  if t != self and t.position == self.position]:
+            return
+        t = self.game.thing_types['Item'](self.game, position=self.position)
+        self.game.things += [t]
+        self.game.changed = True
 
 
 
index 5c5e657d149faae4625bce198e8a6cc1f12527db..1d9e4cbddd1189b426964a6fadcc94048e3a9c65 100755 (executable)
@@ -12,7 +12,7 @@ from plomrogue.commands import (cmd_ALL, cmd_LOGIN, cmd_NICK, cmd_PING, cmd_THIN
                                 cmd_SET_MAP_CONTROL_PASSWORD, cmd_SPAWN_POINT)
 from plomrogue.tasks import (Task_WAIT, Task_MOVE, Task_WRITE, Task_PICK_UP,
                              Task_DROP, Task_FLATTEN_SURROUNDINGS)
-from plomrogue.things import Thing_Player, Thing_Item
+from plomrogue.things import Thing_Player, Thing_Item, Thing_Spawner
 
 from plomrogue.config import config
 game = Game(config['savefile'])
@@ -52,6 +52,7 @@ game.register_task(Task_PICK_UP)
 game.register_task(Task_DROP)
 game.register_thing_type(Thing_Player)
 game.register_thing_type(Thing_Item)
+game.register_thing_type(Thing_Spawner)
 game.read_savefile()
 game.io.start_loop()
 for port in config['servers']: