示例#1
0
    def get_power(self, image):
        grids = ButtonGrid(origin=(222, 266), delta=(244, 30), button_shape=(72, 15), grid_shape=(4, 2), name='POWER')
        power = [grids[self.index, 0], grids[self.index, 1]]

        power = Digit(power, letter=(255, 223, 57), back=(74, 109, 156), threshold=221, limit=17000, name='POWER')
        result = power.ocr(image)
        return result
示例#2
0
    def get_level(self, image):
        level = []
        level += ButtonGrid(origin=(130, 259), delta=(168, 0), button_shape=(57, 21), grid_shape=(3, 1), name='LEVEL').buttons()
        level += ButtonGrid(origin=(832, 259), delta=(168, 0), button_shape=(57, 21), grid_shape=(3, 1), name='LEVEL').buttons()

        level = Digit(level, letter=(255, 255, 255), back=(102, 102, 102), limit=120, threshold=127, additional_preprocess=self.process, name='LEVEL')
        result = level.ocr(image)
        return result
示例#3
0
import copy
import importlib
import os
from datetime import datetime

from module.base.ocr import Digit
from module.campaign.assets import *
from module.campaign.campaign_base import CampaignBase
from module.campaign.campaign_ui import CampaignUI
from module.config.config import AzurLaneConfig
from module.exception import ScriptEnd, CampaignNameError
from module.logger import logger
from module.reward.reward import Reward

OCR_OIL = Digit(OCR_OIL, letter=(247, 247, 247), back=(33, 36, 49), limit=25000, name='OCR_OIL')


class CampaignRun(CampaignUI, Reward):
    folder: str
    name: str
    stage: str
    module = None
    config: AzurLaneConfig
    campaign: CampaignBase
    run_count: int

    def load_campaign(self, name, folder='campaign_main'):
        """
        Args:
            name (str): Name of .py file under module.campaign.
            folder (str): Name of the file folder under campaign.
示例#4
0
from module.base.ocr import Digit
from module.exercise.assets import *
from module.exercise.combat import ExerciseCombat
from module.logger import logger
from module.ui.ui import page_exercise

OCR_EXERCISE_REMAIN = Digit(OCR_EXERCISE_REMAIN,
                            letter=(173, 247, 74),
                            back=(66, 89, 140),
                            limit=10)
RECORD_OPTION = ('DailyRecord', 'exercise')
RECORD_SINCE = (
    0,
    12,
    18,
)


class Exercise(ExerciseCombat):
    opponent_change_count = 0

    def _new_opponent(self):
        logger.info('New opponent')
        self.appear_then_click(NEW_OPPONENT)
        self.opponent_change_count += 1
        self.device.sleep(1)

    def _exercise_once(self):
        self._opponent_fleet_check_all()
        while self.opponent_change_count <= 5:
            for opponent in self._opponent_sort():
示例#5
0
from module.base.ocr import Digit
from module.logger import logger
from module.raid.assets import *
from module.raid.run import RaidRun
from module.ui.page import page_raid

RECORD_OPTION = ('DailyRecord', 'raid')
RECORD_SINCE = (0, )

LETTER = (57, 52, 255)
BACK = (123, 178, 255)
THRESHOLD = 75
OCR_EASY = Digit(OCR_REMAIN_EASY,
                 letter=LETTER,
                 back=BACK,
                 limit=15,
                 threshold=THRESHOLD)
OCR_NORMAL = Digit(OCR_REMAIN_NORMAL,
                   letter=LETTER,
                   back=BACK,
                   limit=15,
                   threshold=THRESHOLD)
OCR_HARD = Digit(OCR_REMAIN_HARD,
                 letter=LETTER,
                 back=BACK,
                 limit=15,
                 threshold=THRESHOLD)


class RaidDaily(RaidRun):
    def get_remain(self, mode):
示例#6
0
import numpy as np

from module.base.ocr import Digit
from module.base.utils import get_color
from module.combat.combat import Combat
from module.daily.assets import *
from module.equipment.fleet_equipment import DailyEquipment
from module.logger import logger
from module.ui.ui import page_daily, page_campaign, BACK_ARROW, DAILY_CHECK

DAILY_MISSION_LIST = [DAILY_MISSION_1, DAILY_MISSION_2, DAILY_MISSION_3]
OCR_REMAIN = Digit(OCR_REMAIN, letter=(255, 255, 255), back=(127, 127, 127), length=1, white_list='0123')
OCR_DAILY_FLEET_INDEX = Digit(OCR_DAILY_FLEET_INDEX, letter=(90, 154, 255), back=(24, 32, 49), length=1,
                              white_list='123456')
RECORD_OPTION = ('DailyRecord', 'daily')
RECORD_SINCE = (0,)


class Daily(Combat, DailyEquipment):
    daily_current: int
    daily_checked: list

    def is_active(self):
        color = get_color(image=self.device.image, area=DAILY_ACTIVE.area)
        color = np.array(color).astype(float)
        color = (np.max(color) + np.min(color)) / 2
        active = color > 30
        if active:
            logger.attr(f'Daily_{self.daily_current}', 'active')
        else:
            logger.attr(f'Daily_{self.daily_current}', 'inactive')
示例#7
0
import importlib

from module.base.ocr import Digit
from campaign.campaign_hard.campaign_hard import Campaign
from module.campaign.run import CampaignRun
from module.hard.assets import *
from module.logger import logger

OCR_HARD_REMAIN = Digit(OCR_HARD_REMAIN,
                        letter=(123, 227, 66),
                        back=(24, 24, 24),
                        limit=3,
                        name='OCR_HARD_REMAIN')
RECORD_OPTION = ('DailyRecord', 'hard')
RECORD_SINCE = (0, )


class CampaignHard(CampaignRun):
    equipment_has_take_on = False
    campaign: Campaign

    def run(self):
        logger.hr('Campaign hard', level=1)
        chapter, stage = self.config.HARD_CAMPAIGN.split('-')
        name = f'campaign_{chapter}_{stage}'

        # Initial
        self.load_campaign(name='campaign_hard',
                           folder='campaign_hard')  # Load campaign file
        module = importlib.import_module(
            '.' + name, 'campaign.campaign_main')  # Load map from normal mode.
示例#8
0
from module.base.ocr import Digit
from module.equipment.assets import *
from module.equipment.equipment import Equipment
from module.ui.assets import FLEET_CHECK
from module.ui.ui import UI, page_fleet

OCR_FLEET_INDEX = Digit(OCR_FLEET_INDEX,
                        letter=(90, 154, 255),
                        back=(24, 32, 49),
                        length=1,
                        white_list='123456')


class DailyEquipment(UI, Equipment):
    equipment_has_take_on = False

    def equipment_take_on(self):
        if self.config.FLEET_DAILY_EQUIPMENT is None:
            return False
        if self.equipment_has_take_on:
            return False

        self.ui_ensure(page_fleet)
        self.ui_ensure_index(self.config.FLEET_DAILY,
                             letter=OCR_FLEET_INDEX,
                             next_button=FLEET_NEXT,
                             prev_button=FLEET_PREV)
        super().equipment_take_on(enter=FLEET_ENTER,
                                  out=FLEET_CHECK,
                                  fleet=self.config.FLEET_DAILY_EQUIPMENT)
        self.equipment_has_take_on = True