c_id)
cmd_ALL.argtypes = 'string'
+def cmd_SPAWN_POINT(game, big_yx, little_yx):
+ if little_yx.y >= game.map_geometry.size.y or \
+ little_yx.x >= game.map_geometry.size.x:
+ raise GameError('illegal spawn point')
+ game.spawn_point = big_yx, little_yx
+cmd_SPAWN_POINT.argtypes = 'yx_tuple yx_tuple:nonneg'
+
def cmd_LOGIN(game, nick, connection_id):
for t in [t for t in game.things if t.type_ == 'Player' and t.name == nick]:
raise GameError('name already in use')
if game.get_player(connection_id):
raise GameError('cannot log in twice')
t = game.thing_types['Player'](game)
- t.position = (YX(0,0),
- YX(game.map_geometry.size.y // 2, game.map_geometry.size.x // 2))
+ t.position = game.spawn_point
game.things += [t] # TODO refactor into Thing.__init__?
t.player_char = game.get_next_player_char()
game.sessions[connection_id] = {
self.map_controls = {}
self.map_control_passwords = {}
self.annotations = {}
+ self.spawn_point = YX(0,0), YX(0,0)
self.portals = {}
self.player_chars = string.digits + string.ascii_letters
self.player_char_i = -1
t.position[1], t.type_, t.id_))
if hasattr(t, 'name'):
write(f, 'THING_NAME %s %s' % (t.id_, quote(t.name)))
+ write(f, 'SPAWN_POINT %s %s' % (self.spawn_point[0],
+ self.spawn_point[1]))
def get_map(self, big_yx, type_='normal'):
if type_ == 'normal':
self.annotations = {}
self.portals = {}
self.admin_passwords = []
+ self.spawn_point = YX(0,0), YX(0,0)
self.map_geometry = map_geometry
self.map_control_passwords = {'X': 'secret'}
self.get_map(YX(0,0))
cmd_GOD_ANNOTATE, cmd_GOD_PORTAL, cmd_THING_TYPES,
cmd_THING_NAME, cmd_TERRAINS, cmd_ADMIN_PASSWORD,
cmd_BECOME_ADMIN, cmd_SET_TILE_CONTROL,
- cmd_SET_MAP_CONTROL_PASSWORD)
+ 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_Furniture
game.register_command(cmd_SET_TILE_CONTROL)
game.register_command(cmd_SET_MAP_CONTROL_PASSWORD)
game.register_command(cmd_BECOME_ADMIN)
+game.register_command(cmd_SPAWN_POINT)
game.register_task(Task_WAIT)
game.register_task(Task_MOVE)
game.register_task(Task_WRITE)