Example #1
0
 def handle_input(self, data):
     u = db.get_user(self.username)
     if u:
         if u.check_password(data):
             self.client.player = load_player(self.username)
             self.client.modal = None
             add_player_to_game(self.client)
         else:
             self.client.send('error', db.get_msg('lobby.bad_user_pass'))
             self.client.modal = Username(self.client)
     else:
         self.client.send('error', db.get_msg('lobby.bad_user_pass'))
         self.client.modal = Username(self.client)
Example #2
0
def add_player_to_game(client):
    if not client.player:
        lobby_logger.error(
            'Client could not be moved to the game, there was no player obj.')
        client.send('misc', db.get_msg('lobby.login_error'))
        client.close()
    else:
        lobby_logger.info("Adding player:%s to the game" % client.player.name)
        client.send('state', 'game')
        client.send('misc', db.get_msg('lobby.enter_game'))
        client.add_cycle(engine.cycle(client.send, 6, "player_hms", client.player))
        client.add_cycle(engine.cycle(heal_tick, 6, [client]))
        room = world.get_room(client.player.room)
        room.contents.add_player(client)
        do_look(client, None, None)
        do_pi(client, None, None)
Example #3
0
def do_dig(client, args, msg):
    if len(args) == 1:
        current_room = world.get_room(client.player.room)
        zone = world.get_zone(current_room.zone)
        dir = args[0]
        if current_room.exits.has_exit_by_string(dir):
            client.send("error", db.get_msg('building.error_dig_overlap'))
            return
        for e in EXIT_NAMES.keys():
            if dir == EXIT_NAMES[e].lower():
                md = MAP_DIR[e]
                cl = current_room.get_loc()
                new_room = Room(db.new_room(zone, (cl[0]+md[0], cl[1]+md[1], cl[2]+md[2])))
                out_exit = db.new_exit(dir, new_room.short_name)
                in_exit = db.new_exit(OPPOSITE_EXIT[dir], current_room.short_name)
                current_room.exits.add_exit(out_exit)
                new_room.exits.add_exit(in_exit)
    else:
        client.send("error", 'Usage: dig <dir>')
Example #4
0
 def get_prompt(self):
     """
         grabs a message from the db formatted to newplayer.<state>
     """
     return db.get_msg('newplayer.%s' % self.state)
Example #5
0
def new_connection(client):
    lobby_logger.info("New client connected.")
    client.send('state', 'lobby')
    client.send('misc', db.get_msg('connect'))
    client.modal = Username(client)