Example #1
0
import cv2
import numpy as np
from scipy import optimize

from module.base.decorator import cached_property
from module.base.mask import Mask
from module.base.utils import crop

UI_MASK = Mask(file='./assets/mask/MASK_MAP_UI.png')
TILE_CENTER = Mask(file='./assets/map_detection/TILE_CENTER.png')
TILE_CORNER = Mask(file='./assets/map_detection/TILE_CORNER.png')


class Assets:
    @cached_property
    def ui_mask(self):
        return UI_MASK.image

    @cached_property
    def ui_mask_stroke(self):
        kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (3, 3))
        image = cv2.erode(self.ui_mask, kernel).astype('uint8')
        return image

    @cached_property
    def ui_mask_in_map(self):
        DETECTING_AREA = (123, 55, 1280, 720)
        area = np.append(np.subtract(0, DETECTING_AREA[:2]), self.ui_mask.shape[::-1])
        # area = (-123, -55, 1157, 665)
        return crop(self.ui_mask, area)
Example #2
0
from module.base.button import ButtonGrid
from module.base.decorator import Config, cached_property
from module.base.filter import Filter
from module.base.mask import Mask
from module.base.timer import Timer
from module.base.utils import *
from module.dorm.assets import *
from module.logger import logger
from module.ocr.ocr import Digit, DigitCounter
from module.template.assets import TEMPLATE_DORM_COIN, TEMPLATE_DORM_LOVE
from module.ui.assets import DORM_CHECK
from module.ui.page import page_dorm, page_dormmenu
from module.ui.ui import UI

MASK_DORM = Mask(file='./assets/mask/MASK_DORM.png')
DORM_CAMERA_SWIPE = (300, 250)
DORM_CAMERA_RANDOM = (-20, -20, 20, 20)
OCR_FILL = DigitCounter(OCR_DORM_FILL,
                        letter=(255, 247, 247),
                        threshold=128,
                        name='OCR_DORM_FILL')


class Food:
    def __init__(self, feed, amount):
        self.feed = feed
        self.amount = amount

    def __str__(self):
        return f'Food_{self.feed}'
Example #3
0
from module.base.mask import Mask
from module.base.utils import *
from module.config.config import AzurLaneConfig
from module.logger import logger
from module.map.map_grids import SelectedGrids
from module.map_detection.utils import fit_points

MASK_RADAR = Mask('./assets/mask/MASK_OS_RADAR.png')


class RadarGrid:
    is_enemy = False  # Red gun
    is_resource = False  # green box to get items
    is_exclamation = False  # Yellow exclamation mark '!'
    is_meowfficer = False  # Blue meowfficer
    is_question = False  # White question mark '?'
    is_ally = False  # Ally cargo ship in daily mission, yellow '!' on radar
    is_akashi = False  # White question mark '?'
    is_archive = False  # Purple archive
    is_port = False

    enemy_scale = 0
    enemy_genre = None  # Light, Main, Carrier, Treasure, Enemy(unknown)

    is_fleet = False

    dic_encode = {
        'EN': 'is_enemy',
        'RE': 'is_resource',
        'AR': 'is_archive',
        'EX': 'is_exclamation',
Example #4
0
from module.guild.assets import *
from module.guild.base import GuildBase
from module.logger import logger
from module.template.assets import TEMPLATE_OPERATIONS_RED_DOT, TEMPLATE_OPERATIONS_ADD

RECORD_OPTION_DISPATCH = ('RewardRecord', 'operations_dispatch')
RECORD_SINCE_DISPATCH = (
    6,
    12,
    18,
    21,
)
RECORD_OPTION_BOSS = ('RewardRecord', 'operations_boss')
RECORD_SINCE_BOSS = (0, )

MASK_OPERATIONS = Mask(file='./assets/mask/MASK_OPERATIONS.png')
MASK_SIDEBAR_RED_DOT = Mask(file='./assets/mask/MASK_SIDEBAR_RED_DOT.png')


class GuildOperations(GuildBase):
    def _guild_operations_mode_ensure(self, skip_first_screenshot=True):
        """
        Determine which operations menu has loaded
            0 - No ongoing operations, Officers/Elites/Leader must select one to begin
            1 - Operations available, displaying a state diagram/web of operations
            2 - Guild Raid Boss active
            Otherwise None if unable to ensure or determine the menu at all

        Pages:
            in: GUILD_OPERATIONS_ANY
            out: GUILD_OPERATIONS_ANY
Example #5
0
import re

import numpy as np
from PIL import Image

from module.base.mask import Mask
from module.ui.page import *

MASK_MAIN = Mask('./assets/mask/MASK_MAIN.png')
MASK_PLAYER = Mask('./assets/mask/MASK_PLAYER.png')


def put_image_mask(image, mask):
    """
    Args:
        image (PIL.Image.Image):
        mask (str): Filename

    Returns:
        PIL.Image.Image:
    """
    mask = Image.open(f'./assets/mask/{mask}.png').convert('L')
    new = Image.new('RGB', image.size, (0, 0, 0))
    new.paste(image, box=(0, 0, image.size[0], image.size[1]), mask=mask)
    return new


def handle_sensitive_image(image):
    """
    Args:
        image:
Example #6
0
from module.guild.assets import *
from module.guild.base import GuildBase
from module.logger import logger
from module.template.assets import TEMPLATE_OPERATIONS_RED_DOT, TEMPLATE_OPERATIONS_ADD

RECORD_OPTION_DISPATCH = ('RewardRecord', 'operations_dispatch')
RECORD_SINCE_DISPATCH = (
    6,
    12,
    18,
    21,
)
RECORD_OPTION_BOSS = ('RewardRecord', 'operations_boss')
RECORD_SINCE_BOSS = (0, )

MASK_OPERATIONS = Mask(file='./assets/mask/MASK_OPERATIONS.png')


class GuildOperations(GuildBase):
    def _guild_operations_mode_ensure(self, skip_first_screenshot=True):
        """
        Determine which operations menu has loaded
            0 - No ongoing operations, Officers/Elites/Leader must select one to begin
            1 - Operations available, displaying a state diagram/web of operations
            2 - Guild Raid Boss active
            Otherwise None if unable to ensure or determine the menu at all

        Pages:
            in: GUILD_OPERATIONS_ANY
            out: GUILD_OPERATIONS_ANY
        """
Example #7
0
from module.base.mask import Mask
from module.map_detection.utils_assets import ASSETS

# Patch ui_mask, get rid of map mechanism
_ = ASSETS.ui_mask
ASSETS.ui_mask = Mask(file='./assets/mask/MASK_MAP_UI_20211125.png').image

from module.campaign.campaign_base import CampaignBase as CampaignBase_


class CampaignBase(CampaignBase_):
    def campaign_ensure_mode(self, mode='normal'):
        """
        Args:
            mode (str): 'normal', 'hard', 'ex'

        Returns:
            bool: If mode changed.
        """
        # No need to switch
        pass

    def _campaign_get_chapter_index(self, name):
        """
        Args:
            name (str, int):

        Returns:
            int
        """
        if name == 't':