Overview¶
Path | PyPoE/poe/sim/mods.py |
Version | 1.0.0a0 |
Revision | $Id: a887c5ad480fe2a81026962eaafbb642e48d967a $ |
Author | Omega_K2 |
Description¶
Utilities for dealing with Mods.dat.
This module implements some generic functions to simplify dealing with Mods.dat and perform several common tasks.
Warning
This module is intended to be used with
PyPoE.poe.file.dat.RelationalReader
.
Agreement¶
See PyPoE/LICENSE
Documentation¶
-
class
PyPoE.poe.sim.mods.
SpawnChanceCalculator
(mod_list, tags)[source]¶ Bases:
object
Class to calculate spawn chances.
-
get_mod
(mod_id)[source]¶ Returns the mod for the specified mod id based on the stored modifier list or None if it isn’t found.
Parameters: mod_id (str) – The mod identifier to look for Returns: Returns the mod if found, None otherwise Return type: DatRecord or None See also
-
get_spawn_weight
(mod)[source]¶ Calculates the spawn weight of the given mod based on the stored list of tags.
Parameters: Returns: Calculated spawn weight
Return type: See also
-
get_total_spawn_weight
()[source]¶ Calculate the total spawn weight based on the stored modifier list
Returns: Sum of spawn weights Return type: int
-
spawn_chance
(mod_or_id, remove=True)[source]¶ Calculates the spawn chance for the given mod based on the tags and the mod list given to this instance.
If remove is specified the mod is also removed from the mod list. It is recommended to leave this option enabled, as it will take care of updating tags and mods of the same grouping, which will guarantee that future mods rolled on this instance will be calculated properly.
Parameters: - mod_or_id (str | DatRecord) – Id of the mod or the instance of the mod row
- remove (bool) – Remove the mod from the list once the chance has been calculated
Returns: The calculated spawn chance for the mod
Return type: Raises: TypeError
– if mod_or_id has an invalid typeValueError
– if mod_or_id not found
-
-
PyPoE.poe.sim.mods.
get_translation
(mod, translation_cache, translation_file=None, **kwargs)[source]¶ Returns the Translation result of the stats found on the specified mod using the specified TranslationFileCache.
Parameters: - mod (DatRecord) –
- translation_cache (TranslationFileCache) –
PyPoE.poe.file.TranslationCache
instance to retrieve the translation file from. - translation_file (str) – Name of the translation file to use. If left empty, it will be automatically determined based on the mod domain.
Returns: Return type:
-
PyPoE.poe.sim.mods.
get_translation_file_from_domain
(domain)[source]¶ Returns the likely stat translation file for a given mod domain.
Parameters: domain (int) – Id of the domain Returns: name of the stat translation file Return type: str
-
PyPoE.poe.sim.mods.
get_mod_from_id
(mod_id, mod_list)[source]¶ Returns the mod for given mod or None if it isn’t found.
Parameters: Returns: Returns the mod if found, None otherwise
Return type: DatRecord or None
-
PyPoE.poe.sim.mods.
get_spawn_weight
(mod, tags)[source]¶ Calculates the spawn weight of the given mod for the given tags.
Parameters: Returns: Calculated spawn weight
Return type:
-
PyPoE.poe.sim.mods.
generate_spawnable_mod_list
(mod_dat_file, domain, generation_type, level=1, tags=['default'])[source]¶ Generates a list of modifiers that can be spawned for the specified parameters, i.e. mods that can not spawn will be removed.
TODO: Certain generation types/domains may have different rules.
Parameters: - mod_dat_file (DatFile) –
- domain (MOD_DOMAIN) – The mod domain
- generation_type (MOD_GENERATION_TYPE) – The mod generation type
- level (int) – The level of object to the mod would be spawned on
- tags (list[str]) – List of tags for this object
Returns: Returns a list of applicable mod rows that have a spawn weighting above 0.
Return type: list[DatRecord]
Raises: TypeError
– if domain is not a valid MOD_DOMAIN constant if generation_type is not a valid MOD_GENERATION_TYPE constant