From 9316d59ddce7a7b8ee70d2b4e111330f1a691e37 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Fri, 27 Nov 2020 04:17:00 +0100 Subject: [PATCH] Introduce SpawnPoint things, and their Spawners. --- plomrogue/commands.py | 4 ++++ plomrogue/things.py | 22 ++++++++++++++++++++-- rogue_chat.py | 5 ++++- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/plomrogue/commands.py b/plomrogue/commands.py index 3a10a4c..6532b72 100644 --- a/plomrogue/commands.py +++ b/plomrogue/commands.py @@ -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' diff --git a/plomrogue/things.py b/plomrogue/things.py index 98dff00..fe7d57e 100644 --- a/plomrogue/things.py +++ b/plomrogue/things.py @@ -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 diff --git a/rogue_chat.py b/rogue_chat.py index 1f9228f..3ace630 100755 --- a/rogue_chat.py +++ b/rogue_chat.py @@ -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']: -- 2.30.2