pytower.suitebro

class pytower.suitebro.Suitebro(filename, directory, data)[source]

Suitebro file

Abstraction over the input CondoData/.map file, representing parsed tower-unite-suitebro data

Parameters:
objects[source]

The list of TowerObject instances contained in the Suitebro file

__init__(filename, directory, data)[source]

Instantiates a new Suitebro instance based on the input filename and directory

Parameters:
  • filename (str) – Name of file

  • directory (str) – Path to directory (can be relative or absolute)

  • data (dict[str, Any]) – The raw json data from tower-unite-suitebro

__iter__()[source]
__repl__()[source]
add_object(obj)[source]

Adds a new object to the Suitebro file

Parameters:

obj (TowerObject) – The object to add

add_objects(objs)[source]

Adds a list of objects to the Suitebro file

Parameters:

objs (Sequence[TowerObject]) – The list of objects to add

find_item(name)[source]

Find a TowerObject by its name

Parameters:

name (str) – The proper name or the nickname of the TowerObject

Return type:

TowerObject | None

Returns:

The first TowerObject matching the name, if found, or else None

get_max_groupid()[source]
Return type:

int

Returns:

Maximum group ID present in the save

group(objs, group_id=None)[source]

Groups a selection of objects together

Parameters:
  • objs (Selection) – Selection of objects to group

  • group_id (Optional[int]) – (Optional) The group ID to use

Return type:

int

groups()[source]

Calculates the groups present in the save

Return type:

set[tuple[int, Selection]]

Returns:

The set of groups, as a set of tuples where the first slot is the group ID and the second slot is the corresponding Selection

inventory_count()[source]

Counts the number of inventory items in the Suitebro file

Return type:

dict[str, int]

Returns:

Dictionary where each key is the proper name of the object and the value is the number of instances

inventory_items()[source]

Lists all TowerObject instances that are non-property and are not I/O nor Game-World.

This is equivalent to getting all items that exist in a player’s inventory

Return type:

list[TowerObject]

Returns:

List of TowerObject instances in the Suitebro that exist in a player’s Steam inventory

item_count()[source]

Counts the number of items in the Suitebro file

Return type:

dict[str, int]

Returns:

Dictionary where each key is the proper name of the object and the value is the number of instances

items()[source]

Lists all non-property TowerObjects

Return type:

list[TowerObject]

Returns:

List containing all of the non-property TowerObject instances in this Suitebro

remove_object(obj)[source]

Removes object from the Suitebro file

Parameters:

obj (TowerObject) – The object to remove

to_dict()[source]

Converts the Suitebro object back into a dictionary, formatted in the tower-unite-suitebro style

Returns:

Serialized Suitebro representation that can be written to a file using json.dump

pytower.suitebro.get_active_save()[source]
Return type:

Suitebro | None

pytower.suitebro.get_suitebro_path()[source]
pytower.suitebro.load_suitebro(filename, only_json=False)[source]
Return type:

Suitebro

Parameters:
pytower.suitebro.pretty_path(path)[source]
Return type:

str

Parameters:

path (str)

pytower.suitebro.run_suitebro_parser(input_path, to_save, output_path, overwrite=False)[source]
Return type:

bool

Parameters:
pytower.suitebro.save_suitebro(save, filename, only_json=False)[source]
Parameters: