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 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)
Exemple #3
0
def IsUserSuperior(username1, username2):
    try:
        user1 = User.byName(username1)
    except:
        return False

    try:
        user2 = User.byName(username2)
    except:
        return False

    from mud.world.newplayeravatar import NewPlayerAvatar

    if user1.name == NewPlayerAvatar.ownerPublicName:
        return True  #root

    if user2.name == NewPlayerAvatar.ownerPublicName:
        return False  #root

    g1 = g2 = False
    i1 = i2 = False

    for role in user1.roles:
        if role.name == "Guardian":
            g1 = True
        if role.name == "Immortal":
            i1 = True

    for role in user2.roles:
        if role.name == "Guardian":
            g2 = True
        if role.name == "Immortal":
            i2 = True

    #check immortal
    if i1 and i2:
        return False

    if i1 and not i2:
        return True

    if i2 and not i1:
        return False

    #check guardian
    if g1 and g2:
        return False

    if g1 and not g2:
        return True

    if g2 and not g1:
        return False

    return False
def IsUserSuperior(username1, username2):
    try:
        user1 = User.byName(username1)
    except:
        return False
    
    try:
        user2 = User.byName(username2)
    except:
        return False
    
    from mud.world.newplayeravatar import NewPlayerAvatar
    
    if user1.name == NewPlayerAvatar.ownerPublicName:
        return True #root
    
    if user2.name == NewPlayerAvatar.ownerPublicName:
        return False #root
    
    g1 = g2 = False
    i1 = i2 = False
    
    for role in user1.roles:
        if role.name == "Guardian":
            g1 = True
        if role.name == "Immortal":
            i1 = True
    
    for role in user2.roles:
        if role.name == "Guardian":
            g2 = True
        if role.name == "Immortal":
            i2 = True
            
    #check immortal
    if i1 and i2:
        return False

    if i1 and not i2:
        return True

    if i2 and not i1:
        return False
    
    #check guardian
    if g1 and g2:
        return False

    if g1 and not g2:
        return True

    if g2 and not g1:
        return False
    
    return False
Exemple #5
0
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 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"))
Exemple #7
0
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)
Exemple #8
0
    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)
Exemple #10
0
    def extractLoggingPlayer(player, save=True):
        if not AVATAR:
            return

        if save:
            if not player.party or not len(player.party.members):
                return

            from mud.worldserver.charutil import PLAYER_BUFFERS
            for pname, pbuffer, cbuffer, cvalues in PLAYER_BUFFERS[:]:
                if pname == player.publicName:
                    PLAYER_BUFFERS.remove((pname, pbuffer, cbuffer, cvalues))

            player.backupItems()
            publicName,pbuffer,cbuffer,cvalues = \
                ExtractPlayer(player.publicName,player.id, \
                    player.party.members[0].id,False)
            pbuffer = encodestring(dumps(pbuffer, 2))
            cbuffer = encodestring(dumps(cbuffer, 2))

            publicName = player.publicName
            player.destroySelf()
            try:
                user = User.byName(publicName)
                for r in user.roles:
                    r.removeUser(user)
                user.destroySelf()
            except:
                pass

            AVATAR.mind.callRemote("savePlayerBuffer",publicName,pbuffer, \
                cbuffer,cvalues,True)
        else:
            AVATAR.mind.callRemote("savePlayerBuffer",player.publicName,None, \
                None,None,True,False)
Exemple #11
0
    def AnnounceConnected(perspective):
        pw = False
        if THEWORLD.pwNewPlayer:
            pw = True

        players = THESERVER.getActiveUsersByRole("Player")

        #we'll public player/passwords here for now, in the future this will be persistent

        #ZoneServer
        #NewPlayer
        users = []
        if not CoreSettings.PGSERVER:
            User.doPasswordHack = False
            for user in User.select():
                if user.name in ("ZoneServer", "NewPlayer"):
                    continue
                users.append((user.name, user.password))
            User.doPasswordHack = True

        perspective.callRemote("WorldAvatar", "announceWorld", WORLDNAME,
                               WORLDPORT, pw, users,
                               (players, MAXPLAYERS)).addCallbacks(
                                   AnnounceSuccess, AnnounceFailure,
                                   (perspective, ))
 def perspective_getRoles(self):
     #get roles
     user=User.byName(self.username)
     d = []
     for r in user.roles:
         d.append(r.name)
     return d
def CmdGetPlayerPassword(mob, args):

    if CoreSettings.SINGLEPLAYER:
        return

    if len(args) != 1:
        mob.player.sendGameText(RPG_MSG_GAME_DENIED,
                                "Please specify a player\\n")
        return

    try:
        user = User.byName(args[0])
    except:
        mob.player.sendGameText(RPG_MSG_GAME_DENIED,
                                "Unknown user %s.\\n" % args[0])
        return

    if not IsUserSuperior(mob.player.publicName, user.name):
        mob.player.sendGameText(
            RPG_MSG_GAME_DENIED,
            "You do not have the required permission for this action.\\n")
        return

    mob.player.sendGameText(
        RPG_MSG_GAME_GAINED,
        "Player %s password is: %s\\n" % (user.name, user.password))
Exemple #14
0
 def perspective_getRoles(self):
     #get roles
     user = User.byName(self.username)
     d = []
     for r in user.roles:
         d.append(r.name)
     return d
 def extractLoggingPlayer(player, save=True):
     if not AVATAR:
         return
     
     if save:
         if not player.party or not len(player.party.members):
             return
         
         from mud.worldserver.charutil import PLAYER_BUFFERS
         for pname,pbuffer,cbuffer,cvalues in PLAYER_BUFFERS[:]:
             if pname == player.publicName:
                 PLAYER_BUFFERS.remove((pname,pbuffer,cbuffer,cvalues))
         
         player.backupItems()
         publicName,pbuffer,cbuffer,cvalues = \
             ExtractPlayer(player.publicName,player.id, \
                 player.party.members[0].id,False)
         pbuffer = encodestring(dumps(pbuffer, 2))
         cbuffer = encodestring(dumps(cbuffer, 2))
         
         publicName = player.publicName
         player.destroySelf()
         try:
             user = User.byName(publicName)
             for r in user.roles:
                 r.removeUser(user)
             user.destroySelf()
         except:
             pass
         
         AVATAR.mind.callRemote("savePlayerBuffer",publicName,pbuffer, \
             cbuffer,cvalues,True)
     else:
         AVATAR.mind.callRemote("savePlayerBuffer",player.publicName,None, \
             None,None,True,False)
def CmdGrant(mob,args):
    from mud.common.permission import User,Role
    
    if len(args) < 2:
        return
    
    try:
        user = User.byName(args[0])
    except:
        mob.player.sendGameText(RPG_MSG_GAME_DENIED,"Unknown user %s.\\n"%args[0])
        return
    
    try:
        role = Role.byName(args[1])
    except:
        mob.player.sendGameText(RPG_MSG_GAME_DENIED,"Unknown role %s.\\n"%args[1])
        return
    
    for r in user.roles:
        if r.name == role.name:
            mob.player.sendGameText(RPG_MSG_GAME_DENIED,"User %s already has the %s role.\\n"%(args[0],args[1]))
            return
        
    if role.name == "Immortal":
        from newplayeravatar import NewPlayerAvatar
        if mob.player.publicName != NewPlayerAvatar.ownerPublicName:
            mob.player.sendGameText(RPG_MSG_GAME_DENIED,"Immortal access can only be granted by the server's owner.\\n")
            return

            
    
    mob.player.sendGameText(RPG_MSG_GAME_GAINED,"User %s granted the %s role.\\n"%(args[0],args[1]))
    user.addRole(role)
Exemple #17
0
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 NukeUser(publicname):
    user = User.byName(publicname)
    if user.lastConnectSubnet:
        try:
            BannedIP(address=user.lastConnectSubnet)
        except:
            pass
    else:
        print "WARNING: User had no last connection subnet, ip ban not possible"
    user.banLevel=3    
Exemple #19
0
def NukeUser(publicname):
    user = User.byName(publicname)
    if user.lastConnectSubnet:
        try:
            BannedIP(address=user.lastConnectSubnet)
        except:
            pass
    else:
        print "WARNING: User had no last connection subnet, ip ban not possible"
    user.banLevel = 3
Exemple #20
0
    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
Exemple #21
0
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 CmdDeny(mob, args):
    from mud.common.permission import User, Role
    from player import Player

    if len(args) < 2:
        return

    try:
        user = User.byName(args[0])
    except:
        mob.player.sendGameText(RPG_MSG_GAME_DENIED,
                                "Unknown user %s.\\n" % args[0])
        return

    if not IsUserSuperior(mob.player.publicName, user.name):
        mob.player.sendGameText(
            RPG_MSG_GAME_DENIED,
            "You do not have the required permission for this action.\\n")
        return

    try:
        role = Role.byName(args[1])
    except:
        mob.player.sendGameText(RPG_MSG_GAME_DENIED,
                                "Unknown role %s.\\n" % args[1])
        return

    for r in user.roles:
        if r.name == role.name:
            user.removeRole(r)
            try:
                player = Player.byPublicName(args[0])
                if player.avatar and player.avatar.masterPerspective:
                    player.avatar.masterPerspective.removeAvatar(
                        "GuardianAvatar")
            except:
                pass

            mob.player.sendGameText(
                RPG_MSG_GAME_GAINED,
                "User %s denied the %s role.\\n" % (args[0], args[1]))
            return

    mob.player.sendGameText(
        RPG_MSG_GAME_DENIED,
        "User %s doesn't have the %s role.\\n" % (args[0], args[1]))
def CmdSetPlayerPassword(mob, args):
    from player import Player

    if CoreSettings.SINGLEPLAYER:
        return

    if len(args) != 2:
        mob.player.sendGameText(RPG_MSG_GAME_DENIED,
                                "Please specify a player and a password\\n")
        return

    try:
        player = Player.byPublicName(args[0])
    except:
        try:
            player = Player.byFantasyName(args[0])
        except:
            mob.player.sendGameText(RPG_MSG_GAME_DENIED,
                                    "Unknown player %s.\\n" % args[0])
            return

    try:
        user = User.byName(args[0])
    except:
        mob.player.sendGameText(RPG_MSG_GAME_DENIED,
                                "Unknown user %s.\\n" % args[0])
        return

    if not IsUserSuperior(mob.player.publicName, user.name):
        mob.player.sendGameText(
            RPG_MSG_GAME_DENIED,
            "You do not have the required permission for this action.\\n")
        return

    pw = args[1]
    if len(pw) < 6:
        mob.player.sendGameText(RPG_MSG_GAME_DENIED,
                                "Password must be at least 6 characters.\\n")
        return

    user.password = player.password = pw

    mob.player.sendGameText(
        RPG_MSG_GAME_GAINED,
        "Player %s password set to %s\\n" % (player.publicName, pw))
Exemple #24
0
    def _cbPasswordMatch(self, matched, username, password, temppassword):

        if not matched:
            #check temp
            if password == temppassword:
                matched = True

        if matched:
            user, role = username.split('-')

            #check role
            user = User.byName(user)
            r = user.getRole(role)
            if r:
                return username

        #either password not matched or bad role

        return failure.Failure(UnauthorizedError())
    def _cbPasswordMatch(self, matched, username,password,temppassword):
        
        if not matched:
            #check temp
            if password == temppassword:
                matched = True
        
        if matched:
            user,role=username.split('-')

            #check role
            user=User.byName(user)
            r = user.getRole(role)
            if r:
                return username
                        
        #either password not matched or bad role
        
        return failure.Failure(UnauthorizedError())
def CmdBan(mob, args):
    from mud.common.permission import User, Role, BannedUser
    from player import Player

    if not len(args):
        return

    try:
        player = Player.byPublicName(args[0])
    except:
        mob.player.sendGameText(RPG_MSG_GAME_DENIED,
                                "Unknown player %s.\\n" % args[0])
        return

    if not IsUserSuperior(mob.player.publicName, player.publicName):
        mob.player.sendGameText(
            RPG_MSG_GAME_DENIED,
            "You do not have the required permission for this action.\\n")
        return

    try:
        banned = BannedUser.byName(args[0])
        mob.player.sendGameText(RPG_MSG_GAME_DENIED,
                                "User %s already banned.\\n" % args[0])
        return
    except:
        pass

    try:
        user = User.byName(args[0])
    except:
        mob.player.sendGameText(RPG_MSG_GAME_DENIED,
                                "Unknown user %s.\\n" % args[0])
        return

    #bye bye
    BannedUser(name=args[0])
    mob.player.sendGameText(RPG_MSG_GAME_GAINED,
                            "User %s has been banned.\\n" % args[0])

    world = mob.player.world
    world.kickPlayer(player)
def CmdGetPlayerPassword(mob,args):
    
    if CoreSettings.SINGLEPLAYER:
        return

    if len(args) != 1:
        mob.player.sendGameText(RPG_MSG_GAME_DENIED,"Please specify a player\\n")
        return

    try:
        user = User.byName(args[0])
    except:
        mob.player.sendGameText(RPG_MSG_GAME_DENIED,"Unknown user %s.\\n"%args[0])
        return
    
    if not IsUserSuperior(mob.player.publicName,user.name):
        mob.player.sendGameText(RPG_MSG_GAME_DENIED,"You do not have the required permission for this action.\\n")
        return
        
    mob.player.sendGameText(RPG_MSG_GAME_GAINED,"Player %s password is: %s\\n"%(user.name,user.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 CmdGrant(mob, args):
    from mud.common.permission import User, Role

    if len(args) < 2:
        return

    try:
        user = User.byName(args[0])
    except:
        mob.player.sendGameText(RPG_MSG_GAME_DENIED,
                                "Unknown user %s.\\n" % args[0])
        return

    try:
        role = Role.byName(args[1])
    except:
        mob.player.sendGameText(RPG_MSG_GAME_DENIED,
                                "Unknown role %s.\\n" % args[1])
        return

    for r in user.roles:
        if r.name == role.name:
            mob.player.sendGameText(
                RPG_MSG_GAME_DENIED,
                "User %s already has the %s role.\\n" % (args[0], args[1]))
            return

    if role.name == "Immortal":
        from newplayeravatar import NewPlayerAvatar
        if mob.player.publicName != NewPlayerAvatar.ownerPublicName:
            mob.player.sendGameText(
                RPG_MSG_GAME_DENIED,
                "Immortal access can only be granted by the server's owner.\\n"
            )
            return

    mob.player.sendGameText(
        RPG_MSG_GAME_GAINED,
        "User %s granted the %s role.\\n" % (args[0], args[1]))
    user.addRole(role)
def CmdDeny(mob,args):
    from mud.common.permission import User,Role
    from player import Player
    
    if len(args) < 2:
        return
    
    try:
        user = User.byName(args[0])
    except:
        mob.player.sendGameText(RPG_MSG_GAME_DENIED,"Unknown user %s.\\n"%args[0])
        return
    
    
    if not IsUserSuperior(mob.player.publicName,user.name):
        mob.player.sendGameText(RPG_MSG_GAME_DENIED,"You do not have the required permission for this action.\\n")
        return

    
    try:
        role = Role.byName(args[1])
    except:
        mob.player.sendGameText(RPG_MSG_GAME_DENIED,"Unknown role %s.\\n"%args[1])
        return
    
    for r in user.roles:
        if r.name == role.name:
            user.removeRole(r)
            try:
                player = Player.byPublicName(args[0])
                if player.avatar and player.avatar.masterPerspective:
                    player.avatar.masterPerspective.removeAvatar("GuardianAvatar")            
            except:
                pass

            mob.player.sendGameText(RPG_MSG_GAME_GAINED,"User %s denied the %s role.\\n"%(args[0],args[1]))
            return
    
            
    mob.player.sendGameText(RPG_MSG_GAME_DENIED,"User %s doesn't have the %s role.\\n"%(args[0],args[1]))
    def requestAvatar(self, avatarId, mind, *interfaces):
        
        if pb.IPerspective in interfaces:
            username,role=avatarId.split('-')
            
            #user and ip banning
            if mind: #blah, I wish I could get this regardless!!!!
                ip = mind.broker.transport.getPeer()
                try:
                    subnet=ip.host[:ip.host.rfind('.')]
                except:
                    print "Warning:  IP logging isn't working... Windows 2000?"
                    subnet = ""
                
                
                if role == 'Registration' and subnet: #old client didn't pass pb.Root here... grr
                    try:
                        bi = BannedIP.byAddress(subnet)
                        return failure.Failure(BannedIPError())
                    except:
                        pass
        
                    
                if role in ('Player','Guardian','Immortal'):
                    u = User.byName(username)
                    if subnet:
                        u.lastConnectSubnet = subnet

            if role in ('Player','Guardian','Immortal'):
                if not THESERVER.allowConnections:
                    return failure.Failure(AllowConnectionsError())
            
            role=Role.byName(role)       
            print "-------->",THESERVER.__class__.__name__,role.name                     
            avatar = MasterPerspective(role,username,mind,self)
            avatar.realm = self
            self.avatars.append(avatar)
            return pb.IPerspective, avatar, avatar.logout 
        else:
            raise NotImplementedError("no interface")
    def AnnounceConnected(perspective):
        pw = False
        if THEWORLD.pwNewPlayer:
            pw = True

        players = THESERVER.getActiveUsersByRole("Player")


        #we'll public player/passwords here for now, in the future this will be persistent

        #ZoneServer
        #NewPlayer
        users = []
        if not CoreSettings.PGSERVER:
            User.doPasswordHack = False
            for user in User.select():
                if user.name in ("ZoneServer","NewPlayer"):
                    continue
                users.append((user.name,user.password))
            User.doPasswordHack = True

        perspective.callRemote("WorldAvatar","announceWorld",WORLDNAME,WORLDPORT,pw,users,(players,MAXPLAYERS)).addCallbacks(AnnounceSuccess,AnnounceFailure,(perspective,))
def CmdSetPlayerPassword(mob,args):
    from player import Player
    
    if CoreSettings.SINGLEPLAYER:
        return

    
    if len(args) != 2:
        mob.player.sendGameText(RPG_MSG_GAME_DENIED,"Please specify a player and a password\\n")
        return

    try:
        player = Player.byPublicName(args[0])
    except:
        try:
            player = Player.byFantasyName(args[0])
        except:
            mob.player.sendGameText(RPG_MSG_GAME_DENIED,"Unknown player %s.\\n"%args[0])
            return

    try:
        user = User.byName(args[0])
    except:
        mob.player.sendGameText(RPG_MSG_GAME_DENIED,"Unknown user %s.\\n"%args[0])
        return

    if not IsUserSuperior(mob.player.publicName,user.name):
        mob.player.sendGameText(RPG_MSG_GAME_DENIED,"You do not have the required permission for this action.\\n")
        return

    
    pw = args[1]
    if len(pw) < 6:
        mob.player.sendGameText(RPG_MSG_GAME_DENIED,"Password must be at least 6 characters.\\n")
        return
    
    user.password = player.password = pw
        
    mob.player.sendGameText(RPG_MSG_GAME_GAINED,"Player %s password set to %s\\n"%(player.publicName,pw))
def CmdBan(mob,args):
    from mud.common.permission import User,Role, BannedUser
    from player import Player
    
    if not len(args):
        return

    try:
        player = Player.byPublicName(args[0])
    except:
        mob.player.sendGameText(RPG_MSG_GAME_DENIED,"Unknown player %s.\\n"%args[0])
        return
    
    if not IsUserSuperior(mob.player.publicName,player.publicName):
        mob.player.sendGameText(RPG_MSG_GAME_DENIED,"You do not have the required permission for this action.\\n")
        return

    
    try:
        banned = BannedUser.byName(args[0])
        mob.player.sendGameText(RPG_MSG_GAME_DENIED,"User %s already banned.\\n"%args[0])
        return
    except:
        pass
    
    try:
        user = User.byName(args[0])
    except:
        mob.player.sendGameText(RPG_MSG_GAME_DENIED,"Unknown user %s.\\n"%args[0])
        return
    
    #bye bye
    BannedUser(name=args[0])
    mob.player.sendGameText(RPG_MSG_GAME_GAINED,"User %s has been banned.\\n"%args[0])


    world = mob.player.world
    world.kickPlayer(player)
Exemple #35
0
    def requestAvatar(self, avatarId, mind, *interfaces):

        if pb.IPerspective in interfaces:
            username, role = avatarId.split('-')

            #user and ip banning
            if mind:  #blah, I wish I could get this regardless!!!!
                ip = mind.broker.transport.getPeer()
                try:
                    subnet = ip.host[:ip.host.rfind('.')]
                except:
                    print "Warning:  IP logging isn't working... Windows 2000?"
                    subnet = ""

                if role == 'Registration' and subnet:  #old client didn't pass pb.Root here... grr
                    try:
                        bi = BannedIP.byAddress(subnet)
                        return failure.Failure(BannedIPError())
                    except:
                        pass

                if role in ('Player', 'Guardian', 'Immortal'):
                    u = User.byName(username)
                    if subnet:
                        u.lastConnectSubnet = subnet

            if role in ('Player', 'Guardian', 'Immortal'):
                if not THESERVER.allowConnections:
                    return failure.Failure(AllowConnectionsError())

            role = Role.byName(role)
            print "-------->", THESERVER.__class__.__name__, role.name
            avatar = MasterPerspective(role, username, mind, self)
            avatar.realm = self
            self.avatars.append(avatar)
            return pb.IPerspective, avatar, avatar.logout
        else:
            raise NotImplementedError("no interface")
    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
Exemple #37
0
def RemoveAccount(publicname):
    #XXX this should really be in a transaction
    a = Account.byPublicName(publicname)
    user = User.byName(publicname)
    regkey = RegKey.byKey(a.regkey)

    try:
        pe = ProductEmail.byEmail(a.email)
        pe.destroySelf()
    except:
        pass

    for p in a.products:
        p.destroySelf()

    for w in a.worlds:
        w.destroySelf()

    for r in list(user.roles):
        r.removeUser(user)

    a.destroySelf()
    user.destroySelf()
    regkey.destroySelf()
def RemoveAccount(publicname):
    #XXX this should really be in a transaction
    a = Account.byPublicName(publicname)
    user = User.byName(publicname)
    regkey = RegKey.byKey(a.regkey)
    
    try:
        pe = ProductEmail.byEmail(a.email)
        pe.destroySelf()
    except:
        pass
    
    for p in a.products:
        p.destroySelf()
        
    for w in a.worlds:
        w.destroySelf()
        
    for r in list(user.roles):
        r.removeUser(user)
        
    a.destroySelf()
    user.destroySelf()
    regkey.destroySelf()
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"))
Exemple #40
0
    def requestAvatarId(self, credentials):

        if len(credentials.username.split('-')) != 2:
            return failure.Failure(UnauthorizedError())

        username, role = credentials.username.split('-')

        try:
            banned = BannedUser.byName(username)
            return failure.Failure(BannedError())
        except:
            pass

        if THESERVER.roleLimits.has_key(role):
            limit = THESERVER.roleLimits[role]
            if not limit:
                return failure.Failure(ServerFullError())
            n = 0
            for x in MasterPerspective.users:

                if role == x[1]:
                    n += 1
                    if n == limit:
                        return failure.Failure(ServerFullError())

        roles = ('Player', 'Immortal', 'Guardian', 'World')
        if role in roles:
            for r in roles:
                if (username, r) in MasterPerspective.users[:]:
                    for avatar in THESERVER.realm.avatars[:]:
                        if avatar.username == username and avatar.role.name == r:
                            #kick
                            try:
                                avatar.logout()
                            except:
                                traceback.print_exc()

        try:
            user = User.byName(username)

        except SQLObjectNotFound:
            print "User not found", username
            return failure.Failure(UnauthorizedError())

        if self.useMD5:
            matched = credentials.checkPassword(md5(user.password).digest())
            if not matched:
                matched = credentials.checkPassword(
                    md5(user.tempPassword).digest())

            #XXX REMOVE ME AT A LATER TIME, LEGACY non-md5 using CLIENTS!!! 9-10-06
            if not matched:
                matched = credentials.checkPassword(user.password)

        else:
            matched = credentials.checkPassword(user.password)
            if not matched:
                matched = credentials.checkPassword(user.tempPassword)

        if not matched:
            return failure.Failure(UnauthorizedError())

        r = user.getRole(role)
        if r:
            print r
            return credentials.username

        #bad role

        return failure.Failure(UnauthorizedError())
def SetUserBanLevel(publicname,banlevel):
    user = User.byName(publicname)
    user.banLevel = banlevel
 def __init__(self,username,role,mind):
     self.username=username
     self.user = User.byName(username)
     self.role = role
     self.mind = mind
Exemple #43
0
 def __init__(self, username, role, mind):
     self.username = username
     self.user = User.byName(username)
     self.role = role
     self.mind = mind
Exemple #44
0
    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)
Exemple #45
0
def ConfigureUsers():
    reg = User(name="MS", password="******")
    reg.addRole(Role.byName("MS"))

    reg2 = User(name="MSP", password="******")
    reg2.addRole(Role.byName("MSP"))
    def requestAvatarId(self, credentials):

        if len(credentials.username.split('-'))!=2:
            return failure.Failure(UnauthorizedError())
            
            
        username,role=credentials.username.split('-')
        
        try:
            banned = BannedUser.byName(username)
            return failure.Failure(BannedError())
        except:
            pass
        
        if THESERVER.roleLimits.has_key(role):
            limit = THESERVER.roleLimits[role]
            if not limit:
                return failure.Failure(ServerFullError())
            n = 0
            for x in MasterPerspective.users:
                
                if role == x[1]:
                    n+=1
                    if n == limit:
                        return failure.Failure(ServerFullError())
                        
        
        roles = ('Player','Immortal','Guardian','World')
        if role in roles:
            for r in roles:
                if (username,r) in MasterPerspective.users[:]:
                    for avatar in THESERVER.realm.avatars[:]:
                        if avatar.username == username and avatar.role.name == r:
                            #kick
                            try:
                                avatar.logout()
                            except:
                                traceback.print_exc()
                                

        
        try:
            user = User.byName(username)

        except SQLObjectNotFound:
            print "User not found",username
            return failure.Failure(UnauthorizedError())
        
        if self.useMD5:
            matched = credentials.checkPassword(md5(user.password).digest())
            if not matched:
                matched = credentials.checkPassword(md5(user.tempPassword).digest())
                
            #XXX REMOVE ME AT A LATER TIME, LEGACY non-md5 using CLIENTS!!! 9-10-06
            if not matched:
                matched = credentials.checkPassword(user.password)

        else:
            matched = credentials.checkPassword(user.password)
            if not matched:
                matched = credentials.checkPassword(user.tempPassword)
            
        if not matched:
            return failure.Failure(UnauthorizedError())
            
        r = user.getRole(role)
        if r:
            print r
            return credentials.username
                        
        #bad role
        
        return failure.Failure(UnauthorizedError())
Exemple #47
0
    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 SetupEmbeddedWorld(worldname):
    global WORLDSERVER
    global MANHOLE

    DATABASE = "sqlite:///%s/%s/data/worlds/singleplayer/%s/world.db" % (
        os.getcwd(), GAMEROOT, worldname)
    SetDBConnection(DATABASE, True)

    #destroy the new player user, and recreate
    try:
        user = User.byName("NewPlayer")
        user.destroySelf()
    except:
        pass

    CreatePlayer()
    IDESetup()

    #--- Application

    from twisted.spread import pb
    from twisted.internet import reactor
    from twisted.cred.credentials import UsernamePassword

    from mud.server.app import Server

    WORLDSERVER = server = Server(3013)
    server.startServices()

    #kickstart the heart
    world = World.byName("TheWorld")

    #TODO, single player backups
    #world.dbFile = os.getcwd()+"/minions.of.mirth/data/worlds/singleplayer/"+worldname+"/world.db"

    try:
        v = int(TGEGetGlobal("$pref::gameplay::difficulty"))
    except:
        v = 0
        TGESetGlobal("$pref::gameplay::difficulty", 0)
    try:
        respawn = float(TGEGetGlobal("$pref::gameplay::monsterrespawn"))
    except:
        TGESetGlobal("$pref::gameplay::monsterrespawn", 0.0)
        respawn = 0.0
    try:
        SPpopulators = int(TGEGetGlobal("$pref::gameplay::SPpopulators"))
    except:
        SPpopulators = 0
        TGESetGlobal("$pref::gameplay::SPpopulators", 0)

    if v == 1:
        CoreSettings.DIFFICULTY = 0
    elif v == 2:
        CoreSettings.DIFFICULTY = 2
    else:
        CoreSettings.DIFFICULTY = 1

    CoreSettings.RESPAWNTIME = respawn
    CoreSettings.SPPOPULATORS = SPpopulators

    CoreSettings.SINGLEPLAYER = True
    world.launchTime = currentTime()
    world.singlePlayer = True

    world.startup()
    world.transactionTick()

    world.tick()
Exemple #49
0
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))
    #now replace to non-file friendly
    WORLDNAME = WORLDNAME.replace("_"," ")
    print THEWORLD.multiName

    from mud.world.newplayeravatar import NewPlayerAvatar,QueryAvatar
    import mud.world.playeravatar
    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"))
    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 SetupEmbeddedWorld(worldname):
    global WORLDSERVER
    global MANHOLE
    
    DATABASE = "sqlite:///%s/%s/data/worlds/singleplayer/%s/world.db"%(os.getcwd(),GAMEROOT,worldname)
    SetDBConnection(DATABASE,True)
    
    #destroy the new player user, and recreate
    try:
        user = User.byName("NewPlayer")
        user.destroySelf()
    except:
        pass
    
    CreatePlayer()
    IDESetup()
    
    #--- Application
    
    from twisted.spread import pb
    from twisted.internet import reactor
    from twisted.cred.credentials import UsernamePassword
    
    from mud.server.app import Server
    
    WORLDSERVER = server = Server(3013)
    server.startServices()
    
    #kickstart the heart
    world = World.byName("TheWorld")
    
    #TODO, single player backups
    #world.dbFile = os.getcwd()+"/minions.of.mirth/data/worlds/singleplayer/"+worldname+"/world.db"
    
    try:
        v = int(TGEGetGlobal("$pref::gameplay::difficulty"))
    except:
        v = 0
        TGESetGlobal("$pref::gameplay::difficulty",0)
    try:
        respawn = float(TGEGetGlobal("$pref::gameplay::monsterrespawn"))
    except:
        TGESetGlobal("$pref::gameplay::monsterrespawn",0.0)
        respawn = 0.0
    try:
        SPpopulators = int(TGEGetGlobal("$pref::gameplay::SPpopulators"))
    except:
        SPpopulators = 0
        TGESetGlobal("$pref::gameplay::SPpopulators",0)
    
    if v == 1:
        CoreSettings.DIFFICULTY = 0
    elif v == 2:
        CoreSettings.DIFFICULTY = 2
    else:
        CoreSettings.DIFFICULTY = 1
    
    CoreSettings.RESPAWNTIME = respawn
    CoreSettings.SPPOPULATORS = SPpopulators
    
    CoreSettings.SINGLEPLAYER = True
    world.launchTime = currentTime()
    world.singlePlayer = True
    
    world.startup()
    world.transactionTick()
    
    world.tick()
    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)
Exemple #54
0
def SetUserBanLevel(publicname, banlevel):
    user = User.byName(publicname)
    user.banLevel = banlevel
Exemple #55
0
    #now replace to non-file friendly
    WORLDNAME = WORLDNAME.replace("_"," ")
    print THEWORLD.multiName

    from mud.world.newplayeravatar import NewPlayerAvatar,QueryAvatar
    import mud.world.playeravatar
    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"))
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 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"))