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.
-
async
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
-
property
current_map
¶ The current map, database model instance.
- Return type
pyplanet.apps.core.maniaplanet.models.Map
-
async
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
-
async
get_map
(uid=None)[source]¶ Get map instance by uid.
- Parameters
uid – By uid (pk).
- Returns
Player or exception if not found
-
async
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.
-
async
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
-
async
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.
-
property
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
-
property
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).
-
property
previous_map
¶ The previously played map, or None if not known!
- Return type
pyplanet.apps.core.maniaplanet.models.Map
-
async
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
-
async
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
-
async
set_current_map
(map)[source]¶ Set the current map and jump to it.
- Parameters
map – Map instance or uid.
-
async
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.
-
async
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
-
async