utils module¶
-
class
utils.Biome(biome_size, world_coords: Tuple[int, int])¶ Bases:
objectBiomes contain locations and subtly effect player actions.
-
property
color_name¶
-
static
gen_name(type_id: str) → str¶ Generates name for biome.
- Parameters
type_id – urban, suburban, or rural
- Returns
Generated name
-
property
-
class
utils.Container(type_id: str, items: List[utils.Item] = None, name: str = None, explicit: bool = False)¶ Bases:
object
-
exception
utils.InventoryError¶ Bases:
Exception
-
class
utils.Item(item_id, water_oz=None)¶ Bases:
object-
calc_weight()¶
-
property
color_name¶
-
property
water_units¶
-
-
class
utils.Line(line_id: str, line_text: str, line_requirements: List[str], line_actions: List[str], line_returns: Dict[str, str])¶ Bases:
objectContainer object for Clem-formatted game text.
-
class
utils.NPC(name, gender, kindness=None, bicurious=None)¶ Bases:
objectNPC object that exists in and manipulates the world. Commonly referred to as ‘player’.
-
consume_ammo(ammo_type, amount=1)¶
-
count_ammo(ammo_type: str) → int¶ Polls inventory for ammo of specific type
- Parameters
ammo_type – Type of ammo. Types are defined in weapons.csv and items.csv
- Returns
Amount of matched ammo in inventory
-
damage(amount: int, limb: str = None)¶ Deal damage to NPC.
- Parameters
amount – Amount of damage to inflict
limb – Limb to damage - ‘l_arm’, ‘r_arm’, ‘l_leg’, ‘r_leg’, or ‘head’
- Returns
Nothing at the moment
-
die(death_message) → None¶ Cause player to die.
- Parameters
death_message – Message to display upon death. Use
utils.rand_line()instead of hard-coding this.
-
does_evil(variability=75) → bool¶ Returns bool deciding whether or not to do an evil thing. Based on kindness formula.
- Parameters
variability – Amount of randomness to introduce
- Returns
Whether the evil act should be committed
-
drink()¶ Consumes drinkable fluid from inventory.
-
drink_amount() → int¶ Polls total drinkable fluids in inventory.
- Returns
Integer equal to the amount of drinkable fluids the player has.
-
eat()¶ Consumes food from inventory.
-
food_amount() → int¶ Polls total food in inventory.
- Returns
Integer equal to the amount of food the player has.
-
get_relation(other_npc: utils.NPC) → int¶ Return relation between self and another NPC
- Parameters
other_npc – NPC to look up relationship for
- Returns
Relationship level
-
get_weapon(weapon_types=[]) → utils.Item¶ Gets random weapon of specific type.
- Parameters
weapon_types – List of desired weapon types.
- Returns
Random matched weapon.
-
give(thing: utils.Item, other_npc: utils.NPC)¶ Give an item to another NPC.
- Parameters
thing – Gift to give
other_npc – Recipient of gift
-
interact(other_npc_name: str, relation_type: str, amount: int) → None¶ Modify relationship between player and other_npc.
- Parameters
other_npc_name – Name of other NPC object.
relation_type – Type of relationship.
amount – Amount to add.
-
move(new_location: utils.Location) → None¶ Move player into location provided.
- Parameters
new_location –
-
pickup(item: Union[utils.Item, str])¶ Add item to player’s inventory
- Parameters
item – Either existing item object or item ID to create an object with.
-
poll_inventory(type_id) → List[utils.Item]¶ Gets all items of type_id in inventory.
- Parameters
type_id – Item ID to search for
- Returns
List of items matched
-
poll_limbs() → Dict[str, bool]¶ Identifies whether sections of the body work or not
- Returns
Dictionary with “arm”, “arms”, “leg”, “legs”, “head” and their state as a bool.
-
random_location(universe: utils.World)¶ Moves the player to a random position in the universe.
- Parameters
universe – Primary game world
-
set_days_to_live(days: int, death_message: str) → None¶ Starts a death-countdown at the end of which the player will die.
- Parameters
days – Number of days the player has to live
death_message – Message to display upon death. Use
utils.rand_line()instead of hard-coding this.
-
step()¶ Iterate the player’s needs (Should be called once per cycle/day)
-
usable_weapons(weapon_types=[]) → List[utils.Item]¶ Gets list of weapons of specific type.
- Parameters
weapon_types – List of desired weapon types.
- Returns
All matched weapons.
-
wake_up() → None¶ Cause player to wake up from being unconscious and set head health to 30.
-
-
class
utils.Relation(type_id, amount)¶ Bases:
object
-
exception
utils.StateMismatch¶ Bases:
Exception
-
class
utils.World(size, biome_size)¶ Bases:
objectWorld object that the entire game exists within. Commonly referred to as “universe”.
-
utils.clear()¶ Clears terminal.
-
utils.color(intext: str, fore_color: int, bright: bool = False)¶ Colors string
- Parameters
intext – String to be colored
fore_color – Colorama color to be used. E.g. Fore.BLACK
bright –
-
utils.gen_location(type_id)¶
-
utils.get_lines(line_id: str, players=None, item=None) → List[utils.Line]¶ Filters game lines by line_id and requirements.
- Parameters
line_id – The category of text to look for in the list.
players – List of players relevant to this line. If omitted it will only return lines that don’t have filters.
item – For specific filters based on single objects selected by the game.
- Returns
List of line objects meeting criteria.
-
utils.get_paren_int(intext: str) → int¶ Extracts integers from parentheses. For use with Clem actions.
- Parameters
intext – String to be checked. E.g. do:consume:ammo(1)
- Returns
Integer found inside parens.
-
utils.load_csv(filename)¶
-
utils.load_data(*directory)¶ Loads csv data files in directory.
- Parameters
directory – String arguments that form a path
-
utils.load_lines(*directory) → Dict[str, List[utils.Line]]¶ Parses Clem file into Line objects.
- Parameters
directory – The directory to look in for ‘lines.clem’.
- Returns
Dictionary of lists of Line objects. The keys are derived from Line.id.
-
utils.load_mods()¶
-
utils.obituary(person: utils.NPC)¶
-
utils.printd(intext, players=(), trailing=False, leading=False, **kwargs)¶ I still don’t know why I originally called it printd instead of printf. The world may never know.
-
utils.rand_line(*args, **kwargs) -> (<class 'str'>, typing.Dict[str, str])¶ Selects a relevant line and executes its actions More or less an alias for random.choice(get_lines()).text, see get_lines() documentation.
- Parameters
args – Passes to get_lines()
kwargs – Passes to get_lines()
-
utils.walkable_coords(player: utils.NPC, universe: utils.World) → List[Tuple[int, int]]¶ Returns adjacent biomes to player’s location in Universe.
- Parameters
player –
universe – World that player exists in.
- Returns
List of world coordinates that can be used to lookup biomes.