From 9b388c554d059b0ef9db7944a2497a2aa11d0671 Mon Sep 17 00:00:00 2001 From: YoursFunny Date: Mon, 6 Jul 2026 16:16:12 +0800 Subject: [PATCH] feat: add `ModuleBase.match_template_luma()` --- module/base/base.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/module/base/base.py b/module/base/base.py index a795875..3084185 100644 --- a/module/base/base.py +++ b/module/base/base.py @@ -99,6 +99,36 @@ class ModuleBase: return appear + def match_template_luma(self, button, interval=0, similarity=0.85): + """ + Args: + button (ButtonWrapper): + interval (int, float): interval between two active events. + similarity (int, float): 0 to 1. + + Returns: + bool: + + Examples: + Image detection: + ``` + self.device.screenshot() + self.appear(Button(area=(...), color=(...), button=(...)) + self.appear(Template(file='...') + ``` + """ + self.device.stuck_record_add(button) + + if interval and not self.interval_is_reached(button, interval=interval): + return False + + appear = button.match_template_luma(self.device.image, similarity=similarity) + + if appear and interval: + self.interval_reset(button, interval=interval) + + return appear + def match_color(self, button, interval=0, threshold=10): """ Args: