From: Christian Heller Date: Fri, 27 Nov 2020 01:05:57 +0000 (+0100) Subject: Add Thing spawner. X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/%7B%7B%20web_path%20%7D%7D/pick_tasks?a=commitdiff_plain;h=80b6be9545812304bed7cf2a25434ef5f08a25c3;p=plomrogue2 Add Thing spawner. --- diff --git a/plomrogue/tasks.py b/plomrogue/tasks.py index 558b178..a7bcf37 100644 --- a/plomrogue/tasks.py +++ b/plomrogue/tasks.py @@ -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 diff --git a/plomrogue/things.py b/plomrogue/things.py index 1618ee6..ca53e87 100644 --- a/plomrogue/things.py +++ b/plomrogue/things.py @@ -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 diff --git a/rogue_chat.py b/rogue_chat.py index 5c5e657..1d9e4cb 100755 --- a/rogue_chat.py +++ b/rogue_chat.py @@ -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']: