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

Commit

Permalink
Merge branch 'main' into BetterDropBehaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
Pinibot authored Apr 23, 2023
2 parents 2d87ea1 + 8c68d5b commit 022e34f
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/model/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ def set_compass_south(self):
def __compass_right_click(self, msg, rel_y):
self.log_msg(msg)
self.mouse.move_to(self.win.compass_orb.random_point())
pag.rightClick()
self.mouse.right_click()
self.mouse.move_rel(0, rel_y, 5, 2)
self.mouse.click()

Expand Down Expand Up @@ -618,7 +618,7 @@ def toggle_auto_retaliate(self, toggle_on: bool):
self.log_msg(f"Toggling auto retaliate {state}...")
# click the combat tab
self.mouse.move_to(self.win.cp_tabs[0].random_point())
pag.click()
self.mouse.click()
time.sleep(0.5)

if toggle_on:
Expand Down
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
45 changes: 45 additions & 0 deletions src/utilities/api/status_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,48 @@ def get_game_tick(self) -> int:
"""
return player_data["tick"]

def get_real_level(self, skill_name):
"""
Fetches the real level of a skill.
Args:
skill_name: The name of the skill to check (must be all caps).
Example:
>>> print(api_status.get_real_level("ATTACK"))
"""
return next(
(skill["realLevel"] for skill in player_data["skills"] if skill["skillName"] == skill_name),
None,
)

def get_boosted_level(self, skill_name):
"""
Fetches boosted level of a skill.
Args:
skill_name: The name of the skill to check (must be all caps).
Example:
>>> print(api_status.get_boosted_level("ATTACK"))
"""
return next(
(skill["boostedLevel"] for skill in player_data["skills"] if skill["skillName"] == skill_name),
None,
)

def get_is_boosted(self, skill_name) -> bool:
"""
Compares real level to boosted level of a skill.
Args:
skill_name: The name of the skill to check (must be all caps).
Returns:
True if boosted level is greater than real level
Example:
>>> print(api_status.get_is_boosted("ATTACK"))
"""
real_level = self.get_real_level(skill_name)
boosted_level = self.get_boosted_level(skill_name)
if real_level is not None and boosted_level is not None:
return boosted_level > real_level
return False

def get_run_energy(self) -> int:
"""
Gets the player's current run energy.
Expand Down Expand Up @@ -193,6 +235,9 @@ def get_animation_id(self) -> int:
while True:
# api.get_PlayerData()
time.sleep(api.gameTick)
print(f"Real Strength Level: {api.get_real_level('STRENGTH')}")
print(f"Boosted Strength Level: {api.get_boosted_level('STRENGTH')}")
print(f"Is Strength boosted?: {api.get_is_boosted('STRENGTH')}")
print(f"Run Energy: {api.get_run_energy()}")
print(f"Is Inventory Full: {api.get_is_inv_full()}")
print(f"Inventory: {api.get_inv()}")
Expand Down

0 comments on commit 022e34f

Please sign in to comment.