def warp_player_to_player(self, from_string, to_string): from_player = self.player_manager.get_logged_in_by_name(from_string) to_player = self.player_manager.get_logged_in_by_name(to_string) if from_player is not None: if to_player is not None: from_protocol = self.factory.protocols[from_player.protocol] if from_player is not to_player: warp_packet = build_packet(Packets.WARP_COMMAND, warp_command_write(t="WARP_OTHER_SHIP", player=to_player.name.encode('utf-8'))) else: warp_packet = build_packet(Packets.WARP_COMMAND, warp_command_write(t='WARP_UP')) from_protocol.client_protocol.transport.write(warp_packet) if from_string != to_string: self.protocol.send_chat_message("Warped ^yellow;%s^green; to ^yellow;%s^green;." % (from_string, to_string)) else: self.protocol.send_chat_message("Warped to ^yellow;%s^green;." % to_string) else: self.protocol.send_chat_message("No player by the name ^yellow;%s^green; found." % to_string) self.protocol.send_chat_message(self.warp.__doc__) return else: self.protocol.send_chat_message("No player by the name ^yellow;%s^green; found." % from_string) self.protocol.send_chat_message(self.warp.__doc__)
def warp_player_to_player(self, from_string, to_string): self.logger.debug( "Warp player-to-player command called by %s: %s to %s", self.protocol.player.name, from_string, to_string) from_player = self.player_manager.get_logged_in_by_name(from_string) to_player = self.player_manager.get_logged_in_by_name(to_string) if from_player is not None: if to_player is not None: from_protocol = self.factory.protocols[from_player.protocol] if from_player is not to_player: warp_packet = build_packet( Packets.WARP_COMMAND, warp_command_write( t="WARP_OTHER_SHIP", player=to_player.name.encode('utf-8'))) else: warp_packet = build_packet(Packets.WARP_COMMAND, warp_command_write(t='WARP_UP')) from_protocol.client_protocol.transport.write(warp_packet) else: self.protocol.send_chat_message( "No player by the name %s found." % to_string) self.protocol.send_chat_message(self.warp.__doc__) return else: self.protocol.send_chat_message("No player by the name %s found." % from_string) self.protocol.send_chat_message(self.warp.__doc__)
def warp_player_to_player(self, from_string, to_string): self.logger.debug("Warp player-to-player command called by %s: %s to %s", self.protocol.player.name, from_string, to_string) from_player = self.player_manager.get_logged_in_by_name(from_string) to_player = self.player_manager.get_logged_in_by_name(to_string) print from_player print to_player if from_player is not None: if to_player is not None: from_protocol = self.factory.protocols[from_player.protocol] if from_player is not to_player: warp_packet = build_packet(Packets.WARP_COMMAND, warp_command_write(t="WARP_OTHER_SHIP", player=to_player.name.encode('utf-8'))) print warp_packet else: warp_packet = build_packet(Packets.WARP_COMMAND, warp_command_write(t='WARP_UP')) from_protocol.client_protocol.transport.write(warp_packet) else: self.protocol.send_chat_message("No player by the name %s found." % to_string) self.protocol.send_chat_message(self.warp.__doc__) return else: self.protocol.send_chat_message("No player by the name %s found." % from_string) self.protocol.send_chat_message(self.warp.__doc__)
def warp(self, name): """Warps you to a planet. Syntax: /warp [warp name]""" name = " ".join(name).strip().strip("\t") if len(name) == 0: warps = [] for warp in self.planet_warps: if warps != "": warps.append(warp[1]) warpnames = " ".join(warps) self.protocol.send_chat_message("List of planet warps:\n "+warpnames) return for warp in self.planet_warps: if warp[1] == name: sector, 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.WARP_COMMAND, warp_command_write(t="MOVE_SHIP", sector=sector, x=x, y=y, z=z, planet=planet, satellite=satellite)) self.protocol.client_protocol.transport.write(warp_packet) warp_packet = build_packet(Packets.WARP_COMMAND, warp_command_write(t="WARP_DOWN")) self.protocol.client_protocol.transport.write(warp_packet) self.protocol.send_chat_message("Warped.") return self.protocol.send_chat_message("No warp with that name!")
def warp(self, name): """Warps you to a planet. Syntax: /warp [warp name]""" name = " ".join(name).strip().strip("\t") if len(name) == 0: warps = [] for warp in self.planet_warps: if warps != "": warps.append(warp[1]) warpnames = " ".join(warps) self.protocol.send_chat_message("List of planet warps:\n " + warpnames) return for warp in self.planet_warps: if warp[1] == name: sector, 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.WARP_COMMAND, warp_command_write(t="MOVE_SHIP", sector=sector, x=x, y=y, z=z, planet=planet, satellite=satellite), ) self.protocol.client_protocol.transport.write(warp_packet) warp_packet = build_packet(Packets.WARP_COMMAND, warp_command_write(t="WARP_DOWN")) self.protocol.client_protocol.transport.write(warp_packet) self.protocol.send_chat_message("Warped.") return self.protocol.send_chat_message("No warp with that name!")
def home(self, arg): """Warps you to your home planet.\nSyntax: /home""" player = self.player_manager.get_logged_in_by_name(self.protocol.player.name) from_protocol = self.factory.protocols[player.protocol] warp_packet = build_packet(Packets.WARP_COMMAND, warp_command_write(t='WARP_HOME')) from_protocol.client_protocol.transport.write(warp_packet) self.protocol.send_chat_message("^yellow;%s^green; warped to their home planet." % self.protocol.player.name)
def poi(self, name): """Moves you and your ship to a Planet of Interest (PoI). Syntax: /poi [name] *omit [name] for list of PoI's""" name = " ".join(name).strip().strip("\t") if len(name) == 0: warps = [] for warp in self.planet_warps: if warps != "": warps.append(warp[1]) warpnames = "^green;, ^yellow;".join(warps) 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.planet_warps: if warp[1] == name: sector, 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.WARP_COMMAND, warp_command_write(t="MOVE_SHIP", sector=sector, x=x, y=y, z=z, planet=planet, satellite=satellite), ) self.protocol.client_protocol.transport.write(warp_packet) # warp_packet = build_packet(Packets.WARP_COMMAND, # warp_command_write(t="WARP_DOWN")) # self.protocol.client_protocol.transport.write(warp_packet) # self.protocol.send_chat_message("Beamed down to ^yellow;%s^green; and your ship will arrive soon." % name) self.protocol.send_chat_message("Warp drive engaged! Warping to ^yellow;%s^green;." % name) return self.protocol.send_chat_message("There is no PoI with that name!")
def beam_to_planet(self, where): warp_packet = build_packet(Packets.WARP_COMMAND, warp_command_write(t="WARP_DOWN")) self.protocol.client_protocol.transport.write(warp_packet) self.protocol.send_chat_message("Beamed down to ^yellow;%s^green; and your ship will arrive soon." % where) self.factory.broadcast_planet( "%s^green; beamed down to the planet" % self.protocol.player.colored_name(self.config.colors), planet=self.protocol.player.planet)
def warp_self_to_player(self, name): self.logger.debug("Warp command called by %s to %s", self.protocol.player.name, name) name = " ".join(name) target_player = self.player_manager.get_logged_in_by_name(name) if target_player is not None: if target_player is not self.protocol.player: warp_packet = build_packet(Packets.WARP_COMMAND, warp_command_write(t="WARP_OTHER_SHIP", player=target_player.name.encode('utf-8'))) else: warp_packet = build_packet(Packets.WARP_COMMAND, warp_command_write(t='WARP_UP')) self.protocol.client_protocol.transport.write(warp_packet) else: self.protocol.send_chat_message("No player by the name %s found." % name) self.protocol.send_chat_message(self.warp.__doc__)
def move_ship_to_coords(protocol, sector, x, y, z, planet, satellite): logger.info("Moving %s's ship to coordinates: %s", protocol.player.name, ":".join((sector, 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.WARP_COMMAND, packets.warp_command_write(t="MOVE_SHIP", sector=sector, x=x, y=y, z=z, planet=planet, satellite=satellite, player="".encode('utf-8'))) protocol.client_protocol.transport.write(warp_packet)
def beam_to_planet(self, where): warp_packet = build_packet(Packets.WARP_COMMAND, warp_command_write(t="WARP_DOWN")) self.protocol.client_protocol.transport.write(warp_packet) self.protocol.send_chat_message( "Beamed down to ^yellow;%s^green; and your ship will arrive soon." % where) self.factory.broadcast_planet( "%s^green; beamed down to the planet" % self.protocol.player.colored_name(self.config.colors), planet=self.protocol.player.planet)
def move_ship_to_coords(protocol, sector, x, y, z, planet, satellite): logger.info( "Moving %s's ship to coordinates: %s", protocol.player.name, ":".join( (sector, 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.WARP_COMMAND, packets.warp_command_write(t="MOVE_SHIP", sector=sector, x=x, y=y, z=z, planet=planet, satellite=satellite, player="".encode('utf-8'))) protocol.client_protocol.transport.write(warp_packet)
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: sector, 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.WARP_COMMAND, warp_command_write(t="MOVE_SHIP", sector=sector, 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)
def poi(self, name): """Moves you and your ship to a Planet of Interest (PoI). Syntax: /poi <PoI name> or /poi for list of PoI's""" name = " ".join(name).strip().strip("\t") if len(name) == 0: warps = [] for warp in self.planet_warps: if warps != "": warps.append(warp[1]) warpnames = "^shadow,green;, ^shadow,yellow;".join(warps) self.protocol.send_chat_message("List of PoI's: ^shadow,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.planet_warps: if warp[1] == name: sector, 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.WARP_COMMAND, warp_command_write(t="MOVE_SHIP", sector=sector, x=x, y=y, z=z, planet=planet, satellite=satellite)) self.protocol.client_protocol.transport.write(warp_packet) # warp_packet = build_packet(Packets.WARP_COMMAND, # warp_command_write(t="WARP_DOWN")) # self.protocol.client_protocol.transport.write(warp_packet) # self.protocol.send_chat_message("Beamed down to ^shadow,yellow;%s^shadow,green; and your ship will arrive soon." % name) self.protocol.send_chat_message( "Warp drive engaged! Warping to ^shadow,yellow;%s^shadow,green;." % name) return self.protocol.send_chat_message("There is no PoI with that name!")
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: sector, 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.WARP_COMMAND, warp_command_write(t="MOVE_SHIP", sector=sector, 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)
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: sector, 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.WARP_COMMAND, warp_command_write(t="MOVE_SHIP", sector=sector, 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) #reactor.callLater(1, self.beam_to_planet, name) # enable this for 1s delayed warping of a player return self.protocol.send_chat_message( "There is no PoI named ^yellow;%s^green;." % name)
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: sector, 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.WARP_COMMAND, warp_command_write(t="MOVE_SHIP", sector=sector, 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) #reactor.callLater(1, self.beam_to_planet, name) # enable this for 1s delayed warping of a player return self.protocol.send_chat_message("There is no PoI named ^yellow;%s^green;." % name)