Example #1
0
 def start_rollback(self,
                    connection,
                    mapname,
                    start_x,
                    start_y,
                    end_x,
                    end_y,
                    ignore_indestructable=True):
     if self.rollback_in_progress:
         return S_ROLLBACK_IN_PROGRESS
     if mapname is None:
         map = self.rollback_map
     else:
         try:
             maps = check_rotation([mapname])
             if not maps:
                 return S_INVALID_MAP_NAME
             map = Map(maps[0]).data
         except MapNotFound as error:
             return error.message
     name = (connection.name if connection is not None else
             S_AUTOMATIC_ROLLBACK_PLAYER_NAME)
     message = S_ROLLBACK_COMMENCED.format(player=name)
     self.send_chat(message, irc=True)
     self.packet_generator = self.create_rollback_generator(
         self.map, map, start_x, start_y, end_x, end_y,
         ignore_indestructable)
     self.rollback_in_progress = True
     self.rollback_start_time = time.time()
     self.rollback_last_chat = self.rollback_start_time
     self.rollback_rows = 0
     self.rollback_total_rows = end_x - start_x
     self.cycle_call = LoopingCall(self.rollback_cycle)
     self.cycle_call.start(self.rollback_time_between_cycles)
Example #2
0
 def set_map_rotation(self, maps: List[str]) -> None:
     """
     Over-writes the current map rotation with provided one.
     `FeatureProtocol.advance_rotation` still needs to be called to actually
     change the map,
     """
     maps = check_rotation(maps, os.path.join(config.config_dir, 'maps'))
     self.maps = maps
     self.map_rotator = self.map_rotator_type(maps)
Example #3
0
 def set_map_rotation(self, maps: List[str], now: bool = True) -> None:
     """
     Over-writes the current map rotation with provided one.
     And advances immediately with the new rotation by default.
     """
     maps = check_rotation(maps, os.path.join(config.config_dir, 'maps'))
     self.maps = maps
     self.map_rotator = self.map_rotator_type(maps)
     if now:
         self.advance_rotation()
Example #4
0
 def set_map_rotation(self, maps, now=True):
     try:
         maps = check_rotation(maps, os.path.join(cfg.config_dir, 'maps'))
     except MapNotFound as e:
         return e
     self.maps = maps
     self.map_rotator = self.map_rotator_type(maps)
     if now:
         self.advance_rotation()
     return True
Example #5
0
def load_map(connection, map):
    """
    Instantly switches map to the specified
    /loadmap <mapname>
    """
    protocol = connection.protocol

    try:
        protocol.planned_map = check_rotation([map])[0]
        protocol.advance_rotation()
    except MapNotFound:
        return 'Map %s not found' % (map)
Example #6
0
 def show_result(self):
     result = self.votes_left()['name']
     if result == "extend":
         tl = self.protocol.set_time_limit(self.extension_time, True)
         span = prettify_timespan(tl * 60.0)
         self.protocol.send_chat('Mapvote ended. Current map will '
                                 'continue for %s.' % span, irc=True)
         self.protocol.autoschedule_votemap()
     else:
         self.protocol.send_chat('Mapvote ended. Next map will be: %s.' %
                                 result, irc=True)
         self.protocol.planned_map = check_rotation([result])[0]
     self.set_cooldown()
Example #7
0
def change_planned_map(connection, *pre_maps):
    name = connection.name
    protocol = connection.protocol

    # parse seed numbering
    maps, _map_list = parse_maps(pre_maps)
    if not maps:
        return 'Invalid map name'

    planned_map = maps[0]
    try:
        protocol.planned_map = check_rotation([planned_map])[0]
        protocol.send_chat('%s changed next map to %s' % (name, planned_map),
                           irc=True)
    except MapNotFound:
        return 'Map %s not found' % (maps[0])
Example #8
0
def change_planned_map(connection, *pre_maps):
    """
    Set the next map to be loaded after current game ends and inform everyone of it
    /map <mapname>
    """
    name = connection.name
    protocol = connection.protocol

    # parse seed numbering
    maps, _map_list = parse_maps(pre_maps)
    if not maps:
        return 'Invalid map name'

    planned_map = maps[0]
    try:
        protocol.planned_map = check_rotation([planned_map])[0]
        protocol.send_chat('%s changed next map to %s' % (name, planned_map),
                           irc=True)
    except MapNotFound:
        return 'Map %s not found' % (maps[0])
Example #9
0
 def set_map_rotation(self, maps, now=True):
     try:
         maps = check_rotation(maps, os.path.join(cfg.config_dir, 'maps'))
     except MapNotFound, e:
         return e