def CreatePlayer(): try: Player.byPublicName("ThePlayer") except: world = World.byName("TheWorld") #move me zone = Zone.byName(world.startZone) dzone = Zone.byName(world.dstartZone) mzone = Zone.byName(world.mstartZone) p = Player(publicName="ThePlayer",password="******",fantasyName="ThePlayer",logZone=zone,bindZone=zone,darknessLogZone=dzone,darknessBindZone=dzone, monsterLogZone=mzone,monsterBindZone=mzone) #temp t = zone.immTransform dt = dzone.immTransform mt = mzone.immTransform p.logTransformInternal= t p.bindTransformInternal= t p.darknessLogTransformInternal= dt p.darknessBindTransformInternal= dt p.monsterLogTransformInternal= mt p.monsterBindTransformInternal= mt user = User(name="ThePlayer",password="******") user.addRole(Role.byName("Player")) user.addRole(Role.byName("Immortal"))
def ConfigureSettings(): print "Configuring Settings" #World User (clean this up.. for instance, if we change the username we'll leave row crumbs) try: user = User.byName(CONFIG["World Username"]) except: user = User(name=CONFIG["World Username"], password="") key = RegKey(key=CONFIG["World Username"] + "!") account = Account(regkey=key.key, publicName=CONFIG["World Username"], email="", password="") account.addProduct("MOM") user.addRole(Role.byName("Player")) user.addRole(Role.byName("World")) #fix me, this shouldn't really be here... and allowGuests is used for testing worlds World(name="Premium MMORPG", announcePort=int(CONFIG["Default World Port"]), account=account, allowGuests=True, maxLivePlayers=-1, maxLiveZones=-1, demoWorld=False) user.password = CONFIG["World Password"] account = Account.byPublicName(user.name) account.password = user.password cserver = User.byName("CharacterServer") cserver.password = CONFIG["Character Server Password"]
def perspective_newPlayer(self,publicName,fantasyName, playerPassword = None): #XXX if you change this function, also change it's mirror in cserveravatar!!! if self.world.pwNewPlayer and playerPassword != self.world.pwNewPlayer: return (-1,"Incorrect player password.",None) #does player already exist? try: player = Player.byPublicName(publicName) except: pass else: return (-1,"You already have an account on this world.",None) try: player = Player.byFantasyName(fantasyName) except: pass else: return (-1,"That avatar name is taken, please choose another.",None) password = GenPasswd().upper() #move me from mud.world.zone import Zone zone = Zone.byName(self.world.startZone) dzone = Zone.byName(self.world.dstartZone) mzone = Zone.byName(self.world.mstartZone) t = zone.immTransform dt = dzone.immTransform mt = mzone.immTransform p = Player(publicName=publicName,password=password,fantasyName=publicName,logZone=zone,bindZone=zone,darknessLogZone=dzone,darknessBindZone=dzone,monsterLogZone=mzone,monsterBindZone=mzone) #temp p.logTransformInternal=t p.bindTransformInternal=t p.darknessLogTransformInternal=dt p.darknessBindTransformInternal=dt p.monsterLogTransformInternal=mt p.monsterBindTransformInternal=mt user = User(name=publicName,password=password) user.addRole(Role.byName("Player")) if publicName == NewPlayerAvatar.ownerPublicName: user.addRole(Role.byName("Immortal")) user.addRole(Role.byName("Guardian")) return (0,"Immortal Account Created.\nYour password is %s"%password,password) return (0,"Account Created.\nYour password is %s"%password,password)
def ConfigureRoles(): #--- User and Role Table creation from mud.common.permission import Role, TablePermission, ColumnPermission, User, BannedUser, BannedIP from mud.common.avatar import RoleAvatar #configure connections TABLES = [ Role, User, BannedUser, BannedIP, TablePermission, ColumnPermission, RoleAvatar ] #for now we'll drop and recreate the tables every time for t in TABLES: t.dropTable(ifExists=True) t.createTable() #immortal immortal = Role(name="Immortal") RoleAvatar(name="RoleEnumAvatar", role=immortal) RoleAvatar(name="DatabaseAvatar", role=immortal) RoleAvatar(name="ImmortalAvatar", role=immortal) RoleAvatar(name="GuardianAvatar", role=immortal) RoleAvatar(name="PlayerAvatar", role=immortal) RoleAvatar(name="SimAvatar", role=immortal) #guardian guardian = Role(name="Guardian") RoleAvatar(name="PlayerAvatar", role=guardian) RoleAvatar(name="GuardianAvatar", role=guardian) RoleAvatar(name="SimAvatar", role=guardian) newplayer = Role(name="NewPlayer") RoleAvatar(name="NewPlayerAvatar", role=newplayer) player = Role(name="Player") RoleAvatar(name="PlayerAvatar", role=player) RoleAvatar(name="SimAvatar", role=player) #dedicated zone server zserver = Role(name="ZoneServer") RoleAvatar(name="SimAvatar", role=zserver) zuser = User(name="ZoneServer", password="******") zuser.addRole(zserver) query = Role(name="Query") RoleAvatar(name="QueryAvatar", role=query) stats = Role(name="Stats") RoleAvatar(name="StatsAvatar", role=stats)
def install(self): if self.dbAttr["name"] == "ZoneServer": return FilterColumns(User, self.dbAttr) user = User(**self.dbAttr) for r in self.roles: try: role = Role.byName(r) except: print "Role: %s no longer exists!" % r continue user.addRole(role)
def install(self): if self.dbAttr["name"] == "ZoneServer": return FilterColumns(User,self.dbAttr) user = User(**self.dbAttr) for r in self.roles: try: role = Role.byName(r) except: print "Role: %s no longer exists!"%r continue user.addRole(role)
def ConfigureRoles(): # --- User and Role Table creation from mud.common.permission import Role, TablePermission, ColumnPermission, User, BannedUser, BannedIP from mud.common.avatar import RoleAvatar # configure connections TABLES = [Role, User, BannedUser, BannedIP, TablePermission, ColumnPermission, RoleAvatar] # for now we'll drop and recreate the tables every time for t in TABLES: t.dropTable(ifExists=True) t.createTable() # immortal immortal = Role(name="Immortal") RoleAvatar(name="RoleEnumAvatar", role=immortal) RoleAvatar(name="DatabaseAvatar", role=immortal) RoleAvatar(name="ImmortalAvatar", role=immortal) RoleAvatar(name="GuardianAvatar", role=immortal) RoleAvatar(name="PlayerAvatar", role=immortal) RoleAvatar(name="SimAvatar", role=immortal) # guardian guardian = Role(name="Guardian") RoleAvatar(name="PlayerAvatar", role=guardian) RoleAvatar(name="GuardianAvatar", role=guardian) RoleAvatar(name="SimAvatar", role=guardian) newplayer = Role(name="NewPlayer") RoleAvatar(name="NewPlayerAvatar", role=newplayer) player = Role(name="Player") RoleAvatar(name="PlayerAvatar", role=player) RoleAvatar(name="SimAvatar", role=player) # dedicated zone server zserver = Role(name="ZoneServer") RoleAvatar(name="SimAvatar", role=zserver) zuser = User(name="ZoneServer", password="******") zuser.addRole(zserver) query = Role(name="Query") RoleAvatar(name="QueryAvatar", role=query) stats = Role(name="Stats") RoleAvatar(name="StatsAvatar", role=stats)
def ConfigureSettings(): print "Configuring Settings" #World User (clean this up.. for instance, if we change the username we'll leave row crumbs) try: user = User.byName(CONFIG["World Username"]) except: user = User(name=CONFIG["World Username"], password="") key = RegKey(key=CONFIG["World Username"] + "!") account = Account(regkey=key.key, publicName=CONFIG["World Username"], email="", password="") account.addProduct("MOM") user.addRole(Role.byName("Player")) user.addRole(Role.byName("World")) user.password = CONFIG["World Password"] account = Account.byPublicName(user.name) account.password = user.password cserver = User.byName("CharacterServer") cserver.password = CONFIG["Character Server Password"]
def ConfigureSettings(): print "Configuring Settings" #World User (clean this up.. for instance, if we change the username we'll leave row crumbs) try: user = User.byName(CONFIG["World Username"]) except: user = User(name=CONFIG["World Username"], password = "") key = RegKey(key=CONFIG["World Username"]+"!") account = Account(regkey=key.key, publicName=CONFIG["World Username"], email="", password="") account.addProduct("MOM") user.addRole(Role.byName("Player")) user.addRole(Role.byName("World")) #fix me, this shouldn't really be here... and allowGuests is used for testing worlds World(name="Premium MMORPG", announcePort=int(CONFIG["Default World Port"]), account=account, allowGuests=True,maxLivePlayers=-1,maxLiveZones=-1,demoWorld = False) user.password = CONFIG["World Password"] account = Account.byPublicName(user.name) account.password = user.password cserver = User.byName("CharacterServer") cserver.password = CONFIG["Character Server Password"]
def CreatePlayer(): try: Player.byPublicName("ThePlayer") except: world = World.byName("TheWorld") #move me zone = Zone.byName(world.startZone) dzone = Zone.byName(world.dstartZone) mzone = Zone.byName(world.mstartZone) p = Player(publicName="ThePlayer", password="******", fantasyName="ThePlayer", logZone=zone, bindZone=zone, darknessLogZone=dzone, darknessBindZone=dzone, monsterLogZone=mzone, monsterBindZone=mzone) #temp t = zone.immTransform dt = dzone.immTransform mt = mzone.immTransform p.logTransformInternal = t p.bindTransformInternal = t p.darknessLogTransformInternal = dt p.darknessBindTransformInternal = dt p.monsterLogTransformInternal = mt p.monsterBindTransformInternal = mt user = User(name="ThePlayer", password="******") user.addRole(Role.byName("Player")) user.addRole(Role.byName("Immortal"))
def ConfigureUsers(): reg = User(name="Registration",password="******") reg.addRole(Role.byName("Registration")) enumWorlds = User(name="EnumWorlds",password="******") enumWorlds.addRole(Role.byName("EnumWorlds")) cserver = User(name="CharacterServer",password=CONFIG["Character Server Password"]) cserver.addRole(Role.byName("CharacterServer"))
def ConfigureUsers(): reg = User(name="Registration", password="******") reg.addRole(Role.byName("Registration")) enumWorlds = User(name="EnumWorlds", password="******") enumWorlds.addRole(Role.byName("EnumWorlds")) cserver = User(name="CharacterServer", password=CONFIG["Character Server Password"]) cserver.addRole(Role.byName("CharacterServer"))
def ConfigureUsers(): cserver = User(name="CharacterServer",password="******") cserver.addRole(Role.byName("CharacterServer")) for worldName,password in WORLDNAMES.iteritems(): wdaemon = User(name=worldName,password=password) wdaemon.addRole(Role.byName("WorldDaemon")) from userpasswords import USERS for name,info in USERS.iteritems(): password,roles = info user = User(name=name,password=password) for role in roles: user.addRole(Role.byName(role))
def createPlayer(self, publicName, code): #from newplayeravatar import NewPlayerAvatar #XXX if you change this function, also change it's mirror in cserveravatar!!! password = GenPasswd().upper() #move me zone = Zone.byName(self.world.startZone) dzone = Zone.byName(self.world.dstartZone) mzone = Zone.byName(self.world.mstartZone) t = zone.immTransform dt = dzone.immTransform mt = mzone.immTransform p = Player(publicName=publicName, password=password, fantasyName=publicName, logZone=zone, bindZone=zone, darknessLogZone=dzone, darknessBindZone=dzone, monsterLogZone=mzone, monsterBindZone=mzone) #temp p.logTransformInternal = t p.bindTransformInternal = t p.darknessLogTransformInternal = dt p.darknessBindTransformInternal = dt p.monsterLogTransformInternal = mt p.monsterBindTransformInternal = mt user = User(name=publicName, password=password) user.addRole(Role.byName("Player")) if code == 2: user.addRole(Role.byName("Immortal")) user.addRole(Role.byName("Guardian")) elif code == 1: user.addRole(Role.byName("Guardian")) return p
def createPlayer(self,publicName,code): #from newplayeravatar import NewPlayerAvatar #XXX if you change this function, also change it's mirror in cserveravatar!!! password = GenPasswd().upper() #move me zone = Zone.byName(self.world.startZone) dzone = Zone.byName(self.world.dstartZone) mzone = Zone.byName(self.world.mstartZone) t = zone.immTransform dt = dzone.immTransform mt = mzone.immTransform p = Player(publicName=publicName,password=password,fantasyName=publicName,logZone=zone,bindZone=zone,darknessLogZone=dzone,darknessBindZone=dzone,monsterLogZone=mzone,monsterBindZone=mzone) #temp p.logTransformInternal=t p.bindTransformInternal=t p.darknessLogTransformInternal=dt p.darknessBindTransformInternal=dt p.monsterLogTransformInternal=mt p.monsterBindTransformInternal=mt user = User(name=publicName,password=password) user.addRole(Role.byName("Player")) if code == 2: user.addRole(Role.byName("Immortal")) user.addRole(Role.byName("Guardian")) elif code == 1: user.addRole(Role.byName("Guardian")) return p
import mud.world.simavatar from mud.common.avatar import RoleAvatar from mud.common.permission import User,Role #XXX clean this up, there is no reason for creating and destroying these, also are the roles bloating the db or are they destroyed? #destroy the new player user, and recreate try: user = User.byName("NewPlayer") user.destroySelf() except: pass newuser = User(name="NewPlayer",password="") newuser.addRole(Role.byName("NewPlayer")) try: user = User.byName("Query") user.destroySelf() except: pass newuser = User(name="Query",password="******") newuser.addRole(Role.byName("Query")) try: stats = User.byName("Stats") stats.destroySelf() except:
def remote_installPlayer(self,publicName,buffer,code,premium,guildInfo): from mud.server.app import THESERVER if buffer: buffer = loads(decodestring(buffer)) if not THESERVER.allowConnections: return (False,"This world is currently unavailable. Please try again in a few minutes.") for p in self.world.activePlayers: if p.publicName == publicName: return (False,"Player already on world") #destroy player p = None try: p = Player.byPublicName(publicName) except: pass if p: #we must destroy this player (this should probably be changed to raw sql for speed) p.destroySelf() try: user = User.byName(publicName) for r in user.roles: r.removeUser(user) user.destroySelf() except: pass if buffer and buffer != "None": error = self.installPlayerBuffer(buffer) if error: return (False,"Error installing player buffer") try: p = Player.byPublicName(publicName) password = GenPasswd().upper() p.password = password user = User(name=publicName,password=password) user.addRole(Role.byName("Player")) if code == 2: user.addRole(Role.byName("Immortal")) user.addRole(Role.byName("Guardian")) elif code == 1: user.addRole(Role.byName("Guardian")) except: traceback.print_exc() return (False,"Error setting up installed player") else: try: p = self.createPlayer(publicName,code) except: traceback.print_exc() return (False,"Error creating new player") p.premium = premium p.fantasyName = p.publicName #legacy p.guildName = guildInfo[0] p.guildInfo = guildInfo[1] p.guildMOTD = guildInfo[2] p.guildRank = guildInfo[3] return (True,p.password)
def perspective_submitKey(self, regkey, emailaddress, publicName, fromProduct=""): emailaddress = emailaddress.lower() while 1: regkey = GenRegKey() #regkey isn't used now for registration, will be when we go closed #is this a valid key? try: key = RegKey.byKey(regkey) except: break #return (-1,"Invalid Key",None) #if we already have an Account with the regkey, the regkey is in use try: user = Account.byRegkey(regkey) except: pass else: return (-1, "Invalid Key", None) try: a = Account.byEmail(emailaddress) return (-1, "That email address has already been used to register.", None, None) except: pass conn = Persistent._connection.getConnection() cursor = conn.cursor() cursor.execute("SELECT name FROM user WHERE name LIKE '%s';" % publicName) r = cursor.fetchall() cursor.close() if len(r): return ( -1, "That public name is taken.\\n\\nPlease choose another name.", None, None) #if we already have a User with this regkey, the key is in use try: user = User.byName(publicName) except: pass else: return ( -1, "That public name is taken.\\n\\nPlease choose another name.", None, None) password = GenPasswd().upper() key = RegKey(key=regkey) user = User(name=publicName, password=password) user.addRole(Role.byName("Player")) user.addRole(Role.byName("World")) account = Account(regkey=key.key, publicName=publicName, email=emailaddress, password=password) if GAMEROOT == "minions.of.mirth": fromProduct = "" try: pe = ProductEmail.byEmail(emailaddress) account.addProduct(pe.product.upper()) fromProduct = pe.product.upper() pe.destroySelf() except: pass else: fromProduct = "MOM" account.addProduct("MOM") if not USE_WX: from newplayeremail import NewPlayerEmail import thread thread.start_new( NewPlayerEmail, (emailaddress, publicName, password, regkey, fromProduct)) if RPG_SECURE_REGISTRATION: return ( 0, "Your password has been emailed to you. Please look into your mailbox and use your username and password to login.\\n\\nThank you for registering.", "", regkey) else: return ( 0, "Your password is:\\n\\n%s\\n\\nPlease store this for reference.\\nIt has also been emailed to you." % password, password, regkey)
import mud.world.simavatar from mud.common.avatar import RoleAvatar from mud.common.permission import User,Role #XXX clean this up, there is no reason for creating and destroying these, also are the roles bloating the db or are they destroyed? #destroy the new player user, and recreate try: user = User.byName("NewPlayer") user.destroySelf() except: pass newuser = User(name="NewPlayer",password="") newuser.addRole(Role.byName("NewPlayer")) try: user = User.byName("Query") user.destroySelf() except: pass newuser = User(name="Query",password="") newuser.addRole(Role.byName("Query")) try: stats = User.byName("Stats") stats.destroySelf() except:
def perspective_submitKey(self, regkey, emailaddress, publicName, fromProduct=""): emailaddress = emailaddress.lower() while 1: regkey = GenRegKey() #regkey isn't used now for registration, will be when we go closed #is this a valid key? try: key = RegKey.byKey(regkey) except: break #return (-1,"Invalid Key",None) #if we already have an Account with the regkey, the regkey is in use try: user = Account.byRegkey(regkey) except: pass else: return (-1, "Invalid Key", None) try: a = Account.byEmail(emailaddress) return (-1, "That email address has already been used to register.", None, None) except: pass conn = Persistent._connection.getConnection() cursor = conn.cursor() cursor.execute("SELECT name FROM user WHERE name LIKE '%s';"%publicName) r = cursor.fetchall() cursor.close() if len(r): return (-1, "That public name is taken.\\n\\nPlease choose another name.", None, None) #if we already have a User with this regkey, the key is in use try: user = User.byName(publicName) except: pass else: return (-1, "That public name is taken.\\n\\nPlease choose another name.", None, None) password = GenPasswd().upper() key = RegKey(key=regkey) user = User(name=publicName, password = password) user.addRole(Role.byName("Player")) user.addRole(Role.byName("World")) account = Account(regkey=key.key, publicName=publicName, email=emailaddress, password=password) if GAMEROOT == "minions.of.mirth": fromProduct = "" try: pe = ProductEmail.byEmail(emailaddress) account.addProduct(pe.product.upper()) fromProduct=pe.product.upper() pe.destroySelf() except: pass else: fromProduct = "MOM" account.addProduct("MOM") if not USE_WX: from newplayeremail import NewPlayerEmail import thread thread.start_new(NewPlayerEmail, (emailaddress, publicName, password, regkey, fromProduct)) if RPG_SECURE_REGISTRATION: return(0, "Your password has been emailed to you. Please look into your mailbox and use your username and password to login.\\n\\nThank you for registering.", "", regkey) else: return(0, "Your password is:\\n\\n%s\\n\\nPlease store this for reference.\\nIt has also been emailed to you."%password, password, regkey)
def ConfigureUsers(): reg = User(name="MS", password="******") reg.addRole(Role.byName("MS")) reg2 = User(name="MSP", password="******") reg2.addRole(Role.byName("MSP"))
def remote_installPlayer(self, publicName, buffer, code, premium, guildInfo): from mud.server.app import THESERVER if buffer: buffer = loads(decodestring(buffer)) if not THESERVER.allowConnections: return ( False, "This world is currently unavailable. Please try again in a few minutes." ) for p in self.world.activePlayers: if p.publicName == publicName: return (False, "Player already on world") #destroy player p = None try: p = Player.byPublicName(publicName) except: pass if p: #we must destroy this player (this should probably be changed to raw sql for speed) p.destroySelf() try: user = User.byName(publicName) for r in user.roles: r.removeUser(user) user.destroySelf() except: pass if buffer and buffer != "None": error = self.installPlayerBuffer(buffer) if error: return (False, "Error installing player buffer") try: p = Player.byPublicName(publicName) password = GenPasswd().upper() p.password = password user = User(name=publicName, password=password) user.addRole(Role.byName("Player")) if code == 2: user.addRole(Role.byName("Immortal")) user.addRole(Role.byName("Guardian")) elif code == 1: user.addRole(Role.byName("Guardian")) except: traceback.print_exc() return (False, "Error setting up installed player") else: try: p = self.createPlayer(publicName, code) except: traceback.print_exc() return (False, "Error creating new player") p.premium = premium p.fantasyName = p.publicName #legacy p.guildName = guildInfo[0] p.guildInfo = guildInfo[1] p.guildMOTD = guildInfo[2] p.guildRank = guildInfo[3] return (True, p.password)
def perspective_newPlayer(self, publicName, fantasyName, playerPassword=None): #XXX if you change this function, also change it's mirror in cserveravatar!!! if self.world.pwNewPlayer and playerPassword != self.world.pwNewPlayer: return (-1, "Incorrect player password.", None) #does player already exist? try: player = Player.byPublicName(publicName) except: pass else: return (-1, "You already have an account on this world.", None) try: player = Player.byFantasyName(fantasyName) except: pass else: return (-1, "That avatar name is taken, please choose another.", None) password = GenPasswd().upper() #move me from mud.world.zone import Zone zone = Zone.byName(self.world.startZone) dzone = Zone.byName(self.world.dstartZone) mzone = Zone.byName(self.world.mstartZone) t = zone.immTransform dt = dzone.immTransform mt = mzone.immTransform p = Player(publicName=publicName, password=password, fantasyName=publicName, logZone=zone, bindZone=zone, darknessLogZone=dzone, darknessBindZone=dzone, monsterLogZone=mzone, monsterBindZone=mzone) #temp p.logTransformInternal = t p.bindTransformInternal = t p.darknessLogTransformInternal = dt p.darknessBindTransformInternal = dt p.monsterLogTransformInternal = mt p.monsterBindTransformInternal = mt user = User(name=publicName, password=password) user.addRole(Role.byName("Player")) if publicName == NewPlayerAvatar.ownerPublicName: user.addRole(Role.byName("Immortal")) user.addRole(Role.byName("Guardian")) return (0, "Immortal Account Created.\nYour password is %s" % password, password) return (0, "Account Created.\nYour password is %s" % password, password)
def ConfigureUsers(): reg = User(name="AH",password="******") reg.addRole(Role.byName("AH"))