home · contact · privacy
Introduce SpawnPoint things, and their Spawners.
authorChristian Heller <c.heller@plomlompom.de>
Fri, 27 Nov 2020 03:17:00 +0000 (04:17 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Fri, 27 Nov 2020 03:17:00 +0000 (04:17 +0100)
plomrogue/commands.py
plomrogue/things.py
rogue_chat.py

index 3a10a4c24e182aa6b72dd6a41ac575bcb2664d0e..6532b72bbe027ebb65d0805025140a49da8145d4 100644 (file)
@@ -88,6 +88,10 @@ def cmd_LOGIN(game, nick, connection_id):
     t.name = nick
     game.io.send('CHAT ' + quote(t.name + ' entered the map.'))
     game.io.send('PLAYER_ID %s' % t.id_, connection_id)
+    for s in [s for s in game.things
+              if s.type_ == 'SpawnPoint' and s.name == t.name]:
+        t.position = s.position
+        break
     game.changed = True
 cmd_LOGIN.argtypes = 'string'
 
index 98dff00dbb40868e2af8d2beb35e85fdfda2d23c..fe7d57ef3229265ab50ebb64465b6d48b6631a13 100644 (file)
@@ -43,19 +43,37 @@ class Thing_Item(Thing):
 
 
 
-class Thing_ItemSpawner(Thing):
+class ThingSpawner(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)
+        t = self.game.thing_types[self.child_type](self.game,
+                                                   position=self.position)
         self.game.things += [t]
         self.game.changed = True
 
 
 
+class Thing_ItemSpawner(ThingSpawner):
+    child_type = 'Item'
+
+
+
+class Thing_SpawnPointSpawner(ThingSpawner):
+    child_type = 'SpawnPoint'
+
+
+
+class Thing_SpawnPoint(Thing):
+    symbol_hint = 's'
+    portable = True
+    name = ' '
+
+
+
 class ThingAnimate(Thing):
     blocking = True
 
index 1f9228faf01763226c8bd0af09ed5bf226bf0669..3ace6307ed4b777764c3d099983d96cb0f4dab61 100755 (executable)
@@ -12,7 +12,8 @@ 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, Thing_ItemSpawner
+from plomrogue.things import (Thing_Player, Thing_Item, Thing_ItemSpawner,
+                              Thing_SpawnPoint, Thing_SpawnPointSpawner)
 
 from plomrogue.config import config
 game = Game(config['savefile'])
@@ -53,6 +54,8 @@ game.register_task(Task_DROP)
 game.register_thing_type(Thing_Player)
 game.register_thing_type(Thing_Item)
 game.register_thing_type(Thing_ItemSpawner)
+game.register_thing_type(Thing_SpawnPoint)
+game.register_thing_type(Thing_SpawnPointSpawner)
 game.read_savefile()
 game.io.start_loop()
 for port in config['servers']: