def cmd_GOD_PLAYER_HAT(game, name, hat):
game.hats[name] = hat
cmd_GOD_PLAYER_HAT.argtypes = 'string string'
+
+def cmd_THING_HAT_DESIGN(game, thing_id, design):
+ if len(design) != 9:
+ raise GameError('hat design of wrong length')
+ t = game.get_thing(thing_id)
+ if not t:
+ raise GameError('thing of ID %s not found' % thing_id)
+ if t.type_ != 'Hat':
+ raise GameError('thing of ID %s not a hat' % thing_id)
+ t.design = design
+cmd_THING_HAT_DESIGN.argtypes = 'int:pos string'
write(f, 'THING_INSTALLED %s' % t.id_)
if t.type_ == 'Door' and t.blocking:
write(f, 'THING_DOOR_CLOSED %s' % t.id_)
+ elif t.type_ == 'Hat':
+ write(f, 'THING_HAT_DESIGN %s %s' % (t.id_,
+ quote(t.design)))
elif t.type_ == 'MusicPlayer':
write(f, 'THING_MUSICPLAYER_SETTINGS %s %s %s %s' %
(t.id_, int(t.playing), t.playlist_index, int(t.repeat)))
import string
msg = msg.replace('\n', ' ') # Inserted by some tablet keyboards.
legal_chars = string.digits + string.ascii_letters +\
- string.punctuation + ' ' + 'ÄäÖöÜüߧ' + 'éèáàô' + '–'
+ string.punctuation + ' ' + 'ÄäÖöÜüߧ' + 'éèáàô' + '–…'
for c in msg:
if not c in legal_chars:
raise ArgError('Command/message contains illegal character(s), '
t.accept()
self.thing.game.things.remove(self.thing.carrying)
break
+ elif self.thing.carrying.type_ == 'Hat':
+ for t in [t for t in self.thing.game.things
+ if t.type_ == 'HatRemixer'
+ and t.position == self.thing.position]:
+ t.accept(self.thing.carrying)
+ break
self.thing.carrying = None
from plomrogue.errors import GameError, PlayError
from plomrogue.mapping import YX
+import random
-class Thing_HatSpawner(ThingSpawner):
- child_type = 'Hat'
+class Thing_HatRemixer(Thing):
+ symbol_hint = 'H'
+ def accept(self, hat):
+ import string
+ new_design = ''
+ legal_chars = string.ascii_letters + string.digits + string.punctuation + ' '
+ for i in range(9):
+ new_design += random.choice(list(legal_chars))
+ hat.design = new_design
+ self.sound('HAT REMIXER', 'remixing a hat …')
def proceed(self):
if self.bottle_counter >= 3:
self.bottle_counter = 0
- t = self.game.thing_types['MusicPlayer'](self.game,
- position=self.position)
+ choice = random.choice(['MusicPlayer', 'Hat'])
+ t = self.game.thing_types[choice](self.game, position=self.position)
self.game.things += [t]
- self.sound('BOTTLE DEPOSITOR',
- 'here is a gift as a reward for ecological consciousness –'
- 'use "command thing" on it to learn more!')
+ msg = 'here is a gift as a reward for ecological consciousness –'
+ if choice == 'MusicPlayer':
+ msg += 'pick it up and then use "command thing" on it!'
+ elif choice == 'Hat':
+ msg += 'pick it up and then use "(un-)wear" on it!'
+ self.sound('BOTTLE DEPOSITOR', msg)
self.game.changed = True
def accept(self):
cmd_GOD_THING_NAME, cmd_THING_DOOR_CLOSED,
cmd_GOD_THING_PROTECTION, cmd_THING_PROTECTION,
cmd_SET_MAP_CONTROL_PASSWORD, cmd_SPAWN_POINT,
- cmd_THING_MUSICPLAYER_SETTINGS,
+ cmd_THING_MUSICPLAYER_SETTINGS, cmd_THING_HAT_DESIGN,
cmd_THING_MUSICPLAYER_PLAYLIST_ITEM,
cmd_THING_BOTTLE_EMPTY, cmd_PLAYER_FACE,
cmd_GOD_PLAYER_FACE, cmd_GOD_PLAYER_HAT)
Thing_SpawnPoint, Thing_SpawnPointSpawner,
Thing_Door, Thing_DoorSpawner, Thing_Bottle,
Thing_BottleSpawner, Thing_BottleDeposit,
- Thing_MusicPlayer, Thing_Hat, Thing_HatSpawner)
+ Thing_MusicPlayer, Thing_Hat, Thing_HatRemixer)
from plomrogue.config import config
game = Game(config['savefile'])
game.register_command(cmd_PLAYER_FACE)
game.register_command(cmd_GOD_PLAYER_FACE)
game.register_command(cmd_GOD_PLAYER_HAT)
+game.register_command(cmd_THING_HAT_DESIGN)
game.register_task(Task_WAIT)
game.register_task(Task_MOVE)
game.register_task(Task_WRITE)
game.register_thing_type(Thing_BottleDeposit)
game.register_thing_type(Thing_MusicPlayer)
game.register_thing_type(Thing_Hat)
-game.register_thing_type(Thing_HatSpawner)
+game.register_thing_type(Thing_HatRemixer)
game.read_savefile()
game.io.start_loop()
for port in config['servers']: