1
0
mirror of https://github.com/0O0o0oOoO00/Alas.git synced 2026-05-15 09:29:26 +08:00
Files
Alas/module/luahook/api.py
2025-03-18 22:37:03 +08:00

115 lines
3.5 KiB
Python

import requests
import adbutils
from pydantic import BaseModel
from module.exception import CrackerError
class CrackApi:
class ShipProperties(BaseModel):
armor: float = -1
speed: float = -1
antiaircraft: float = -1
oxy_recovery_bench: float = -1
torpedo: float = -1
hit: float = -1
sonarRange: float = -1
attack_duration: float = -1
raid_distance: float = -1
oxy_recovery_surface: float = -1
oxy_recovery: float = -1
dodge: float = -1
luck: float = -1
reload: float = -1
oxy_cost: float = -1
durability: float = -1
air: float = -1
oxy_max: float = -1
cannon: float = -1
antisub: float = -1
class FakePlayerInfo(BaseModel):
name: str = ""
level: str = ""
id: str = ""
def __init__(self, base_url):
self.api_url = base_url
def post(self, path, data=None):
url = f'{self.api_url}/{path}'
try:
response = requests.post(url, data=data) # TODO: add timeout
except requests.exceptions.Timeout:
raise CrackerError('CrackApi request timeout')
except Exception as e:
raise CrackerError(f'CrackApi request error: {e}')
if response.status_code != 200:
raise CrackerError(f'CrackApi response error: {response.status_code}')
def disable_all(self):
self.post('disable_all')
def enable_global_ship_properties_crack(self):
self.post('enable_global_ship_properties_crack')
def disable_global_ship_properties_crack(self):
self.post('disable_global_ship_properties_crack')
def update_global_ship_properties(self, ship_properties: ShipProperties):
self.post('update_global_ship_properties', data=ship_properties.json())
def enable_fast_stage_move(self):
self.post("enable_fast_stage_move")
def disable_fast_stage_move(self):
self.post("disable_fast_stage_move")
def enable_remove_hard_mode_ship_properties_limit(self):
self.post("enable_remove_hard_mode_ship_properties_limit")
def disable_remove_hard_mode_ship_properties_limit(self):
self.post("disable_remove_hard_mode_ship_properties_limit")
def enable_remove_hard_mode_ship_type_limit(self):
self.post("enable_remove_hard_mode_ship_type_limit")
def disable_remove_hard_mode_ship_type_limit(self):
self.post("disable_remove_hard_mode_ship_type_limit")
def enable_remove_hard_mode_limit(self):
self.post("enable_remove_hard_mode_limit")
def disable_remove_hard_mode_limit(self):
self.post("disable_remove_hard_mode_limit")
def enable_fake_player(self):
self.post("enable_fake_player")
def disable_fake_player(self):
self.post("disable_fake_player")
def update_fake_player_info(self, fake_player_info: FakePlayerInfo):
self.post("update_fake_player_info", data=fake_player_info.json())
def enable_no_bb_animation(self):
self.post("enable_no_bb_animation")
def disable_no_bb_animation(self):
self.post("disable_no_bb_animation")
def enable_no_emotion_warning(self):
self.post("enable_no_emotion_warning")
def disable_no_emotion_warning(self):
self.post("disable_no_emotion_warning")
def enable_opsi_fast_move(self):
self.post("enable_opsi_fast_move")
def disable_opsi_fast_move(self):
self.post("disable_opsi_fast_move")
def is_alive(self):
self.post("is_alive")