home
·
contact
·
privacy
projects
/
plomrogue2
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
ed297e4
)
Spawn hats from BottleDeposit, add HatRemixer.
author
Christian Heller
<c.heller@plomlompom.de>
Mon, 7 Dec 2020 05:35:27 +0000
(06:35 +0100)
committer
Christian Heller
<c.heller@plomlompom.de>
Mon, 7 Dec 2020 05:35:27 +0000
(06:35 +0100)
plomrogue/commands.py
patch
|
blob
|
history
plomrogue/game.py
patch
|
blob
|
history
plomrogue/parser.py
patch
|
blob
|
history
plomrogue/tasks.py
patch
|
blob
|
history
plomrogue/things.py
patch
|
blob
|
history
rogue_chat.py
patch
|
blob
|
history
diff --git
a/plomrogue/commands.py
b/plomrogue/commands.py
index 0228c69de5cede80930cb3104d8e14bf9df53073..a36f9e6a5a8cc51a6aee35118f2b909dd9f305cd 100644
(file)
--- a/
plomrogue/commands.py
+++ b/
plomrogue/commands.py
@@
-331,3
+331,14
@@
cmd_GOD_PLAYER_FACE.argtypes = 'string string'
def cmd_GOD_PLAYER_HAT(game, name, hat):
game.hats[name] = hat
cmd_GOD_PLAYER_HAT.argtypes = 'string string'
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'
diff --git
a/plomrogue/game.py
b/plomrogue/game.py
index 0fc486796232a1e5c95f102847e5ea59147eb2ba..5e206b9c8c289155a59aa7700dd9306ea4e05e79 100755
(executable)
--- a/
plomrogue/game.py
+++ b/
plomrogue/game.py
@@
-403,6
+403,9
@@
class Game(GameBase):
write(f, 'THING_INSTALLED %s' % t.id_)
if t.type_ == 'Door' and t.blocking:
write(f, 'THING_DOOR_CLOSED %s' % t.id_)
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)))
elif t.type_ == 'MusicPlayer':
write(f, 'THING_MUSICPLAYER_SETTINGS %s %s %s %s' %
(t.id_, int(t.playing), t.playlist_index, int(t.repeat)))
diff --git
a/plomrogue/parser.py
b/plomrogue/parser.py
index 140637b468aea0982462a9e3a697690ee24c676d..302733d0322a69c9592276b94239b626debcb4c3 100644
(file)
--- a/
plomrogue/parser.py
+++ b/
plomrogue/parser.py
@@
-84,7
+84,7
@@
class Parser:
import string
msg = msg.replace('\n', ' ') # Inserted by some tablet keyboards.
legal_chars = string.digits + string.ascii_letters +\
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), '
for c in msg:
if not c in legal_chars:
raise ArgError('Command/message contains illegal character(s), '
diff --git
a/plomrogue/tasks.py
b/plomrogue/tasks.py
index 9fccbc33450f2c50fe5caf6269d0ba171bc7e644..8337132f58f77450df3d27e5a20f155d9692b407 100644
(file)
--- a/
plomrogue/tasks.py
+++ b/
plomrogue/tasks.py
@@
-122,6
+122,12
@@
class Task_DROP(Task):
t.accept()
self.thing.game.things.remove(self.thing.carrying)
break
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
self.thing.carrying = None
diff --git
a/plomrogue/things.py
b/plomrogue/things.py
index 2c12cf283e41cc5b788d37c35d1fabe23225ba17..32d7854732029bd0fc2ef2946dae9ecaebf006d7 100644
(file)
--- a/
plomrogue/things.py
+++ b/
plomrogue/things.py
@@
-1,5
+1,6
@@
from plomrogue.errors import GameError, PlayError
from plomrogue.mapping import YX
from plomrogue.errors import GameError, PlayError
from plomrogue.mapping import YX
+import random
@@
-170,9
+171,17
@@
class Thing_Hat(Thing):
-class Thing_Hat
Spawner(ThingSpawner
):
-
child_type = 'Hat
'
+class Thing_Hat
Remixer(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 …')
@@
-289,12
+298,15
@@
class Thing_BottleDeposit(Thing):
def proceed(self):
if self.bottle_counter >= 3:
self.bottle_counter = 0
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.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):
self.game.changed = True
def accept(self):
diff --git
a/rogue_chat.py
b/rogue_chat.py
index 7882013af3f539838648e373f105ce66178e3bc8..8e4fd1bc366c8a2fc0acb2c6e0a081e7dd633e13 100755
(executable)
--- a/
rogue_chat.py
+++ b/
rogue_chat.py
@@
-10,7
+10,7
@@
from plomrogue.commands import (cmd_ALL, cmd_LOGIN, cmd_NICK, cmd_PING, cmd_THIN
cmd_GOD_THING_NAME, cmd_THING_DOOR_CLOSED,
cmd_GOD_THING_PROTECTION, cmd_THING_PROTECTION,
cmd_SET_MAP_CONTROL_PASSWORD, cmd_SPAWN_POINT,
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)
cmd_THING_MUSICPLAYER_PLAYLIST_ITEM,
cmd_THING_BOTTLE_EMPTY, cmd_PLAYER_FACE,
cmd_GOD_PLAYER_FACE, cmd_GOD_PLAYER_HAT)
@@
-22,7
+22,7
@@
from plomrogue.things import (Thing_Player, Thing_Item, Thing_ItemSpawner,
Thing_SpawnPoint, Thing_SpawnPointSpawner,
Thing_Door, Thing_DoorSpawner, Thing_Bottle,
Thing_BottleSpawner, Thing_BottleDeposit,
Thing_SpawnPoint, Thing_SpawnPointSpawner,
Thing_Door, Thing_DoorSpawner, Thing_Bottle,
Thing_BottleSpawner, Thing_BottleDeposit,
- Thing_MusicPlayer, Thing_Hat, Thing_Hat
Spawn
er)
+ Thing_MusicPlayer, Thing_Hat, Thing_Hat
Remix
er)
from plomrogue.config import config
game = Game(config['savefile'])
from plomrogue.config import config
game = Game(config['savefile'])
@@
-61,6
+61,7
@@
game.register_command(cmd_THING_BOTTLE_EMPTY)
game.register_command(cmd_PLAYER_FACE)
game.register_command(cmd_GOD_PLAYER_FACE)
game.register_command(cmd_GOD_PLAYER_HAT)
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_task(Task_WAIT)
game.register_task(Task_MOVE)
game.register_task(Task_WRITE)
@@
-84,7
+85,7
@@
game.register_thing_type(Thing_BottleSpawner)
game.register_thing_type(Thing_BottleDeposit)
game.register_thing_type(Thing_MusicPlayer)
game.register_thing_type(Thing_Hat)
game.register_thing_type(Thing_BottleDeposit)
game.register_thing_type(Thing_MusicPlayer)
game.register_thing_type(Thing_Hat)
-game.register_thing_type(Thing_Hat
Spawn
er)
+game.register_thing_type(Thing_Hat
Remix
er)
game.read_savefile()
game.io.start_loop()
for port in config['servers']:
game.read_savefile()
game.io.start_loop()
for port in config['servers']: