Character¶
-
class
ourdestiny.d2character(profile_object_in, character_info_json, character_inventory_json, character_equipped_json, character_progression_json, character_activities_json, character_records_json)¶ The object that represents an in-game character, containing attributes and methods related to character information and management. Should be produced by the profile’s get_character_object method.
Parameters: - profile_object_in (ourdestiny.d2profile) – The client object that created the character object. Allows the character object to authenticate and lookup items in database files without needing to rewrite methods or produce multiple client objects
- character_info_json (dict) – The JSON containing the basic character data obtained from GetProfile
- character_inventory_json (dict) – The JSON containing the data for all of the items in the character’s inventory obtained from GetProfile
- character_equipped_json (dict) – The JSON containing the data for all of the items equipped to the character obtained from GetProfile
- character_progression_json (dict) – The JSON containing the data for all of the character progressions
- character_activities_json (dict) – The JSON containing the data for all of the character’s available and current activities
- character_records_json (dict) – The JSON containing the data for character-specific records for this character
Variables: - profile_object (ourdestiny.d2profile) – The d2client object that created this character object
- character_id (string) – The character ID for this character
- membership_type (integer) – The membership type (platform) enum for the platform this character is on
- light (integer) – The light (or power as it was formerly known, or light before that, thanks Bungie) level of this character
- mobility (integer) – The mobility of this character
- resilience (integer) – The resilience of this character
- recovery (integer) – The recovery of this character
- discipline (integer) – The discipline of this character
- intellect (integer) – The intellect of this character
- strength (integer) – The strength of this character
- race (string) – The race of this character (Human, Awoken, or Exo)
- gender (string) – The gender of this character
- cclass (string) – The class of this character - note the extra c, since “class” is a reserved keyword
- inventory (List[ourdestiny.d2item]) – A list of d2item objects in the character’s inventory
- postmaster (List[ourdestiny.d2item]) – A list of d2item objects in the character’s postmaster inventory
- equipped (List[ourdestiny.d2item]) – A list of d2item objects currently equipped to the character
- current_activity (ourdestiny.d2activity) – The current activity the character is in, if it is in one
- available_activities (List[ourdestiny.d2activity]) – The activities available to this character
- progressions (List[ourdestiny.d2progression]) – A list of d2progression objects containing data about progressions on this character - e.g glory ranks, infamy ranks
- factions (List[ourdestiny.d2faction]) – A list of d2faction objects containing data about factions
- records (list[ourdestiny.d2record]) – A list of d2record objects specific to this character
-
equip_item(item_to_equip)¶ Takes a d2item object, and equips it if it can be instanced, is equippable, and belongs to the current character
Parameters: item_to_equip (ourdestiny.d2item) – The object of the item to be equipped to the current character
Returns: The response JSON from the API - see https://bungie-net.github.io/multi/operation_post_Destiny2-EquipItem.html
Return type: dict
Raises: - ItemCannotBeInstanced – Raised when an item is passed in that has no instance ID, and therefore cannot be instanced, and in turn cannot be equipped
- NoRoomInDestination – Raised when an item cannot be equipped because there is no space - for example, trying to equip more than 1 exotic weapon at a time
- ItemDoesNotBelongToCharacter – Raised when an item passed in does not belong to this character
-
equip_items(array_of_items_to_equip)¶ Takes an array of items, and equips them if they can be instanced, equippable and belong to the current character
Parameters: array_of_items_to_equip (list[ourdestiny.d2item]) – A list of item objects to be equipped to the current character
Returns: The response JSON from the API - see https://bungie-net.github.io/multi/schema_Destiny-DestinyEquipItemResults.html
Return type: dict
Raises: - ItemCannotBeInstanced – Raised when an item is passed in that has no instance ID, and therefore cannot be instanced, and in turn cannot be equipped
- NoRoomInDestination – Raised when an item cannot be equipped because there is no space - for example, trying to equip more than 1 exotic weapon at a time
- ItemDoesNotBelongToCharacter – Raised when an item passed in does not belong to this character
-
get_equipped_item_by_index(item_index)¶ Gets an item from the character’s equipped items by index
Parameters: item_index (integer) – The 0-based index of the item in the list of the character’s equipped items Returns: The item object at the index given Return type: ourdestiny.d2item
-
get_equipped_item_by_name(item_name)¶ Gets an item currently equipped to this character
Parameters: item_name (string) – The exact, case-sensitive name of the item you’re looking for Returns: The requested item object Return type: ourdestiny.d2item
-
get_instanced_equipped_item_by_name(item_name)¶ Gets an instanced item from the character’s equipped item
Parameters: item_name (string) – The exact, case-sensitive name of the item you’re looking for Returns: The requested item object Return type: ourdestiny.d2item
-
get_instanced_equipped_items_by_name(list_of_items_to_get)¶ Gets a list of instanced items from the character’s equipped items
Parameters: list_of_items_to_get (List[str]) – A list of strings of items to get Returns: A list of requested items Return type: List[ourdestiny.d2item]
-
get_instanced_inventory_item_by_name(item_name)¶ Gets an instanced item from the character’s inventory
Parameters: item_name (string) – The exact, case-sensitive name of the item you’re looking for Returns: The requested item object Return type: ourdestiny.d2item
-
get_instanced_inventory_items_by_name(list_of_items_to_get)¶ Gets a list of instanced items from the character’s inventory
Parameters: list_of_items_to_get (List[str]) – A list of strings of items to get Returns: A list of items that could be found. Return type: List[ourdestiny.d2item]
-
get_instanced_item_by_name(item_name)¶ Gets an instanced item from the character’s inventory or equipped items
Parameters: item_name (string) – The exact, case-sensitive name of the item you’re looking for Returns: The requested item object Return type: ourdestiny.d2item
-
get_inventory_item_by_index(item_index)¶ Gets an item from the character’s inventory items by index
Parameters: item_index (integer) – The 0-based index of the item in the list of the character’s inventory items Returns: The item object at the index given Return type: ourdestiny.d2item
-
get_inventory_item_by_name(item_name)¶ Gets an item in the character’s inventory
Parameters: item_name (string) – The exact, case-sensitive name of the item you’re looking for Returns: The requested item object Return type: d2item
-
get_item_by_name(item_name)¶ Gets an item from the character’s inventory and equipped items
Parameters: item_name (string) – The exact, case-sensitive name of the item you’re looking for Returns: The requested item object Return type: ourdestiny.d2item
-
get_item_in_same_slot(item_to_check)¶ Gets the currently equipped item in the same slot as the item passed in
Parameters: item_to_check (ourdestiny.d2item) – The item to get the equipped item in the same slot as Returns: The item in the same slot as the equipped item Return type: ourdestiny.d2item
-
get_item_in_slot(slot)¶ Gets an equipped item in an inventory slot - uses one of two corresponding values for each slot, shown below:
Kinetic Weapons: 0Energy Weapons: 1Power Weapons: 2Helmet: 3Gauntlets: 4Chest Armor: 5Leg Armor: 6Class Armor: 7Ghost: 8Vehicle: 9Ships: 10Subclass: 16Clan Banners: 17Emblems: 27Finishers: 47Emotes: 12Seasonal Artifact: 49Parameters: slot (string or integer) – The slot being targeted Returns: The equipped item in the slot Return type: ourdestiny.d2item
-
pull_from_postmaster(item_to_pull, stack_size=1)¶ Pulls an item from the postmaster into the relevant inventory bucket
Parameters: - item_to_pull (ourdestiny.d2item) – The item to pull from the postmaster
- stack_size (integer) – The number of items in the stack you want to pull - defaults to 1
Returns: The response JSON from the API
Return type: dict
Raises: - NoRoomInDestination – There is not room in the bucket the item is being pulled into
- ItemNotInBucket – The item is not currently being held in the postmaster
- ItemNotFound – The item is not found on the API’s end
-
swap_item(item_in_equipped, item_in_inventory)¶ Do not use for equipping items to an in-game character, this is used to keep consistency locally due to Bungie’s API not updating its inventories instantly.
Swaps a currently equipped item with an inventory item in the local character object
Parameters: - item_in_equipped (ourdestiny.d2item) – Item in equipped list to be swapped
- item_in_inventory (ourdestiny.d2item) – Item in inventory list to be swapped
-
transfer_item(item_to_transfer, number_to_transfer=1)¶ Transfers an instanced item to or from the vault
Parameters: - item_to_transfer (d2item) – The item object to be transferred to the vault
- number_to_transfer (integer) – The number of items to transfer to the vault - defaults to 1, but can be increased in the case of stacks of items, such as planetary materials
Returns: The response JSON from the API - see https://bungie-net.github.io/multi/schema_Destiny-DestinyEquipItemResults.html
Return type: dict