mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-16 15:07:22 +08:00
Dev: Add SHOP_EXTRACT_TEMPLATE to collect new item templates
This commit is contained in:
@@ -6,7 +6,6 @@ from module.base.decorator import cached_property
|
||||
from module.base.filter import Filter
|
||||
from module.base.timer import Timer
|
||||
from module.combat.assets import GET_ITEMS_1, GET_SHIP
|
||||
from module.exception import ScriptError
|
||||
from module.logger import logger
|
||||
from module.shop.assets import *
|
||||
from module.shop.shop_select_globals import *
|
||||
@@ -82,6 +81,7 @@ class ShopItemGrid(ItemGrid):
|
||||
|
||||
class ShopBase(ModuleBase):
|
||||
_currency = 0
|
||||
shop_template_folder = ''
|
||||
|
||||
@cached_property
|
||||
def shop_filter(self):
|
||||
@@ -145,6 +145,13 @@ class ShopBase(ModuleBase):
|
||||
logger.warning('Expected type \'ShopItemGrid\' but was None')
|
||||
return []
|
||||
|
||||
if self.config.SHOP_EXTRACT_TEMPLATE:
|
||||
if self.shop_template_folder:
|
||||
logger.info(f'Extract item templates to {self.shop_template_folder}')
|
||||
shop_items.extract_template(image, self.shop_template_folder)
|
||||
else:
|
||||
logger.warning('SHOP_EXTRACT_TEMPLATE enabled but shop_template_folder is not set, skip extracting')
|
||||
|
||||
shop_items.predict(
|
||||
image,
|
||||
name=True,
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
from module.base.decorator import cached_property
|
||||
from module.exception import ScriptError
|
||||
from module.logger import logger
|
||||
from module.ocr.ocr import Digit
|
||||
from module.shop.assets import *
|
||||
@@ -10,6 +9,8 @@ OCR_SHOP_CORE = Digit(SHOP_CORE, letter=(239, 239, 239), name='OCR_SHOP_CORE')
|
||||
|
||||
|
||||
class CoreShop(ShopClerk):
|
||||
shop_template_folder = './assets/shop/core'
|
||||
|
||||
@cached_property
|
||||
def shop_filter(self):
|
||||
"""
|
||||
@@ -26,7 +27,7 @@ class CoreShop(ShopClerk):
|
||||
"""
|
||||
shop_grid = self.shop_grid
|
||||
shop_core_items = ShopItemGrid(shop_grid, templates={}, amount_area=(60, 74, 96, 95))
|
||||
shop_core_items.load_template_folder('./assets/shop/core')
|
||||
shop_core_items.load_template_folder(self.shop_template_folder)
|
||||
shop_core_items.load_cost_template_folder('./assets/shop/cost')
|
||||
return shop_core_items
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ OCR_SHOP_GEMS = Digit(SHOP_GEMS, letter=(255, 243, 82), name='OCR_SHOP_GEMS')
|
||||
|
||||
class GeneralShop(ShopClerk, ShopUI):
|
||||
gems = 0
|
||||
shop_template_folder = './assets/shop/general'
|
||||
|
||||
@cached_property
|
||||
def shop_filter(self):
|
||||
@@ -29,7 +30,7 @@ class GeneralShop(ShopClerk, ShopUI):
|
||||
"""
|
||||
shop_grid = self.shop_grid
|
||||
shop_general_items = ShopItemGrid(shop_grid, templates={}, amount_area=(60, 74, 96, 95))
|
||||
shop_general_items.load_template_folder('./assets/shop/general')
|
||||
shop_general_items.load_template_folder(self.shop_template_folder)
|
||||
shop_general_items.load_cost_template_folder('./assets/shop/cost')
|
||||
return shop_general_items
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
from module.base.decorator import Config, cached_property
|
||||
from module.base.timer import Timer
|
||||
from module.exception import ScriptError
|
||||
from module.logger import logger
|
||||
from module.ocr.ocr import Digit
|
||||
from module.shop.assets import *
|
||||
@@ -12,6 +10,8 @@ OCR_SHOP_GUILD_COINS = Digit(SHOP_GUILD_COINS, letter=(255, 255, 255), name='OCR
|
||||
|
||||
|
||||
class GuildShop(ShopClerk, ShopUI):
|
||||
shop_template_folder = './assets/shop/guild_cn'
|
||||
|
||||
@cached_property
|
||||
def shop_filter(self):
|
||||
"""
|
||||
@@ -29,7 +29,8 @@ class GuildShop(ShopClerk, ShopUI):
|
||||
"""
|
||||
shop_grid = self.shop_grid
|
||||
shop_guild_items = ShopItemGrid(shop_grid, templates={}, amount_area=(60, 74, 96, 95))
|
||||
shop_guild_items.load_template_folder('./assets/shop/guild_cn')
|
||||
self.shop_template_folder = './assets/shop/guild_cn'
|
||||
shop_guild_items.load_template_folder(self.shop_template_folder)
|
||||
shop_guild_items.load_cost_template_folder('./assets/shop/cost')
|
||||
return shop_guild_items
|
||||
|
||||
@@ -42,7 +43,8 @@ class GuildShop(ShopClerk, ShopUI):
|
||||
"""
|
||||
shop_grid = self.shop_grid
|
||||
shop_guild_items = ShopItemGrid(shop_grid, templates={}, amount_area=(60, 74, 96, 95))
|
||||
shop_guild_items.load_template_folder('./assets/shop/guild_cn')
|
||||
self.shop_template_folder = './assets/shop/guild_cn'
|
||||
shop_guild_items.load_template_folder(self.shop_template_folder)
|
||||
shop_guild_items.load_cost_template_folder('./assets/shop/cost')
|
||||
return shop_guild_items
|
||||
|
||||
@@ -55,7 +57,8 @@ class GuildShop(ShopClerk, ShopUI):
|
||||
"""
|
||||
shop_grid = self.shop_grid
|
||||
shop_guild_items = ShopItemGrid(shop_grid, templates={}, amount_area=(60, 74, 96, 95))
|
||||
shop_guild_items.load_template_folder('./assets/shop/guild_cn')
|
||||
self.shop_template_folder = './assets/shop/guild_cn'
|
||||
shop_guild_items.load_template_folder(self.shop_template_folder)
|
||||
shop_guild_items.load_cost_template_folder('./assets/shop/cost')
|
||||
return shop_guild_items
|
||||
|
||||
@@ -68,7 +71,8 @@ class GuildShop(ShopClerk, ShopUI):
|
||||
"""
|
||||
shop_grid = self.shop_grid
|
||||
shop_guild_items = ShopItemGrid(shop_grid, templates={}, amount_area=(60, 74, 96, 95))
|
||||
shop_guild_items.load_template_folder('./assets/shop/guild')
|
||||
self.shop_template_folder = './assets/shop/guild'
|
||||
shop_guild_items.load_template_folder(self.shop_template_folder)
|
||||
shop_guild_items.load_cost_template_folder('./assets/shop/cost')
|
||||
return shop_guild_items
|
||||
|
||||
|
||||
@@ -106,6 +106,8 @@ class MedalShop2(ShopClerk):
|
||||
origin=(477, origin_y), delta=(156, delta_y), button_shape=(96, 96), grid_shape=(5, row), name='SHOP_GRID')
|
||||
return shop_grid
|
||||
|
||||
shop_template_folder = './assets/shop/medal'
|
||||
|
||||
@cached_property
|
||||
def shop_medal_items(self):
|
||||
"""
|
||||
@@ -117,7 +119,7 @@ class MedalShop2(ShopClerk):
|
||||
shop_grid,
|
||||
templates={}, amount_area=(60, 74, 96, 95),
|
||||
price_area=(52, 132, 132, 162))
|
||||
shop_medal_items.load_template_folder('./assets/shop/medal')
|
||||
shop_medal_items.load_template_folder(self.shop_template_folder)
|
||||
shop_medal_items.load_cost_template_folder('./assets/shop/cost')
|
||||
shop_medal_items.similarity = 0.85 # Lower the threshold for consistent matches of PR/DRBP
|
||||
shop_medal_items.cost_similarity = 0.5
|
||||
|
||||
@@ -10,6 +10,8 @@ OCR_SHOP_MERIT = Digit(SHOP_MERIT, letter=(239, 239, 239), name='OCR_SHOP_MERIT'
|
||||
|
||||
|
||||
class MeritShop(ShopClerk, ShopUI):
|
||||
shop_template_folder = './assets/shop/merit'
|
||||
|
||||
@cached_property
|
||||
def shop_filter(self):
|
||||
"""
|
||||
@@ -26,7 +28,7 @@ class MeritShop(ShopClerk, ShopUI):
|
||||
"""
|
||||
shop_grid = self.shop_grid
|
||||
shop_merit_items = ShopItemGrid(shop_grid, templates={}, amount_area=(60, 74, 96, 95))
|
||||
shop_merit_items.load_template_folder('./assets/shop/merit')
|
||||
shop_merit_items.load_template_folder(self.shop_template_folder)
|
||||
shop_merit_items.load_cost_template_folder('./assets/shop/cost')
|
||||
return shop_merit_items
|
||||
|
||||
|
||||
@@ -102,6 +102,8 @@ class VoucherShop(ShopClerk):
|
||||
name='SHOP_GRID')
|
||||
return shop_grid
|
||||
|
||||
shop_template_folder = './assets/shop/voucher'
|
||||
|
||||
@cached_property
|
||||
def shop_voucher_items(self):
|
||||
"""
|
||||
@@ -113,7 +115,7 @@ class VoucherShop(ShopClerk):
|
||||
shop_grid,
|
||||
templates={}, amount_area=(60, 74, 96, 95),
|
||||
price_area=(52, 132, 132, 162))
|
||||
shop_voucher_items.load_template_folder('./assets/shop/voucher')
|
||||
shop_voucher_items.load_template_folder(self.shop_template_folder)
|
||||
shop_voucher_items.load_cost_template_folder('./assets/shop/cost')
|
||||
shop_voucher_items.similarity = 0.85
|
||||
shop_voucher_items.cost_similarity = 0.5
|
||||
|
||||
Reference in New Issue
Block a user