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

Commit d1f5b62

Browse files
authored
Merge pull request #129 from Rurquhart/chore/rurquhart/morg-item-equipped-list
chore(morg): allow list of ints when checking equipped ids
2 parents c61d823 + 9a1891f commit d1f5b62

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

src/utilities/api/item_ids.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13138,3 +13138,14 @@
1313813138
RAW_TROUT,
1313913139
RAW_TUNA,
1314013140
]
13141+
13142+
rods = [
13143+
RING_OF_DUELING1,
13144+
RING_OF_DUELING2,
13145+
RING_OF_DUELING3,
13146+
RING_OF_DUELING4,
13147+
RING_OF_DUELING5,
13148+
RING_OF_DUELING6,
13149+
RING_OF_DUELING7,
13150+
RING_OF_DUELING8,
13151+
]

src/utilities/api/morg_http_client.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -342,19 +342,19 @@ def get_inv_item_stack_amount(self, item_id: Union[int, List[int]]) -> int:
342342
return int(result["quantity"])
343343
return 0
344344

345-
def get_is_item_equipped(self, item_id: int) -> bool:
345+
def get_is_item_equipped(self, item_id: Union[int, List[int]]) -> bool:
346346
"""
347-
Checks if the player has given item equipped, and its quantity.
347+
Checks if the player has given item(s) equipped. Given a list of IDs, returns True on first ID found.
348348
Args:
349-
item_id: The ID of the item to check for.
349+
item_id: the id of the item to check for (a single ID, or list of IDs).
350350
Returns:
351-
True if the item is equipped, False if not.
351+
True if an item is equipped, False if not.
352352
"""
353353
data = self.__do_get(endpoint=self.equip_endpoint)
354-
return next(
355-
(True for equip_slot in data if equip_slot["id"] == item_id),
356-
False,
357-
)
354+
equipped_ids = [item["id"] for item in data]
355+
if isinstance(item_id, int):
356+
return item_id in equipped_ids
357+
return any(item in item_id for item in equipped_ids)
358358

359359
def get_equipped_item_quantity(self, item_id: int) -> int:
360360
"""
@@ -384,9 +384,6 @@ def convert_player_position_to_pixels(self):
384384

385385
api = MorgHTTPSocket()
386386

387-
id_logs = 1511
388-
id_bones = 526
389-
390387
# Note: Making API calls in succession too quickly can result in issues
391388
while True:
392389
# Player Data
@@ -431,6 +428,7 @@ def convert_player_position_to_pixels(self):
431428
# Equipment Data
432429
if False:
433430
print(f"Is bronze axe equipped?: {api.get_is_item_equipped(ids.BRONZE_AXE)}")
431+
print(f"Are there any ring of duelings equipped? {api.get_is_item_equipped(ids.rods)}")
434432
print(f"How many bronze arrows equipped?: {api.get_equipped_item_quantity(ids.BRONZE_ARROW)}")
435433

436434
# Chatbox Data

0 commit comments

Comments
 (0)