示例#1
0
 def spawn(self, data):
     """
     Warps your ship to spawn.
     Syntax: /spawn
     """
     for warp in self.pois:
         if warp[1] == 'spawn':
             x, y, z, planet, satellite = warp[0].split(':')
             x, y, z, planet, satellite = map(
                 int, (x, y, z, planet, satellite)
             )
             warp_packet = build_packet(
                 Packets.FLY_SHIP,
                 fly_ship_write(
                     x=x,
                     y=y,
                     z=z,
                     planet=planet,
                     satellite=satellite
                 )
             )
             self.protocol.client_protocol.transport.write(warp_packet)
             self.protocol.send_chat_message(
                 'Warp drive engaged! Warping to ^yellow;Spawn^green;.'
             )
             return
         else:
             self.protocol.send_chat_message(
                 'The spawn planet must be set first!'
             )
示例#2
0
    def poi(self, name):
        """Warps your ship to a Planet of Interest (PoI).\nSyntax: /poi [name] *omit name for a list of PoI's"""
        name = " ".join(name).strip().strip("\t")
        if len(name) == 0:
            warps = []
            for warp in self.pois:
                if warps != "":
                    warps.append(warp[1])
            warpnames = "^green;, ^yellow;".join(warps)
            if warpnames == "": warpnames = "^gray;(none)^green;"
            self.protocol.send_chat_message(self.poi.__doc__)
            self.protocol.send_chat_message("List of PoI's: ^yellow;" + warpnames)
            return

        on_ship = self.protocol.player.on_ship
        if not on_ship:
            self.protocol.send_chat_message("You need to be on a ship!")
            return

        for warp in self.pois:
            if warp[1] == name:
                x, y, z, planet, satellite = warp[0].split(":")
                x, y, z, planet, satellite = map(int, (x, y, z, planet, satellite))
                warp_packet = build_packet(Packets.FLY_SHIP,
                                           fly_ship_write(x=x,
                                                          y=y,
                                                          z=z,
                                                          planet=planet,
                                                          satellite=satellite))
                self.protocol.client_protocol.transport.write(warp_packet)
                self.protocol.send_chat_message("Warp drive engaged! Warping to ^yellow;%s^green;." % name)
                return
        self.protocol.send_chat_message("There is no PoI named ^yellow;%s^green;." % name)
def move_ship_to_coords(protocol, x, y, z, planet, satellite):
    logger.info("Moving %s's ship to coordinates: %s", protocol.player.name,
                ":".join((str(x), str(y), str(z), str(planet), str(satellite))))
    x, y, z, planet, satellite = map(int, (x, y, z, planet, satellite))
    warp_packet = build_packet(packets.Packets.FLY_SHIP,
                               packets.fly_ship_write(x=x, y=y, z=z, planet=planet,
                                                      satellite=satellite))
    protocol.client_protocol.transport.write(warp_packet)
示例#4
0
    def goto(self, name):
        """
        Warps your ship to a previously bookmarked planet.
        Syntax: /goto [name] *omit name for a list of bookmarks
        """
        filename = os.path.join(
            'config', 'bookmarks', '{}.json'.format(self.protocol.player.uuid)
        )
        try:
            with open(filename) as f:
                self.bookmarks = json.load(f)
        except:
            self.bookmarks = []
        name = ' '.join(name).strip().strip('\t')
        if name:
            warps = []
            for warp in self.bookmarks:
                if warp:
                    warps.append(warp[1])
            warpnames = '^green;,^yellow; '.join(warps)
            if warpnames == '':
                warpnames = '^gray;(none)^green;'
            self.protocol.send_chat_message(self.goto.__doc__)
            self.protocol.send_chat_message(
                'Bookmarks: ^yellow;{}'.format(warpnames)
            )
            return

        on_ship = self.protocol.player.on_ship
        if not on_ship:
            self.protocol.send_chat_message('You need to be on a ship!')
            return

        for warp in self.bookmarks:
            if warp[1] == name:
                x, y, z, planet, satellite = map(int, warp[0].split(':'))
                warp_packet = build_packet(
                    Packets.FLY_SHIP,
                    fly_ship_write(
                        x=x,
                        y=y,
                        z=z,
                        planet=planet,
                        satellite=satellite
                    )
                )
                self.protocol.client_protocol.transport.write(warp_packet)
                self.protocol.send_chat_message(
                    'Warp drive engaged! Warping to ^yellow;{}^green;.'.format(
                        name
                    )
                )
                return
        self.protocol.send_chat_message(
            'There is no bookmark named: ^yellow;%s'.format(name)
        )
示例#5
0
def move_ship_to_coords(protocol, x, y, z, planet, satellite):
    logger.info('Moving %s\'s ship to coordinates: %s', protocol.player.name,
                ':'.join(map(str, (x, y, z, planet, satellite))))
    x, y, z, planet, satellite = map(int, (x, y, z, planet, satellite))
    warp_packet = build_packet(
        packets.Packets.FLY_SHIP,
        packets.fly_ship_write(x=x,
                               y=y,
                               z=z,
                               planet=planet,
                               satellite=satellite))
    protocol.client_protocol.transport.write(warp_packet)
示例#6
0
    def poi(self, name):
        """
        Warps your ship to a Planet of Interest (PoI).
        Syntax: /poi [name] *omit name for a list of PoI's
        """
        name = ' '.join(name).strip().strip('\t')
        if not name:
            warps = [warp[1] for warp in self.pois]
            warpnames = '^green;, ^yellow;'.join(warps)
            if not warpnames:
                warpnames = '^gray;(none)^green;'

            self.protocol.send_chat_message(self.poi.__doc__)
            self.protocol.send_chat_message(
                "List of PoI's: ^yellow;{}".format(warpnames)
            )
            return

        on_ship = self.protocol.player.on_ship
        if not on_ship:
            self.protocol.send_chat_message('You need to be on a ship!')
            return

        for warp in self.pois:
            if warp[1] == name:
                x, y, z, planet, satellite = warp[0].split(':')
                x, y, z, planet, satellite = map(
                    int, (x, y, z, planet, satellite)
                )
                warp_packet = build_packet(
                    Packets.FLY_SHIP,
                    fly_ship_write(
                        x=x,
                        y=y,
                        z=z,
                        planet=planet,
                        satellite=satellite
                    )
                )
                self.protocol.client_protocol.transport.write(warp_packet)
                self.protocol.send_chat_message(
                    'Warp drive engaged! Warping to ^yellow;{}^green;.'.format(
                        name
                    )
                )
                return
        self.protocol.send_chat_message(
            'There is no PoI named ^yellow;{}^green;.', name
        )
示例#7
0
 def spawn(self, data):
     """Warps your ship to spawn.\nSyntax: /spawn"""
     for warp in self.pois:
         if warp[1] == 'spawn':
             x, y, z, planet, satellite = warp[0].split(":")
             x, y, z, planet, satellite = map(int, (x, y, z, planet, satellite))
             warp_packet = build_packet(Packets.FLY_SHIP,
                                        fly_ship_write(x=x,
                                                       y=y,
                                                       z=z,
                                                       planet=planet,
                                                       satellite=satellite))
             self.protocol.client_protocol.transport.write(warp_packet)
             self.protocol.send_chat_message("Warp drive engaged! Warping to ^yellow;%s^green;." % 'Spawn')
             return
         else:
             self.protocol.send_chat_message("The spawn planet must be set first!")
示例#8
0
    def poi(self, name):
        """
        Warps your ship to a Planet of Interest (PoI).
        Syntax: /poi [name] *omit name for a list of PoI's
        """
        name = ' '.join(name).strip().strip('\t')
        if not name:
            warps = [warp[1] for warp in self.pois]
            warpnames = '^green;, ^yellow;'.join(warps)
            if not warpnames:
                warpnames = '^gray;(none)^green;'

            self.protocol.send_chat_message(self.poi.__doc__)
            self.protocol.send_chat_message(
                "List of PoI's: ^yellow;{}".format(warpnames))
            return

        on_ship = self.protocol.player.on_ship
        if not on_ship:
            self.protocol.send_chat_message('You need to be on a ship!')
            return

        for warp in self.pois:
            if warp[1] == name:
                x, y, z, planet, satellite = warp[0].split(':')
                x, y, z, planet, satellite = map(int,
                                                 (x, y, z, planet, satellite))
                warp_packet = build_packet(
                    Packets.FLY_SHIP,
                    fly_ship_write(x=x,
                                   y=y,
                                   z=z,
                                   planet=planet,
                                   satellite=satellite))
                self.protocol.client_protocol.transport.write(warp_packet)
                self.protocol.send_chat_message(
                    'Warp drive engaged! Warping to ^yellow;{}^green;.'.format(
                        name))
                return
        self.protocol.send_chat_message(
            'There is no PoI named ^yellow;{}^green;.', name)
示例#9
0
    def goto(self, name):
        """Warps your ship to a previously bookmarked planet.\nSyntax: /goto [name] *omit name for a list of bookmarks"""
        filename = "./config/bookmarks/" + self.protocol.player.uuid + ".json"
        try:
            with open(filename) as f:
                self.bookmarks = json.load(f)
        except:
            self.bookmarks = []
        name = " ".join(name).strip().strip("\t")
        if len(name) == 0:
            warps = []
            for warp in self.bookmarks:
                if warps != "":
                    warps.append(warp[1])
            warpnames = "^green;,^yellow; ".join(warps)
            if warpnames == "": warpnames = "^gray;(none)^green;"
            self.protocol.send_chat_message(self.goto.__doc__)
            self.protocol.send_chat_message("Bookmarks: ^yellow;" + warpnames)
            return

        on_ship = self.protocol.player.on_ship
        if not on_ship:
            self.protocol.send_chat_message("You need to be on a ship!")
            return

        for warp in self.bookmarks:
            if warp[1] == name:
                x, y, z, planet, satellite = warp[0].split(":")
                x, y, z, planet, satellite = map(int, (x, y, z, planet, satellite))
                warp_packet = build_packet(Packets.FLY_SHIP,
                                           fly_ship_write(x=x,
                                                          y=y,
                                                          z=z,
                                                          planet=planet,
                                                          satellite=satellite))
                self.protocol.client_protocol.transport.write(warp_packet)
                self.protocol.send_chat_message("Warp drive engaged! Warping to ^yellow;%s^green;." % name)
                return
        self.protocol.send_chat_message("There is no bookmark named: ^yellow;%s" % name)