From 6387d9758d38673df0ced160b4a867986b23abf5 Mon Sep 17 00:00:00 2001 From: nEEtdo0d Date: Thu, 14 Jan 2021 15:13:22 -0500 Subject: [PATCH] Opt: Allow operations checking if event is present however record states already executed, may occur when operation has finished and new operation has begun in same time block --- assets/mask/MASK_SIDEBAR_RED_DOT.png | Bin 0 -> 3137 bytes module/guild/operations.py | 30 +++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 assets/mask/MASK_SIDEBAR_RED_DOT.png diff --git a/assets/mask/MASK_SIDEBAR_RED_DOT.png b/assets/mask/MASK_SIDEBAR_RED_DOT.png new file mode 100644 index 0000000000000000000000000000000000000000..09da6ec144a622e9639b261b98d25f9df0fbf2e8 GIT binary patch literal 3137 zcmeAS@N?(olHy`uVBq!ia0y~yUMqUO3p2Hh<{Qv*v--V?d4)YfH8UwYA zg3%Bd4S~@R7!85Z5E$7ZAis1iSN~ffL0~9svk(H32@SxC_5cGj149EN8<5Y;10>i$ z^(>D8kdR0K5(WoQSj1>S(@a1MHv4dE!RbV7S_t?GO$#vrfzX0r5n~HD6p7Y?2zUZo pM#F9xB-J69?!XC@KG|Gs*O8|z*CLZNe1PQ;gQu&X%Q~loCIDMsnQQ<6 literal 0 HcmV?d00001 diff --git a/module/guild/operations.py b/module/guild/operations.py index 2660ae80b..27e6d1e3b 100644 --- a/module/guild/operations.py +++ b/module/guild/operations.py @@ -14,6 +14,7 @@ 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): @@ -63,6 +64,31 @@ class GuildOperations(GuildBase): logger.warning('Operations interface is unrecognized') return None + def _guild_operations_red_dot_present(self): + """ + Helper function to perform an isolated scan + for the lower bottom left sidebar whether + a red dot is present. + The red dot could either be Tech + or Operations (Guild Master vs Member). + + Pages: + in: GUILD_ANY + out: GUILD_ANY + """ + # Apply mask to cover potential RED_DOTs that are operations or + # anywhere else for that matter + image = MASK_SIDEBAR_RED_DOT.apply(np.array(self.device.image)) + + # Scan image and must have similarity greater than 0.85 + sim, point = TEMPLATE_OPERATIONS_RED_DOT.match_result(image) + if sim < 0.85: + return False + + # Unsure whether this red dot is from the Tech or Operations + # sidebar. But for safety will check Operations anyway + return True + def _guild_operations_enter_ensure(self): """ Specific helper to ensure operation has @@ -323,12 +349,12 @@ class GuildOperations(GuildBase): return elif operations_mode == 1: # Limit check for scanning operations to 4 times a day i.e. 6-hour intervals, 4th time reduced to 3-hour - if not self.config.record_executed_since(option=RECORD_OPTION_DISPATCH, since=RECORD_SINCE_DISPATCH): + if not self.config.record_executed_since(option=RECORD_OPTION_DISPATCH, since=RECORD_SINCE_DISPATCH) or self._guild_operations_red_dot_present(): self._guild_operations_scan() self.config.record_save(option=RECORD_OPTION_DISPATCH) else: # Limit check for Guild Raid Boss to once a day - if not self.config.record_executed_since(option=RECORD_OPTION_BOSS, since=RECORD_SINCE_BOSS): + if not self.config.record_executed_since(option=RECORD_OPTION_BOSS, since=RECORD_SINCE_BOSS) or self._guild_operations_red_dot_present(): skip_record = False if self.appear(GUILD_BOSS_AVAILABLE): if self.config.ENABLE_GUILD_OPERATIONS_BOSS_AUTO: