mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-19 23:33:33 +08:00
Merge pull request #2423 from guoh064/dev
Opt: Clear exercise attempts after final recovery (#2184)
This commit is contained in:
BIN
assets/cn/exercise/OCR_PERIOD_REMAIN.png
Normal file
BIN
assets/cn/exercise/OCR_PERIOD_REMAIN.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
@@ -1466,7 +1466,7 @@
|
|||||||
"Exercise": {
|
"Exercise": {
|
||||||
"OpponentChooseMode": "max_exp",
|
"OpponentChooseMode": "max_exp",
|
||||||
"OpponentTrial": 1,
|
"OpponentTrial": 1,
|
||||||
"ExercisePreserve": 0,
|
"ExerciseStrategy": "aggressive",
|
||||||
"LowHpThreshold": 0.4,
|
"LowHpThreshold": 0.4,
|
||||||
"LowHpConfirmWait": 0.1,
|
"LowHpConfirmWait": 0.1,
|
||||||
"OpponentRefreshValue": 0,
|
"OpponentRefreshValue": 0,
|
||||||
|
|||||||
@@ -7546,9 +7546,19 @@
|
|||||||
"type": "input",
|
"type": "input",
|
||||||
"value": 1
|
"value": 1
|
||||||
},
|
},
|
||||||
"ExercisePreserve": {
|
"ExerciseStrategy": {
|
||||||
"type": "input",
|
"type": "select",
|
||||||
"value": 0
|
"value": "aggressive",
|
||||||
|
"option": [
|
||||||
|
"aggressive",
|
||||||
|
"sun18",
|
||||||
|
"sun12",
|
||||||
|
"sun0",
|
||||||
|
"sat18",
|
||||||
|
"sat12",
|
||||||
|
"sat0",
|
||||||
|
"fri18"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"LowHpThreshold": {
|
"LowHpThreshold": {
|
||||||
"type": "input",
|
"type": "input",
|
||||||
|
|||||||
@@ -573,7 +573,9 @@ Exercise:
|
|||||||
value: max_exp
|
value: max_exp
|
||||||
option: [ max_exp, easiest, leftmost, easiest_else_exp ]
|
option: [ max_exp, easiest, leftmost, easiest_else_exp ]
|
||||||
OpponentTrial: 1
|
OpponentTrial: 1
|
||||||
ExercisePreserve: 0
|
ExerciseStrategy:
|
||||||
|
value: aggressive
|
||||||
|
option: [ aggressive, sun18, sun12, sun0, sat18, sat12, sat0, fri18 ]
|
||||||
LowHpThreshold: 0.4
|
LowHpThreshold: 0.4
|
||||||
LowHpConfirmWait: 0.1
|
LowHpConfirmWait: 0.1
|
||||||
OpponentRefreshValue: 0
|
OpponentRefreshValue: 0
|
||||||
|
|||||||
@@ -340,7 +340,7 @@ class GeneratedConfig:
|
|||||||
# Group `Exercise`
|
# Group `Exercise`
|
||||||
Exercise_OpponentChooseMode = 'max_exp' # max_exp, easiest, leftmost, easiest_else_exp
|
Exercise_OpponentChooseMode = 'max_exp' # max_exp, easiest, leftmost, easiest_else_exp
|
||||||
Exercise_OpponentTrial = 1
|
Exercise_OpponentTrial = 1
|
||||||
Exercise_ExercisePreserve = 0
|
Exercise_ExerciseStrategy = 'aggressive' # aggressive, sun18, sun12, sun0, sat18, sat12, sat0, fri18
|
||||||
Exercise_LowHpThreshold = 0.4
|
Exercise_LowHpThreshold = 0.4
|
||||||
Exercise_LowHpConfirmWait = 0.1
|
Exercise_LowHpConfirmWait = 0.1
|
||||||
Exercise_OpponentRefreshValue = 0
|
Exercise_OpponentRefreshValue = 0
|
||||||
|
|||||||
@@ -2035,9 +2035,17 @@
|
|||||||
"name": "Each Opponent Try X Time(s)",
|
"name": "Each Opponent Try X Time(s)",
|
||||||
"help": "1 ~ Positive Infinity"
|
"help": "1 ~ Positive Infinity"
|
||||||
},
|
},
|
||||||
"ExercisePreserve": {
|
"ExerciseStrategy": {
|
||||||
"name": "Keep X Number Remain(s)",
|
"name": "Exercise Strategy (Keep X number remains)",
|
||||||
"help": "1 ~ 10\n1 means run until 1/10"
|
"help": "If keeping 5 number remains, will try admiral at set time and clear number remains at last recover",
|
||||||
|
"aggressive": "0",
|
||||||
|
"sun18": "5 until Sunday 18pm",
|
||||||
|
"sun12": "5 until Sunday 12pm",
|
||||||
|
"sun0": "5 until Sunday 12am",
|
||||||
|
"sat18": "5 until Saturday 18pm",
|
||||||
|
"sat12": "5 until Saturday 12pm",
|
||||||
|
"sat0": "5 until Saturday 12am",
|
||||||
|
"fri18": "5 until Friday 18pm"
|
||||||
},
|
},
|
||||||
"LowHpThreshold": {
|
"LowHpThreshold": {
|
||||||
"name": "Low HP Threshold",
|
"name": "Low HP Threshold",
|
||||||
|
|||||||
@@ -2035,9 +2035,17 @@
|
|||||||
"name": "Exercise.OpponentTrial.name",
|
"name": "Exercise.OpponentTrial.name",
|
||||||
"help": "Exercise.OpponentTrial.help"
|
"help": "Exercise.OpponentTrial.help"
|
||||||
},
|
},
|
||||||
"ExercisePreserve": {
|
"ExerciseStrategy": {
|
||||||
"name": "Exercise.ExercisePreserve.name",
|
"name": "Exercise.ExerciseStrategy.name",
|
||||||
"help": "Exercise.ExercisePreserve.help"
|
"help": "Exercise.ExerciseStrategy.help",
|
||||||
|
"aggressive": "aggressive",
|
||||||
|
"sun18": "sun18",
|
||||||
|
"sun12": "sun12",
|
||||||
|
"sun0": "sun0",
|
||||||
|
"sat18": "sat18",
|
||||||
|
"sat12": "sat12",
|
||||||
|
"sat0": "sat0",
|
||||||
|
"fri18": "fri18"
|
||||||
},
|
},
|
||||||
"LowHpThreshold": {
|
"LowHpThreshold": {
|
||||||
"name": "Exercise.LowHpThreshold.name",
|
"name": "Exercise.LowHpThreshold.name",
|
||||||
|
|||||||
@@ -2035,9 +2035,17 @@
|
|||||||
"name": "每个对手尝试 X 次",
|
"name": "每个对手尝试 X 次",
|
||||||
"help": ""
|
"help": ""
|
||||||
},
|
},
|
||||||
"ExercisePreserve": {
|
"ExerciseStrategy": {
|
||||||
"name": "保留 X 次演习次数",
|
"name": "演习策略",
|
||||||
"help": ""
|
"help": "若保留 5 次,则会在设定时间尝试冲击元帅,并在周日 18 点刷新后清空所有次数",
|
||||||
|
"aggressive": "保留 0 次",
|
||||||
|
"sun18": "保留 5 次直到星期日 18 点",
|
||||||
|
"sun12": "保留 5 次直到星期日 12 点",
|
||||||
|
"sun0": "保留 5 次直到星期日 0 点",
|
||||||
|
"sat18": "保留 5 次直到星期六 18 点",
|
||||||
|
"sat12": "保留 5 次直到星期六 12 点",
|
||||||
|
"sat0": "保留 5 次直到星期六 0 点",
|
||||||
|
"fri18": "保留 5 次直到星期五 18 点"
|
||||||
},
|
},
|
||||||
"LowHpThreshold": {
|
"LowHpThreshold": {
|
||||||
"name": "血量低于 X 后撤退",
|
"name": "血量低于 X 后撤退",
|
||||||
|
|||||||
@@ -2035,9 +2035,17 @@
|
|||||||
"name": "每個對手嘗試 X 次",
|
"name": "每個對手嘗試 X 次",
|
||||||
"help": ""
|
"help": ""
|
||||||
},
|
},
|
||||||
"ExercisePreserve": {
|
"ExerciseStrategy": {
|
||||||
"name": "保留 X 次演習次數",
|
"name": "演習策略",
|
||||||
"help": ""
|
"help": "若保留 5 次,則會在設定時間嘗試衝擊元帥,並在周日18點刷新后清空所有次數",
|
||||||
|
"aggressive": "保留 0 次",
|
||||||
|
"sun18": "保留 5 次直到星期日 18 點",
|
||||||
|
"sun12": "保留 5 次直到星期日 12 點",
|
||||||
|
"sun0": "保留 5 次直到星期日 0 點",
|
||||||
|
"sat18": "保留 5 次直到星期六 18 點",
|
||||||
|
"sat12": "保留 5 次直到星期六 12 點",
|
||||||
|
"sat0": "保留 5 次直到星期六 0 點",
|
||||||
|
"fri18": "保留 5 次直到星期五 18 點"
|
||||||
},
|
},
|
||||||
"LowHpThreshold": {
|
"LowHpThreshold": {
|
||||||
"name": "血量低於 X 後撤退",
|
"name": "血量低於 X 後撤退",
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ EQUIP_ENTER = Button(area={'cn': (351, 446, 361, 456), 'en': (351, 446, 361, 456
|
|||||||
EXERCISE_PREPARATION = Button(area={'cn': (543, 539, 741, 599), 'en': (541, 537, 743, 601), 'jp': (549, 543, 736, 595), 'tw': (542, 539, 742, 600)}, color={'cn': (235, 186, 114), 'en': (234, 182, 102), 'jp': (235, 184, 111), 'tw': (236, 187, 117)}, button={'cn': (543, 539, 741, 599), 'en': (541, 537, 743, 601), 'jp': (549, 543, 736, 595), 'tw': (542, 539, 742, 600)}, file={'cn': './assets/cn/exercise/EXERCISE_PREPARATION.png', 'en': './assets/en/exercise/EXERCISE_PREPARATION.png', 'jp': './assets/jp/exercise/EXERCISE_PREPARATION.png', 'tw': './assets/tw/exercise/EXERCISE_PREPARATION.png'})
|
EXERCISE_PREPARATION = Button(area={'cn': (543, 539, 741, 599), 'en': (541, 537, 743, 601), 'jp': (549, 543, 736, 595), 'tw': (542, 539, 742, 600)}, color={'cn': (235, 186, 114), 'en': (234, 182, 102), 'jp': (235, 184, 111), 'tw': (236, 187, 117)}, button={'cn': (543, 539, 741, 599), 'en': (541, 537, 743, 601), 'jp': (549, 543, 736, 595), 'tw': (542, 539, 742, 600)}, file={'cn': './assets/cn/exercise/EXERCISE_PREPARATION.png', 'en': './assets/en/exercise/EXERCISE_PREPARATION.png', 'jp': './assets/jp/exercise/EXERCISE_PREPARATION.png', 'tw': './assets/tw/exercise/EXERCISE_PREPARATION.png'})
|
||||||
NEW_OPPONENT = Button(area={'cn': (1065, 340, 1204, 382), 'en': (1064, 339, 1205, 384), 'jp': (1064, 339, 1204, 383), 'tw': (1066, 342, 1203, 381)}, color={'cn': (129, 166, 220), 'en': (128, 165, 221), 'jp': (131, 165, 220), 'tw': (138, 172, 222)}, button={'cn': (1065, 340, 1204, 382), 'en': (1064, 339, 1205, 384), 'jp': (1064, 339, 1204, 383), 'tw': (1066, 342, 1203, 381)}, file={'cn': './assets/cn/exercise/NEW_OPPONENT.png', 'en': './assets/en/exercise/NEW_OPPONENT.png', 'jp': './assets/jp/exercise/NEW_OPPONENT.png', 'tw': './assets/tw/exercise/NEW_OPPONENT.png'})
|
NEW_OPPONENT = Button(area={'cn': (1065, 340, 1204, 382), 'en': (1064, 339, 1205, 384), 'jp': (1064, 339, 1204, 383), 'tw': (1066, 342, 1203, 381)}, color={'cn': (129, 166, 220), 'en': (128, 165, 221), 'jp': (131, 165, 220), 'tw': (138, 172, 222)}, button={'cn': (1065, 340, 1204, 382), 'en': (1064, 339, 1205, 384), 'jp': (1064, 339, 1204, 383), 'tw': (1066, 342, 1203, 381)}, file={'cn': './assets/cn/exercise/NEW_OPPONENT.png', 'en': './assets/en/exercise/NEW_OPPONENT.png', 'jp': './assets/jp/exercise/NEW_OPPONENT.png', 'tw': './assets/tw/exercise/NEW_OPPONENT.png'})
|
||||||
OCR_EXERCISE_REMAIN = Button(area={'cn': (1153, 140, 1178, 165), 'en': (1153, 140, 1178, 165), 'jp': (1153, 140, 1178, 165), 'tw': (1153, 140, 1178, 165)}, color={'cn': (96, 132, 113), 'en': (96, 132, 113), 'jp': (96, 132, 113), 'tw': (96, 132, 113)}, button={'cn': (1153, 140, 1178, 165), 'en': (1153, 140, 1178, 165), 'jp': (1153, 140, 1178, 165), 'tw': (1153, 140, 1178, 165)}, file={'cn': './assets/cn/exercise/OCR_EXERCISE_REMAIN.png', 'en': './assets/en/exercise/OCR_EXERCISE_REMAIN.png', 'jp': './assets/jp/exercise/OCR_EXERCISE_REMAIN.png', 'tw': './assets/tw/exercise/OCR_EXERCISE_REMAIN.png'})
|
OCR_EXERCISE_REMAIN = Button(area={'cn': (1153, 140, 1178, 165), 'en': (1153, 140, 1178, 165), 'jp': (1153, 140, 1178, 165), 'tw': (1153, 140, 1178, 165)}, color={'cn': (96, 132, 113), 'en': (96, 132, 113), 'jp': (96, 132, 113), 'tw': (96, 132, 113)}, button={'cn': (1153, 140, 1178, 165), 'en': (1153, 140, 1178, 165), 'jp': (1153, 140, 1178, 165), 'tw': (1153, 140, 1178, 165)}, file={'cn': './assets/cn/exercise/OCR_EXERCISE_REMAIN.png', 'en': './assets/en/exercise/OCR_EXERCISE_REMAIN.png', 'jp': './assets/jp/exercise/OCR_EXERCISE_REMAIN.png', 'tw': './assets/tw/exercise/OCR_EXERCISE_REMAIN.png'})
|
||||||
|
OCR_PERIOD_REMAIN = Button(area={'cn': (1089, 105, 1209, 129), 'en': (1089, 105, 1209, 129), 'jp': (1089, 105, 1209, 129), 'tw': (1089, 105, 1209, 129)}, color={'cn': (125, 133, 169), 'en': (125, 133, 169), 'jp': (125, 133, 169), 'tw': (125, 133, 169)}, button={'cn': (1089, 105, 1209, 129), 'en': (1089, 105, 1209, 129), 'jp': (1089, 105, 1209, 129), 'tw': (1089, 105, 1209, 129)}, file={'cn': './assets/cn/exercise/OCR_PERIOD_REMAIN.png', 'en': './assets/cn/exercise/OCR_PERIOD_REMAIN.png', 'jp': './assets/cn/exercise/OCR_PERIOD_REMAIN.png', 'tw': './assets/cn/exercise/OCR_PERIOD_REMAIN.png'})
|
||||||
OPPONENT_1 = Button(area={'cn': (104, 77, 316, 381), 'en': (102, 76, 318, 381), 'jp': (104, 77, 316, 381), 'tw': (104, 77, 316, 381)}, color={'cn': (101, 117, 136), 'en': (100, 115, 134), 'jp': (101, 117, 136), 'tw': (101, 117, 136)}, button={'cn': (104, 77, 316, 381), 'en': (102, 76, 318, 381), 'jp': (104, 77, 316, 381), 'tw': (104, 77, 316, 381)}, file={'cn': './assets/cn/exercise/OPPONENT_1.png', 'en': './assets/en/exercise/OPPONENT_1.png', 'jp': './assets/jp/exercise/OPPONENT_1.png', 'tw': './assets/tw/exercise/OPPONENT_1.png'})
|
OPPONENT_1 = Button(area={'cn': (104, 77, 316, 381), 'en': (102, 76, 318, 381), 'jp': (104, 77, 316, 381), 'tw': (104, 77, 316, 381)}, color={'cn': (101, 117, 136), 'en': (100, 115, 134), 'jp': (101, 117, 136), 'tw': (101, 117, 136)}, button={'cn': (104, 77, 316, 381), 'en': (102, 76, 318, 381), 'jp': (104, 77, 316, 381), 'tw': (104, 77, 316, 381)}, file={'cn': './assets/cn/exercise/OPPONENT_1.png', 'en': './assets/en/exercise/OPPONENT_1.png', 'jp': './assets/jp/exercise/OPPONENT_1.png', 'tw': './assets/tw/exercise/OPPONENT_1.png'})
|
||||||
OPPONENT_2 = Button(area={'cn': (348, 77, 560, 381), 'en': (348, 77, 562, 381), 'jp': (348, 77, 560, 381), 'tw': (348, 77, 560, 381)}, color={'cn': (105, 123, 149), 'en': (105, 122, 150), 'jp': (105, 123, 149), 'tw': (105, 123, 149)}, button={'cn': (348, 77, 560, 381), 'en': (348, 77, 562, 381), 'jp': (348, 77, 560, 381), 'tw': (348, 77, 560, 381)}, file={'cn': './assets/cn/exercise/OPPONENT_2.png', 'en': './assets/en/exercise/OPPONENT_2.png', 'jp': './assets/jp/exercise/OPPONENT_2.png', 'tw': './assets/tw/exercise/OPPONENT_2.png'})
|
OPPONENT_2 = Button(area={'cn': (348, 77, 560, 381), 'en': (348, 77, 562, 381), 'jp': (348, 77, 560, 381), 'tw': (348, 77, 560, 381)}, color={'cn': (105, 123, 149), 'en': (105, 122, 150), 'jp': (105, 123, 149), 'tw': (105, 123, 149)}, button={'cn': (348, 77, 560, 381), 'en': (348, 77, 562, 381), 'jp': (348, 77, 560, 381), 'tw': (348, 77, 560, 381)}, file={'cn': './assets/cn/exercise/OPPONENT_2.png', 'en': './assets/en/exercise/OPPONENT_2.png', 'jp': './assets/jp/exercise/OPPONENT_2.png', 'tw': './assets/tw/exercise/OPPONENT_2.png'})
|
||||||
OPPONENT_3 = Button(area={'cn': (592, 77, 804, 381), 'en': (592, 77, 806, 381), 'jp': (592, 77, 804, 381), 'tw': (592, 77, 804, 381)}, color={'cn': (106, 131, 158), 'en': (105, 129, 156), 'jp': (106, 131, 158), 'tw': (106, 131, 158)}, button={'cn': (592, 77, 804, 381), 'en': (592, 77, 806, 381), 'jp': (592, 77, 804, 381), 'tw': (592, 77, 804, 381)}, file={'cn': './assets/cn/exercise/OPPONENT_3.png', 'en': './assets/en/exercise/OPPONENT_3.png', 'jp': './assets/jp/exercise/OPPONENT_3.png', 'tw': './assets/tw/exercise/OPPONENT_3.png'})
|
OPPONENT_3 = Button(area={'cn': (592, 77, 804, 381), 'en': (592, 77, 806, 381), 'jp': (592, 77, 804, 381), 'tw': (592, 77, 804, 381)}, color={'cn': (106, 131, 158), 'en': (105, 129, 156), 'jp': (106, 131, 158), 'tw': (106, 131, 158)}, button={'cn': (592, 77, 804, 381), 'en': (592, 77, 806, 381), 'jp': (592, 77, 804, 381), 'tw': (592, 77, 804, 381)}, file={'cn': './assets/cn/exercise/OPPONENT_3.png', 'en': './assets/en/exercise/OPPONENT_3.png', 'jp': './assets/jp/exercise/OPPONENT_3.png', 'tw': './assets/tw/exercise/OPPONENT_3.png'})
|
||||||
|
|||||||
@@ -1,16 +1,83 @@
|
|||||||
|
from datetime import timedelta
|
||||||
from module.config.utils import get_server_last_update
|
from module.config.utils import get_server_last_update
|
||||||
from module.exercise.assets import *
|
from module.exercise.assets import *
|
||||||
from module.exercise.combat import ExerciseCombat
|
from module.exercise.combat import ExerciseCombat
|
||||||
from module.logger import logger
|
from module.logger import logger
|
||||||
from module.ocr.ocr import Digit
|
from module.ocr.ocr import Digit, Ocr, OcrYuv
|
||||||
from module.ui.ui import page_exercise
|
from module.ui.ui import page_exercise
|
||||||
|
|
||||||
|
|
||||||
|
class DatedDuration(Ocr):
|
||||||
|
def __init__(self, buttons, lang='cnocr', letter=(255, 255, 255), threshold=128, alphabet='0123456789:IDS天日d',
|
||||||
|
name=None):
|
||||||
|
super().__init__(buttons, lang=lang, letter=letter, threshold=threshold, alphabet=alphabet, name=name)
|
||||||
|
|
||||||
|
def after_process(self, result):
|
||||||
|
result = super().after_process(result)
|
||||||
|
result = result.replace('I', '1').replace('D', '0').replace('S', '5')
|
||||||
|
return result
|
||||||
|
|
||||||
|
def ocr(self, image, direct_ocr=False):
|
||||||
|
"""
|
||||||
|
Do OCR on a dated duration, such as `10d 01:30:30` or `7日01:30:30`.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
image:
|
||||||
|
direct_ocr:
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list, datetime.timedelta: timedelta object, or a list of it.
|
||||||
|
"""
|
||||||
|
result_list = super().ocr(image, direct_ocr=direct_ocr)
|
||||||
|
if not isinstance(result_list, list):
|
||||||
|
result_list = [result_list]
|
||||||
|
result_list = [self.parse_time(result) for result in result_list]
|
||||||
|
if len(self.buttons) == 1:
|
||||||
|
result_list = result_list[0]
|
||||||
|
return result_list
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def parse_time(string):
|
||||||
|
"""
|
||||||
|
Args:
|
||||||
|
string (str): `10d 01:30:30` or `7日01:30:30`
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
datetime.timedelta:
|
||||||
|
"""
|
||||||
|
import re
|
||||||
|
result = re.search(r'(\d{1,2})\D?(\d{1,2}):?(\d{2}):?(\d{2})', string)
|
||||||
|
if result:
|
||||||
|
result = [int(s) for s in result.groups()]
|
||||||
|
return timedelta(days=result[0], hours=result[1], minutes=result[2], seconds=result[3])
|
||||||
|
else:
|
||||||
|
logger.warning(f'Invalid dated duration: {string}')
|
||||||
|
return timedelta(days=0, hours=0, minutes=0, seconds=0)
|
||||||
|
|
||||||
|
|
||||||
|
class DatedDurationYuv(DatedDuration, OcrYuv):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
OCR_EXERCISE_REMAIN = Digit(OCR_EXERCISE_REMAIN, letter=(173, 247, 74), threshold=128)
|
OCR_EXERCISE_REMAIN = Digit(OCR_EXERCISE_REMAIN, letter=(173, 247, 74), threshold=128)
|
||||||
|
OCR_PERIOD_REMAIN = DatedDuration(OCR_PERIOD_REMAIN, letter=(255, 255, 255), threshold=128)
|
||||||
|
ADMIRAL_TRIAL_HOUR_INTERVAL = {
|
||||||
|
# "aggressive": [336, 0]
|
||||||
|
"sun18": [6, 0],
|
||||||
|
"sun12": [12, 6],
|
||||||
|
"sun0": [24, 12],
|
||||||
|
"sat18": [30, 24],
|
||||||
|
"sat12": [36, 30],
|
||||||
|
"sat0": [48, 36],
|
||||||
|
"fri18": [56, 48]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class Exercise(ExerciseCombat):
|
class Exercise(ExerciseCombat):
|
||||||
opponent_change_count = 0
|
opponent_change_count = 0
|
||||||
remain = 0
|
remain = 0
|
||||||
|
preserve = 0
|
||||||
|
|
||||||
|
|
||||||
def _new_opponent(self):
|
def _new_opponent(self):
|
||||||
logger.info('New opponent')
|
logger.info('New opponent')
|
||||||
@@ -105,14 +172,61 @@ class Exercise(ExerciseCombat):
|
|||||||
self.config.set_record(Exercise_OpponentRefreshValue=0)
|
self.config.set_record(Exercise_OpponentRefreshValue=0)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
def server_support_ocr_reset_remain(self) -> bool:
|
||||||
|
return self.config.SERVER in ['cn', 'en', 'jp']
|
||||||
|
|
||||||
|
|
||||||
|
def _get_exercise_reset_remain(self):
|
||||||
|
"""
|
||||||
|
Returns:
|
||||||
|
datetime.timedelta
|
||||||
|
"""
|
||||||
|
result = OCR_PERIOD_REMAIN.ocr(self.device.image)
|
||||||
|
return result
|
||||||
|
|
||||||
|
def _get_exercise_strategy(self):
|
||||||
|
"""
|
||||||
|
Returns:
|
||||||
|
int: ExercisePreserve, X times to remain
|
||||||
|
list, int: Admiral trial time period
|
||||||
|
"""
|
||||||
|
if self.config.Exercise_ExerciseStrategy == "aggressive":
|
||||||
|
preserve = 0
|
||||||
|
admiral_interval = None
|
||||||
|
else:
|
||||||
|
preserve = 5
|
||||||
|
admiral_interval = ADMIRAL_TRIAL_HOUR_INTERVAL[self.config.Exercise_ExerciseStrategy]
|
||||||
|
|
||||||
|
return preserve, admiral_interval
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self.ui_ensure(page_exercise)
|
self.ui_ensure(page_exercise)
|
||||||
|
|
||||||
self.opponent_change_count = self._get_opponent_change_count()
|
self.opponent_change_count = self._get_opponent_change_count()
|
||||||
logger.attr("Change_opponent_count", self.opponent_change_count)
|
logger.attr("Change_opponent_count", self.opponent_change_count)
|
||||||
|
self.preserve, admiral_interval = self._get_exercise_strategy()
|
||||||
|
|
||||||
|
if not self.server_support_ocr_reset_remain():
|
||||||
|
logger.info(f'Server {self.config.SERVER} does not yet support OCR exercise reset remain time')
|
||||||
|
logger.info('Please contact the developer to improve as soon as possible')
|
||||||
|
remain_time = timedelta(days=0)
|
||||||
|
else:
|
||||||
|
remain_time = OCR_PERIOD_REMAIN.ocr(self.device.image)
|
||||||
|
|
||||||
|
if admiral_interval is not None and remain_time:
|
||||||
|
admiral_start, admiral_end = admiral_interval
|
||||||
|
|
||||||
|
if admiral_start > int(remain_time.total_seconds() // 3600) >= admiral_end: #set time for getting admiral
|
||||||
|
logger.info('Reach set time for admiral trial, using all attempts.')
|
||||||
|
self.preserve = 0
|
||||||
|
elif int(remain_time.total_seconds() // 3600) < 6: #if not set to "sun18", still depleting at sunday 18pm.
|
||||||
|
logger.info('Exercise period remain less than 6 hours, using all attempts.')
|
||||||
|
self.preserve = 0
|
||||||
|
|
||||||
while 1:
|
while 1:
|
||||||
self.remain = OCR_EXERCISE_REMAIN.ocr(self.device.image)
|
self.remain = OCR_EXERCISE_REMAIN.ocr(self.device.image)
|
||||||
if self.remain <= self.config.Exercise_ExercisePreserve:
|
if self.remain <= self.preserve:
|
||||||
break
|
break
|
||||||
|
|
||||||
logger.hr(f'Exercise remain {self.remain}', level=1)
|
logger.hr(f'Exercise remain {self.remain}', level=1)
|
||||||
@@ -124,12 +238,13 @@ class Exercise(ExerciseCombat):
|
|||||||
logger.info('New opponent exhausted')
|
logger.info('New opponent exhausted')
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
# self.equipment_take_off_when_finished()
|
# self.equipment_take_off_when_finished()
|
||||||
|
|
||||||
# Scheduler
|
# Scheduler
|
||||||
with self.config.multi_set():
|
with self.config.multi_set():
|
||||||
self.config.set_record(Exercise_OpponentRefreshValue=self.opponent_change_count)
|
self.config.set_record(Exercise_OpponentRefreshValue=self.opponent_change_count)
|
||||||
if self.remain <= self.config.Exercise_ExercisePreserve or self.opponent_change_count >= 5:
|
if self.remain <= self.preserve or self.opponent_change_count >= 5:
|
||||||
self.config.task_delay(server_update=True)
|
self.config.task_delay(server_update=True)
|
||||||
else:
|
else:
|
||||||
self.config.task_delay(success=False)
|
self.config.task_delay(success=False)
|
||||||
|
|||||||
@@ -250,3 +250,4 @@ class Duration(Ocr):
|
|||||||
|
|
||||||
class DurationYuv(Duration, OcrYuv):
|
class DurationYuv(Duration, OcrYuv):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user