Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

Commit f64b644

Browse files
authored
Merge pull request #131 from Rurquhart/feat/ruruhart/morg-inv-full-check
Add inventory full check for Morg API
2 parents d1f5b62 + f1ffa49 commit f64b644

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/utilities/api/morg_http_client.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,15 @@ def get_if_item_in_inv(self, item_id: Union[List[int], int]) -> bool:
310310
elif isinstance(item_id, list):
311311
return any(inventory_slot["id"] in item_id for inventory_slot in data)
312312

313+
def get_is_inv_full(self) -> bool:
314+
"""
315+
Checks if player's inventory is full.
316+
Returns:
317+
True if the player's inventory is full, False otherwise.
318+
"""
319+
data = self.__do_get(endpoint=self.inv_endpoint)
320+
return len([item["id"] for item in data if item["id"] != -1]) == 28
321+
313322
def get_inv_item_indices(self, item_id: Union[List[int], int]) -> list:
314323
"""
315324
For the given item ID(s), returns a list of inventory slot indexes that the item exists in.
@@ -410,6 +419,7 @@ def convert_player_position_to_pixels(self):
410419

411420
# Inventory Data
412421
if False:
422+
print(f"Is inventory full: {api.get_is_inv_full()}")
413423
print(f"Are logs in inventory?: {api.get_if_item_in_inv(ids.logs)}")
414424
print(f"Find amount of change in inv: {api.get_inv_item_stack_amount(ids.coins)}")
415425
print(f"Get position of all bones in inv: {api.get_inv_item_indices(ids.BONES)}")

0 commit comments

Comments
 (0)