Skip to content

Commit

Permalink
Merge pull request kelltom#146 from WillowsDad/WillowsDad_AddIsInvEmp…
Browse files Browse the repository at this point in the history
…tyMethod

Add Is Inventory Empty Method to Morg API
  • Loading branch information
kelltom committed Apr 22, 2023
2 parents 58b63d8 + 7be46d4 commit 8c68d5b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/utilities/api/morg_http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,15 @@ def get_is_inv_full(self) -> bool:
data = self.__do_get(endpoint=self.inv_endpoint)
return len([item["id"] for item in data if item["id"] != -1]) == 28

def get_is_inv_empty(self) -> bool:
"""
Checks if player's inventory is empty.
Returns:
True if the player's inventory is empty, False otherwise.
"""
data = self.__do_get(endpoint=self.inv_endpoint)
return not [item["id"] for item in data if item["id"] != -1]

def get_inv_item_indices(self, item_id: Union[List[int], int]) -> list:
"""
For the given item ID(s), returns a list of inventory slot indexes that the item exists in.
Expand Down Expand Up @@ -420,6 +429,7 @@ def convert_player_position_to_pixels(self):
# Inventory Data
if False:
print(f"Is inventory full: {api.get_is_inv_full()}")
print(f"Is inventory empty: {api.get_is_inv_empty()}")
print(f"Are logs in inventory?: {api.get_if_item_in_inv(ids.logs)}")
print(f"Find amount of change in inv: {api.get_inv_item_stack_amount(ids.coins)}")
print(f"Get position of all bones in inv: {api.get_inv_item_indices(ids.BONES)}")
Expand Down

0 comments on commit 8c68d5b

Please sign in to comment.