mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-26 18:20:42 +00:00
commit
30120268d0
@ -3,8 +3,6 @@ import os
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
os.chdir('../')
|
|
||||||
|
|
||||||
from module.base.button import get_color
|
from module.base.button import get_color
|
||||||
from module.config.config import AzurLaneConfig
|
from module.config.config import AzurLaneConfig
|
||||||
from module.logger import logger
|
from module.logger import logger
|
||||||
@ -179,5 +177,5 @@ class AssetExtractor:
|
|||||||
me = ModuleExtractor(name=module, config=config)
|
me = ModuleExtractor(name=module, config=config)
|
||||||
me.write()
|
me.write()
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
ae = AssetExtractor(AzurLaneConfig())
|
ae = AssetExtractor(AzurLaneConfig('template'))
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
import module.config.server as server
|
||||||
|
|
||||||
|
server.server = 'cn' # Don't need to edit, it's used to avoid error.
|
||||||
|
|
||||||
from module.config.config import AzurLaneConfig
|
from module.config.config import AzurLaneConfig
|
||||||
from module.device.device import Device
|
from module.device.device import Device
|
||||||
@ -33,5 +36,5 @@ class Config:
|
|||||||
USE_ADB_SCREENSHOT = False
|
USE_ADB_SCREENSHOT = False
|
||||||
|
|
||||||
|
|
||||||
az = EmulatorChecker(AzurLaneConfig().merge(Config()))
|
az = EmulatorChecker(AzurLaneConfig('template').merge(Config()))
|
||||||
az.stress_test()
|
az.stress_test()
|
||||||
|
@ -78,6 +78,10 @@ BATTLE_PREPARATION = Button(area=(1043, 607, 1241, 667), color=(234, 179, 97), b
|
|||||||
|
|
||||||
button_extract.py会自动提取按钮的属性, 免去了人工输入的烦恼
|
button_extract.py会自动提取按钮的属性, 免去了人工输入的烦恼
|
||||||
|
|
||||||
|
```
|
||||||
|
python -m dev_tools.button_extract
|
||||||
|
```
|
||||||
|
|
||||||
8. **使用按钮**
|
8. **使用按钮**
|
||||||
|
|
||||||
继承 module.base.base 下的 ModuleBase 类, 可以调用以下方法:
|
继承 module.base.base 下的 ModuleBase 类, 可以调用以下方法:
|
||||||
|
@ -1,92 +0,0 @@
|
|||||||
from module.base.timer import Timer
|
|
||||||
from module.campaign.campaign_base import CampaignBase
|
|
||||||
from module.hard.equipment import HardEquipment
|
|
||||||
from module.logger import logger
|
|
||||||
from module.map.assets import MAP_PREPARATION, FLEET_PREPARATION
|
|
||||||
from module.exception import CampaignEnd
|
|
||||||
from module.ui.ui import CAMPAIGN_CHECK
|
|
||||||
|
|
||||||
|
|
||||||
class Config:
|
|
||||||
MAP_HAS_AMBUSH = False
|
|
||||||
EMOTION_REDUCE = False
|
|
||||||
|
|
||||||
class Campaign(CampaignBase, HardEquipment):
|
|
||||||
def run(self):
|
|
||||||
logger.hr(self.ENTRANCE, level=2)
|
|
||||||
self.enter_map(self.ENTRANCE, mode='hard')
|
|
||||||
self.map = self.MAP
|
|
||||||
self.map.reset()
|
|
||||||
|
|
||||||
if self.config.FLEET_HARD == 1:
|
|
||||||
self.ensure_edge_insight(reverse=True)
|
|
||||||
self.full_scan_find_boss()
|
|
||||||
else:
|
|
||||||
self.fleet_switch_click()
|
|
||||||
self.ensure_no_info_bar()
|
|
||||||
self.ensure_edge_insight()
|
|
||||||
self.full_scan_find_boss()
|
|
||||||
|
|
||||||
try:
|
|
||||||
self.clear_boss()
|
|
||||||
except CampaignEnd:
|
|
||||||
logger.hr('Campaign end')
|
|
||||||
|
|
||||||
def fleet_preparation(self):
|
|
||||||
self.equipment_take_on()
|
|
||||||
|
|
||||||
@property
|
|
||||||
def _expected_combat_end(self):
|
|
||||||
return 'in_stage'
|
|
||||||
|
|
||||||
def clear_boss(self):
|
|
||||||
grids = self.map.select(is_boss=True)
|
|
||||||
grids = grids.add(self.map.select(may_boss=True, is_enemy=True))
|
|
||||||
logger.info('May boss: %s' % self.map.select(may_boss=True))
|
|
||||||
logger.info('May boss and is enemy: %s' % self.map.select(may_boss=True, is_enemy=True))
|
|
||||||
logger.info('Is boss: %s' % self.map.select(is_boss=True))
|
|
||||||
# logger.info('Grids: %s' % grids)
|
|
||||||
if grids:
|
|
||||||
logger.hr('Clear BOSS')
|
|
||||||
grids = grids.sort(cost=True, weight=True)
|
|
||||||
logger.info('Grids: %s' % str(grids))
|
|
||||||
self._goto(grids[0])
|
|
||||||
raise CampaignEnd('BOSS Clear.')
|
|
||||||
|
|
||||||
return False
|
|
||||||
|
|
||||||
def equipment_take_off_when_finished(self):
|
|
||||||
logger.info('equipment_take_off_when_finished')
|
|
||||||
campaign_timer = Timer(2)
|
|
||||||
map_timer = Timer(1)
|
|
||||||
fleet_timer = Timer(1)
|
|
||||||
|
|
||||||
while 1:
|
|
||||||
self.device.screenshot()
|
|
||||||
|
|
||||||
# Enter campaign
|
|
||||||
if campaign_timer.reached() and self.appear_then_click(self.ENTRANCE):
|
|
||||||
campaign_timer.reset()
|
|
||||||
continue
|
|
||||||
|
|
||||||
# Map preparation
|
|
||||||
if map_timer.reached() and self.appear(MAP_PREPARATION):
|
|
||||||
self.device.click(MAP_PREPARATION)
|
|
||||||
map_timer.reset()
|
|
||||||
campaign_timer.reset()
|
|
||||||
continue
|
|
||||||
|
|
||||||
# Fleet preparation
|
|
||||||
if fleet_timer.reached() and self.appear(FLEET_PREPARATION):
|
|
||||||
self.equipment_take_off()
|
|
||||||
self.ui_back(check_button=CAMPAIGN_CHECK, appear_button=FLEET_PREPARATION)
|
|
||||||
break
|
|
||||||
|
|
||||||
# Retire
|
|
||||||
if self.handle_retirement():
|
|
||||||
continue
|
|
||||||
|
|
||||||
# Emotion
|
|
||||||
pass
|
|
||||||
|
|
||||||
return True
|
|
@ -96,7 +96,6 @@ class Combat(HPBalancer, EnemySearchingHandler, Retirement, SubmarineCall, Comba
|
|||||||
self.emotion.wait(fleet=fleet_index)
|
self.emotion.wait(fleet=fleet_index)
|
||||||
if balance_hp:
|
if balance_hp:
|
||||||
self.hp_balance()
|
self.hp_balance()
|
||||||
# logger.info('start combat')
|
|
||||||
|
|
||||||
while 1:
|
while 1:
|
||||||
self.device.screenshot()
|
self.device.screenshot()
|
||||||
@ -105,7 +104,12 @@ class Combat(HPBalancer, EnemySearchingHandler, Retirement, SubmarineCall, Comba
|
|||||||
if self.handle_combat_automation_set(auto=auto):
|
if self.handle_combat_automation_set(auto=auto):
|
||||||
continue
|
continue
|
||||||
if self.handle_retirement():
|
if self.handle_retirement():
|
||||||
continue
|
if self.config.ENABLE_HP_BALANCE:
|
||||||
|
self.wait_until_appear(BATTLE_PREPARATION)
|
||||||
|
# When re-entering battle_preparation page, the emergency icon is active by default, even if
|
||||||
|
# nothing to use. After a short animation, everything shows as usual.
|
||||||
|
self.device.sleep(0.5) # Wait animation.
|
||||||
|
continue
|
||||||
if self.handle_combat_low_emotion():
|
if self.handle_combat_low_emotion():
|
||||||
continue
|
continue
|
||||||
if self.handle_emergency_repair_use():
|
if self.handle_emergency_repair_use():
|
||||||
@ -157,6 +161,8 @@ class Combat(HPBalancer, EnemySearchingHandler, Retirement, SubmarineCall, Comba
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def handle_emergency_repair_use(self):
|
def handle_emergency_repair_use(self):
|
||||||
|
if not self.config.ENABLE_HP_BALANCE:
|
||||||
|
return False
|
||||||
if self.appear_then_click(EMERGENCY_REPAIR_CONFIRM, offset=True):
|
if self.appear_then_click(EMERGENCY_REPAIR_CONFIRM, offset=True):
|
||||||
self.device.sleep(0.5) # Animation: hp increase and emergency_repair amount decrease.
|
self.device.sleep(0.5) # Animation: hp increase and emergency_repair amount decrease.
|
||||||
return True
|
return True
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import importlib
|
import importlib
|
||||||
|
|
||||||
from module.base.ocr import Digit
|
from module.base.ocr import Digit
|
||||||
from module.campaign.campaign_hard import Campaign
|
from campaign.campaign_hard.campaign_hard import Campaign
|
||||||
from module.campaign.run import CampaignRun
|
from module.campaign.run import CampaignRun
|
||||||
from module.hard.assets import *
|
from module.hard.assets import *
|
||||||
from module.logger import logger
|
from module.logger import logger
|
||||||
|
Loading…
Reference in New Issue
Block a user