Exemplo n.º 1
0
class TestPlayerEntity(unittest.TestCase):
    def setUp(self):
        self.p = Player(username="******")

    def test_trivial(self):
        pass

    def test_player_serialization(self):
        self.p.save_to_packet()
Exemplo n.º 2
0
class TestPlayerEntity(unittest.TestCase):

    def setUp(self):
        self.p = Player(username="******")

    def test_trivial(self):
        pass

    def test_player_serialization(self):
        self.p.save_to_packet()
Exemplo n.º 3
0
    def load_player(self, username):
        fp = self.folder.child("players").child("%s.dat" % username)
        if not fp.exists():
            raise SerializerReadException("%r doesn't exist!" % username)

        tag = self._read_tag(fp)
        if not tag:
            raise SerializerReadException("%r (in %s) is corrupt!" %
                                          (username, fp.path))

        try:
            player = Player(username=username)
            x, y, z = [i.value for i in tag["Pos"].tags]
            player.location.pos = Position(x, y, z)

            yaw = tag["Rotation"].tags[0].value
            pitch = tag["Rotation"].tags[1].value
            player.location.ori = Orientation.from_degs(yaw, pitch)

            if "Inventory" in tag:
                self._load_inventory_from_tag(player.inventory,
                                              tag["Inventory"])
        except KeyError, e:
            raise SerializerReadException("%r couldn't be loaded: %s" %
                                          (player, e))
Exemplo n.º 4
0
    def test_load_player_first(self):
        """
        Loading a non-existent player raises an SRE.
        """

        self.assertRaises(SerializerReadException, self.s.load_player,
                Player(username="******"))
Exemplo n.º 5
0
        def eb(failure):
            failure.trap(SerializerReadException)
            log.msg("Couldn't load player %r" % username)

            # Make a player.
            player = Player(username=username)
            player.location.x = self.level.spawn[0]
            player.location.y = self.level.spawn[1]
            player.location.stance = self.level.spawn[1]
            player.location.z = self.level.spawn[2]

            return player
Exemplo n.º 6
0
    def load_player(self, username):
        """
        Retrieve player data.
        """

        player = Player(username=username)
        player.location.x = self.spawn[0]
        player.location.y = self.spawn[1]
        player.location.stance = self.spawn[1]
        player.location.z = self.spawn[2]

        self.serializer.load_player(player)

        return player
Exemplo n.º 7
0
    def load_player(self, username):
        """
        Retrieve player data.

        :returns: a ``Deferred`` that will be fired with a ``Player``
        """

        player = Player(username=username)
        player.location.x = self.spawn[0]
        player.location.y = self.spawn[1]
        player.location.stance = self.spawn[1]
        player.location.z = self.spawn[2]

        d = maybeDeferred(self.serializer.load_player, player)
        d.addCallback(lambda none: player)
        return d
Exemplo n.º 8
0
    def load_player(self, username):
        """
        Retrieve player data.

        :returns: a ``Deferred`` that will be fired with a ``Player``
        """

        player = Player(username=username)
        player.location.x = self.spawn[0]
        player.location.y = self.spawn[1]
        player.location.stance = self.spawn[1]
        player.location.z = self.spawn[2]

        d = maybeDeferred(self.serializer.load_player, player)

        @d.addErrback
        def eb(failure):
            failure.trap(SerializerReadException)
            log.msg("Couldn't load player %r" % username)

        # Add a callback to return the player, since ISerializer.load_player()
        # doesn't return the player.
        d.addCallback(lambda none: player)
        return d
Exemplo n.º 9
0
 def setUp(self):
     self.p = Player(username="******")
Exemplo n.º 10
0
 def __init__(self):
     self.player = Player(bravo.location.Location(), eid=0)
Exemplo n.º 11
0
 def setUp(self):
     self.p = Player("unittest")
Exemplo n.º 12
0
 def setUp(self):
     self.p = Player(username="******")