+ def login(self, nick, connection_id):
+ if len(self.sessions) > 200:
+ print('DEBUG LOGIN TOO MANY FOR', connection_id)
+ self.io.send('CHAT "sorry, too many users currenty '
+ 'logged in, try again later"', connection_id)
+ return
+ for t in [t for t in self.things
+ if t.type_ == 'Player' and t.name == nick]:
+ self.io.send('GAME_ERROR ' + quote('name already in use'),
+ connection_id)
+ return
+ t = self.add_thing('Player', self.get_default_spawn_point())
+ t.name = nick
+ t.thing_char = self.get_next_player_char()
+ self.sessions[connection_id] = {
+ 'thing_id': t.id_,
+ 'status': 'player'
+ }
+ print('DEBUG LOGIN', t.name, len(self.sessions))
+ self.io.send('PLAYER_ID %s' % t.id_, connection_id)
+ self.io.send('LOGIN_OK', connection_id)
+ for msg in self.intro_messages:
+ self.io.send('CHAT ' + quote(msg), connection_id)
+ self.io.send('CHAT ' + quote(t.name + ' entered the map.'))
+ for s in [s for s in self.things
+ if s.type_ == 'SpawnPoint' and s.name == t.name]:
+ t.position = s.position
+ if s.temporary:
+ self.remove_thing(s)
+ break
+ t.try_to_sit()
+