def players(): log("SCRIPT", "Booting core server functionality") a = Archive() handler.load_handlers() importer.process_xml() log("SCRIPT", "Finished loading core functionality") log("SCRIPT", "Retreiving player information from database") players = a.list() log("SCRIPT", "Loaded %d player%s from database" % (len(players), '' if len(players) == 1 else 's')) print i = 0 names = players.keys() names.sort() for p in names: i += 1 print '%d: %s' % (i, p) print n = raw_input('Load player index (blank to cancel): ') name = None try: n = int(n) if n < 1 or n > len(names): print 'Cancelled.' sys.exit(0) name = names[n - 1] except (ValueError, IndexError): sys.exit(1) player = Player() if not a.load(name, player): choice = raw_input('Player could not be loaded properly. Delete? (Y/N): ') if choice.upper() == 'Y': a.delete(name) sys.exit(0) print print player.name print player.gender, player.race for stat, value in player.stats.items(): print ' %s: %d' % (stat, value) print action = raw_input('Action ([p]assword, [d]elete), [c]ancel): ') if action == '': sys.exit(0) elif 'password'.startswith(action.lower()): player.password = encrypt_password(raw_input('New password: '******'Password written.' elif 'delete'.startswith(action.lower()): confirm = raw_input('Really delete? (Y/N): ') if confirm.upper() == 'Y': a.delete(name) print 'Deletion complete.' else: print 'Deletion cancelled.' else: print 'Cancelled.'
def clear_archive(self): a = Archive() players = a.list() for p in players.keys(): a.delete(p)
def players(): log("SCRIPT", "Booting core server functionality") a = Archive() handler.load_handlers() importer.process_xml() log("SCRIPT", "Finished loading core functionality") log("SCRIPT", "Retreiving player information from database") players = a.list() log( "SCRIPT", "Loaded %d player%s from database" % (len(players), '' if len(players) == 1 else 's')) print i = 0 names = players.keys() names.sort() for p in names: i += 1 print '%d: %s' % (i, p) print n = raw_input('Load player index (blank to cancel): ') name = None try: n = int(n) if n < 1 or n > len(names): print 'Cancelled.' sys.exit(0) name = names[n - 1] except (ValueError, IndexError): sys.exit(1) player = Player() if not a.load(name, player): choice = raw_input( 'Player could not be loaded properly. Delete? (Y/N): ') if choice.upper() == 'Y': a.delete(name) sys.exit(0) print print player.name print player.gender, player.race for stat, value in player.stats.items(): print ' %s: %d' % (stat, value) print action = raw_input('Action ([p]assword, [d]elete), [c]ancel): ') if action == '': sys.exit(0) elif 'password'.startswith(action.lower()): player.password = encrypt_password(raw_input('New password: '******'Password written.' elif 'delete'.startswith(action.lower()): confirm = raw_input('Really delete? (Y/N): ') if confirm.upper() == 'Y': a.delete(name) print 'Deletion complete.' else: print 'Deletion cancelled.' else: print 'Cancelled.'