pyplanet.contrib.map¶
The map contrib will provide map list and information to the apps and core.
-
class
pyplanet.contrib.map.
MapManager
(instance)[source]¶ Map Manager. Manages the current map pool and the current and next map.
Todo
Write introduction.
Warning
Don’t initiate this class yourself.
-
add_map
(filename, insert=True, save_matchsettings=True)[source]¶ Add or insert map to current online playlist.
Parameters: - filename (str) – Load from filename relative to the ‘Maps’ directory on the dedicated host server.
- insert (bool) – Insert after the current map, this will make it play directly after the current map. True by default.
- save_matchsettings (bool) – Save match settings as well.
Raise: pyplanet.contrib.map.exceptions.MapIncompatible
Raise: pyplanet.contrib.map.exceptions.MapException
-
current_map
¶ The current map, database model instance.
Return type: pyplanet.apps.core.maniaplanet.models.Map
-
extend_ta
(extend_with=None)[source]¶ Extend time limit of the current map. Extend with given seconds, or double the original TA timer if None is given.
Parameters: extend_with (int) – Extend with the given seconds, or None for adding the original TA limit to the current limit(double) Returns:
-
get_map
(uid=None)[source]¶ Get map instance by uid.
Parameters: uid – By uid (pk). Returns: Player or exception if not found
Get the map author nickname by map details. If the map details contains an empty nickname, a GetMapInfo call to the server will be made. This is because TM2020 does not yet return the author nickname via GetMapList, but does via GetMapInfo.
Parameters: map_details – struct containing map details Returns: author nickname (None if not found)
-
get_map_by_index
(index)[source]¶ Get map instance by index id (primary key).
Parameters: index – Primary key index. Returns: Map instance or raise exception.
-
handle_map_change
(info)[source]¶ This will be called from the glue that creates the signal ‘maniaplanet:map_begin’ or ‘map_end’.
Parameters: info – Mapinfo in dict. Returns: Map instance. Return type: pyplanet.apps.core.maniaplanet.models.map.Map
-
load_matchsettings
(filename)[source]¶ Load Match Settings file and insert it into the current map playlist.
Parameters: filename – File to load, relative to Maps folder. Returns: Boolean if loaded.
-
maps
¶ Get the maps that are currently loaded on the server. The list should contain model instances of the currently loaded matchsettings. This list should be up-to-date.
Return type: list
-
next_map
¶ The next scheduled map.
Return type: pyplanet.apps.core.maniaplanet.models.Map
-
playlist_has_map
(uid)[source]¶ Check if our current playlist has a map with the UID given.
Parameters: uid – UID String Returns: Boolean, True if it’s in our current playlist (match settings in our session).
-
previous_map
¶ The previously played map, or None if not known!
Return type: pyplanet.apps.core.maniaplanet.models.Map
-
remove_map
(map, delete_file=False)[source]¶ Remove and optionally delete file from server and playlist.
Parameters: - map – Map instance or filename in string.
- delete_file (bool) – Boolean to decide if we are going to remove the file from the server too. Defaults to False.
Raise: pyplanet.contrib.map.exceptions.MapException
Raise: pyplanet.core.storage.exceptions.StorageException
-
save_matchsettings
(filename=None)[source]¶ Save the current playlist and configuration to the matchsettings file.
Parameters: filename (str) – Give the filename of the matchsettings, Leave empty to use the current loaded and configured one. Raise: pyplanet.contrib.map.exceptions.MapException Raise: pyplanet.core.storage.exceptions.StorageException
-
set_current_map
(map)[source]¶ Set the current map and jump to it.
Parameters: map – Map instance or uid.
-
set_next_map
(map)[source]¶ Set the next map. This will prepare the manager to set the next map and will communicate the next map to the dedicated server.
The Map parameter can be a map instance or the UID of the map.
Parameters: map (pyplanet.apps.core.maniaplanet.models.Map, str) – Map instance or UID string.
-
upload_map
(fh, filename, insert=True, overwrite=False)[source]¶ Upload and add/insert the map to the current online playlist.
Parameters: - fh – File handler, bytesio object or any readable context.
- filename (str) – The filename when saving on the server. Must include the map.gbx! Relative to ‘Maps’ folder.
- insert (bool) – Insert after the current map, this will make it play directly after the current map. True by default.
- overwrite (bool) – Overwrite current file if exists? Default False.
Raise: pyplanet.contrib.map.exceptions.MapIncompatible
Raise: pyplanet.contrib.map.exceptions.MapException
Raise: pyplanet.core.storage.exceptions.StorageException
-