mirror of
https://github.com/0O0o0oOoO00/Alas.git
synced 2026-05-14 13:49:26 +08:00
Merge branch 'smallkai' into smallkai-dev
This commit is contained in:
@@ -23,6 +23,10 @@
|
||||
"Optimization": {
|
||||
"ScreenshotInterval": 0.3,
|
||||
"CombatScreenshotInterval": 1.0,
|
||||
"ClickMaxRecord": 15,
|
||||
"SingleButtonMaxCount": 12,
|
||||
"MultiButtonMaxCount1": 6,
|
||||
"MultiButtonMaxCount2": 6,
|
||||
"TaskHoardingDuration": 0,
|
||||
"WhenTaskQueueEmpty": "goto_main"
|
||||
},
|
||||
|
||||
@@ -56,7 +56,7 @@ class ConfigModel:
|
||||
|
||||
# Webui
|
||||
WebuiHost: str = "0.0.0.0"
|
||||
WebuiPort: int = 22367
|
||||
WebuiPort: int = 22267
|
||||
Language: str = "en-US"
|
||||
Theme: str = "default"
|
||||
DpiScaling: bool = True
|
||||
|
||||
@@ -198,6 +198,22 @@
|
||||
"type": "input",
|
||||
"value": 1.0
|
||||
},
|
||||
"ClickMaxRecord": {
|
||||
"type": "input",
|
||||
"value": 15
|
||||
},
|
||||
"SingleButtonMaxCount": {
|
||||
"type": "input",
|
||||
"value": 12
|
||||
},
|
||||
"MultiButtonMaxCount1": {
|
||||
"type": "input",
|
||||
"value": 6
|
||||
},
|
||||
"MultiButtonMaxCount2": {
|
||||
"type": "input",
|
||||
"value": 6
|
||||
},
|
||||
"TaskHoardingDuration": {
|
||||
"type": "input",
|
||||
"value": 0
|
||||
|
||||
@@ -91,6 +91,10 @@ Error:
|
||||
Optimization:
|
||||
ScreenshotInterval: 0.3
|
||||
CombatScreenshotInterval: 1.0
|
||||
ClickMaxRecord: 15
|
||||
SingleButtonMaxCount: 12
|
||||
MultiButtonMaxCount1: 6
|
||||
MultiButtonMaxCount2: 6
|
||||
TaskHoardingDuration: 0
|
||||
WhenTaskQueueEmpty:
|
||||
value: goto_main
|
||||
|
||||
@@ -40,6 +40,10 @@ class GeneratedConfig:
|
||||
# Group `Optimization`
|
||||
Optimization_ScreenshotInterval = 0.3
|
||||
Optimization_CombatScreenshotInterval = 1.0
|
||||
Optimization_ClickMaxRecord = 15
|
||||
Optimization_SingleButtonMaxCount = 12
|
||||
Optimization_MultiButtonMaxCount1 = 6
|
||||
Optimization_MultiButtonMaxCount2 = 6
|
||||
Optimization_TaskHoardingDuration = 0
|
||||
Optimization_WhenTaskQueueEmpty = 'goto_main' # stay_there, goto_main, close_game
|
||||
|
||||
|
||||
@@ -505,6 +505,22 @@
|
||||
"name": "Take Screenshots Every X Second(s) In Combat",
|
||||
"help": "Minimum interval between 2 screenshots, limited in 0.1 ~ 1.0, can help reduce CPU during battle"
|
||||
},
|
||||
"ClickMaxRecord": {
|
||||
"name": "Optimization.ClickMaxRecord.name",
|
||||
"help": "Optimization.ClickMaxRecord.help"
|
||||
},
|
||||
"SingleButtonMaxCount": {
|
||||
"name": "Optimization.SingleButtonMaxCount.name",
|
||||
"help": "Optimization.SingleButtonMaxCount.help"
|
||||
},
|
||||
"MultiButtonMaxCount1": {
|
||||
"name": "Optimization.MultiButtonMaxCount1.name",
|
||||
"help": "Optimization.MultiButtonMaxCount1.help"
|
||||
},
|
||||
"MultiButtonMaxCount2": {
|
||||
"name": "Optimization.MultiButtonMaxCount2.name",
|
||||
"help": "Optimization.MultiButtonMaxCount2.help"
|
||||
},
|
||||
"TaskHoardingDuration": {
|
||||
"name": "Hoard Tasks For X Minute(s)",
|
||||
"help": "By purposely not adding ready tasks to pending, allows for larger subsets to be built and run en masse at a later time\nCan reduce the frequency of operating AL"
|
||||
|
||||
@@ -505,6 +505,22 @@
|
||||
"name": "Optimization.CombatScreenshotInterval.name",
|
||||
"help": "Optimization.CombatScreenshotInterval.help"
|
||||
},
|
||||
"ClickMaxRecord": {
|
||||
"name": "Optimization.ClickMaxRecord.name",
|
||||
"help": "Optimization.ClickMaxRecord.help"
|
||||
},
|
||||
"SingleButtonMaxCount": {
|
||||
"name": "Optimization.SingleButtonMaxCount.name",
|
||||
"help": "Optimization.SingleButtonMaxCount.help"
|
||||
},
|
||||
"MultiButtonMaxCount1": {
|
||||
"name": "Optimization.MultiButtonMaxCount1.name",
|
||||
"help": "Optimization.MultiButtonMaxCount1.help"
|
||||
},
|
||||
"MultiButtonMaxCount2": {
|
||||
"name": "Optimization.MultiButtonMaxCount2.name",
|
||||
"help": "Optimization.MultiButtonMaxCount2.help"
|
||||
},
|
||||
"TaskHoardingDuration": {
|
||||
"name": "Optimization.TaskHoardingDuration.name",
|
||||
"help": "Optimization.TaskHoardingDuration.help"
|
||||
|
||||
@@ -499,11 +499,27 @@
|
||||
},
|
||||
"ScreenshotInterval": {
|
||||
"name": "放慢截图速度至 X 秒一张",
|
||||
"help": "执行两次截图之间的最小间隔,限制在 0.1 ~ 2.0,根据需要自行调整\n建议调整为较短的间隔,比如0.1s\n我也不知道为什么,但这似乎对于减少Alas的部分报错有一定的帮助 : )"
|
||||
"help": ""
|
||||
},
|
||||
"CombatScreenshotInterval": {
|
||||
"name": "战斗中放慢截图速度至 X 秒一张",
|
||||
"help": "执行两次截图之间的最小间隔,限制在 0.1 ~ 5.0,根据需要自行调整\n建议调整为较短的间隔,比如0.5s\n我也不知道为什么,但这似乎对于减少Alas的部分报错有一定的帮助 : )"
|
||||
"help": ""
|
||||
},
|
||||
"ClickMaxRecord": {
|
||||
"name": "最大点击记录量",
|
||||
"help": "默认为15"
|
||||
},
|
||||
"SingleButtonMaxCount": {
|
||||
"name": "单Button最大计数",
|
||||
"help": "该数值单项不得超过最大点击记录量,默认为12"
|
||||
},
|
||||
"MultiButtonMaxCount1": {
|
||||
"name": "多Button最大计数(Button1)",
|
||||
"help": "该数值与下一项设置之和不得大于最大点击记录量,默认为6"
|
||||
},
|
||||
"MultiButtonMaxCount2": {
|
||||
"name": "多Button最大计数(Button2)",
|
||||
"help": "该数值与上一项设置之和不得大于最大点击记录量,默认为6"
|
||||
},
|
||||
"TaskHoardingDuration": {
|
||||
"name": "囤积任务 X 分钟",
|
||||
|
||||
@@ -505,6 +505,22 @@
|
||||
"name": "戰鬥中放慢截圖速度至 X 秒一張",
|
||||
"help": "執行兩次截圖之間的最小間隔,限制在 0.1 ~ 1.0,能降低戰鬥時的 CPU 佔用"
|
||||
},
|
||||
"ClickMaxRecord": {
|
||||
"name": "Optimization.ClickMaxRecord.name",
|
||||
"help": "Optimization.ClickMaxRecord.help"
|
||||
},
|
||||
"SingleButtonMaxCount": {
|
||||
"name": "Optimization.SingleButtonMaxCount.name",
|
||||
"help": "Optimization.SingleButtonMaxCount.help"
|
||||
},
|
||||
"MultiButtonMaxCount1": {
|
||||
"name": "Optimization.MultiButtonMaxCount1.name",
|
||||
"help": "Optimization.MultiButtonMaxCount1.help"
|
||||
},
|
||||
"MultiButtonMaxCount2": {
|
||||
"name": "Optimization.MultiButtonMaxCount2.name",
|
||||
"help": "Optimization.MultiButtonMaxCount2.help"
|
||||
},
|
||||
"TaskHoardingDuration": {
|
||||
"name": "囤積任務 X 分鐘",
|
||||
"help": "能在收穫期間降低操作遊戲的頻率\n任務觸發後,等待 X 分鐘後,一次性執行佇列中的任務"
|
||||
|
||||
@@ -72,6 +72,10 @@ class Device(Screenshot, Control, AppControl):
|
||||
stuck_long_wait_list = ['BATTLE_STATUS_S', 'PAUSE', 'LOGIN_CHECK']
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
record_maxlen = self.config.Optimization_ClickMaxRecord
|
||||
if record_maxlen != self.click_record.maxlen:
|
||||
self.click_record = collections.deque(maxlen=record_maxlen)
|
||||
|
||||
for _ in range(2):
|
||||
try:
|
||||
super().__init__(*args, **kwargs)
|
||||
@@ -263,19 +267,29 @@ class Device(Screenshot, Control, AppControl):
|
||||
|
||||
return removed
|
||||
|
||||
def check_and_ensure_record_setting(self):
|
||||
record_maxlen = self.config.Optimization_ClickMaxRecord
|
||||
if self.config.Optimization_SingleButtonMaxCount > record_maxlen:
|
||||
self.config.Optimization_SingleButtonMaxCount = int(0.8 * record_maxlen)
|
||||
if self.config.Optimization_MultiButtonMaxCount1 + self.config.Optimization_MultiButtonMaxCount2 > record_maxlen:
|
||||
self.config.Optimization_MultiButtonMaxCount1 = int(0.4 * record_maxlen)
|
||||
self.config.Optimization_MultiButtonMaxCount2 = int(0.4 * record_maxlen)
|
||||
|
||||
def click_record_check(self):
|
||||
"""
|
||||
Raises:
|
||||
GameTooManyClickError:
|
||||
"""
|
||||
self.check_and_ensure_record_setting()
|
||||
|
||||
count = collections.Counter(self.click_record).most_common(2)
|
||||
if count[0][1] >= 12:
|
||||
if count[0][1] >= self.config.Optimization_SingleButtonMaxCount:
|
||||
show_function_call()
|
||||
logger.warning(f'Too many click for a button: {count[0][0]}')
|
||||
logger.warning(f'History click: {[str(prev) for prev in self.click_record]}')
|
||||
self.click_record_clear()
|
||||
raise GameTooManyClickError(f'Too many click for a button: {count[0][0]}')
|
||||
if len(count) >= 2 and count[0][1] >= 6 and count[1][1] >= 6:
|
||||
if len(count) >= 2 and count[0][1] >= self.config.Optimization_MultiButtonMaxCount1 and count[1][1] >= self.config.Optimization_MultiButtonMaxCount2:
|
||||
show_function_call()
|
||||
logger.warning(f'Too many click between 2 buttons: {count[0][0]}, {count[1][0]}')
|
||||
logger.warning(f'History click: {[str(prev) for prev in self.click_record]}')
|
||||
|
||||
@@ -155,31 +155,12 @@ class Screenshot(Adb, WSA, DroidCast, AScreenCap, Scrcpy, NemuIpc):
|
||||
Minimum interval between 2 screenshots in seconds.
|
||||
Or None for Optimization_ScreenshotInterval, 'combat' for Optimization_CombatScreenshotInterval
|
||||
"""
|
||||
if interval is None:
|
||||
origin = self.config.Optimization_ScreenshotInterval
|
||||
interval = limit_in(origin, 0.1, 2.0)
|
||||
if interval != origin:
|
||||
logger.warning(f'Optimization.ScreenshotInterval {origin} is revised to {interval}')
|
||||
self.config.Optimization_ScreenshotInterval = interval
|
||||
# Allow nemu_ipc to have a lower default
|
||||
if self.config.Emulator_ScreenshotMethod == 'nemu_ipc':
|
||||
interval = limit_in(origin, 0.1, 0.2)
|
||||
elif interval == 'combat':
|
||||
origin = self.config.Optimization_CombatScreenshotInterval
|
||||
interval = limit_in(origin, 0.3, 5.0)
|
||||
if interval != origin:
|
||||
logger.warning(f'Optimization.CombatScreenshotInterval {origin} is revised to {interval}')
|
||||
self.config.Optimization_CombatScreenshotInterval = interval
|
||||
elif isinstance(interval, (int, float)):
|
||||
if isinstance(interval, (int, float)):
|
||||
# No limitation for manual set in code
|
||||
pass
|
||||
else:
|
||||
logger.warning(f'Unknown screenshot interval: {interval}')
|
||||
raise ScriptError(f'Unknown screenshot interval: {interval}')
|
||||
# Screenshot interval in scrcpy is meaningless,
|
||||
# video stream is received continuously no matter you use it or not.
|
||||
if self.config.Emulator_ScreenshotMethod == 'scrcpy':
|
||||
interval = 0.1
|
||||
|
||||
if interval != self._screenshot_interval.limit:
|
||||
logger.info(f'Screenshot interval set to {interval}s')
|
||||
|
||||
Reference in New Issue
Block a user