Beispiel #1
0
    def install(self):
        if not FROMGAME:
            print "Installing Player: %s" % self.dbAttr["publicName"]

        # Restore log and bind zone data for the three realms.
        try:
            bindZone = Zone.byName(self.bindZone)
            logZone = Zone.byName(self.logZone)
        except:
            bindZone = Zone.byName(self.world.startZone)
            logZone = Zone.byName(self.world.startZone)
            self.dbAttr["bindTransformInternal"] = bindZone.immTransform
            self.dbAttr["logTransformInternal"] = logZone.immTransform
        try:
            darknessBindZone = Zone.byName(self.darknessBindZone)
            darknessLogZone = Zone.byName(self.darknessLogZone)
        except:
            darknessBindZone = Zone.byName(self.world.dstartZone)
            darknessLogZone = Zone.byName(self.world.dstartZone)
            self.dbAttr[
                "darknessBindTransformInternal"] = darknessBindZone.immTransform
            self.dbAttr[
                "darknessLogTransformInternal"] = darknessLogZone.immTransform
        try:
            monsterBindZone = Zone.byName(self.monsterBindZone)
            monsterLogZone = Zone.byName(self.monsterLogZone)
        except:
            monsterBindZone = Zone.byName(self.world.mstartZone)
            monsterLogZone = Zone.byName(self.world.mstartZone)
            self.dbAttr[
                "monsterBindTransformInternal"] = monsterBindZone.immTransform
            self.dbAttr[
                "monsterLogTransformInternal"] = monsterLogZone.immTransform
        #todo, initial monster before live

        self.dbAttr["bindZoneID"] = bindZone.id
        self.dbAttr["logZoneID"] = logZone.id
        self.dbAttr["darknessBindZoneID"] = darknessBindZone.id
        self.dbAttr["darknessLogZoneID"] = darknessLogZone.id
        self.dbAttr["monsterBindZoneID"] = monsterBindZone.id
        self.dbAttr["monsterLogZoneID"] = monsterLogZone.id

        FilterColumns(Player, self.dbAttr)
        player = Player(**self.dbAttr)

        # Restore character data on this player.
        for c in self.characters:
            c.install(player)

        # Restore monster spawn data on this player.
        for f in self.mspawns:
            f.install(player)

        # Restore bank items of this player.
        for i in self.items:
            i.install(player, bank=True)
Beispiel #2
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
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)