diff --git a/alas.py b/alas.py index 6268c638a..58ff6809a 100644 --- a/alas.py +++ b/alas.py @@ -407,6 +407,10 @@ class AzurLaneAutoScript: GemsFarming(config=self.config, device=self.device).run( name=self.config.Campaign_Name, folder=self.config.Campaign_Event, mode=self.config.Campaign_Mode) + def island_freebie(self): + from module.island.freebie import IslandFreebie + IslandFreebie(config=self.config, device=self.device).run() + def daemon(self): from module.daemon.daemon import AzurLaneDaemon AzurLaneDaemon(config=self.config, device=self.device, task="Daemon").run() diff --git a/assets/cn/island/ISLAND_FREEBIE_AVAILABLE.BUTTON.png b/assets/cn/island/ISLAND_FREEBIE_AVAILABLE.BUTTON.png new file mode 100644 index 000000000..2b3e6e474 Binary files /dev/null and b/assets/cn/island/ISLAND_FREEBIE_AVAILABLE.BUTTON.png differ diff --git a/assets/cn/island/ISLAND_FREEBIE_AVAILABLE.gif b/assets/cn/island/ISLAND_FREEBIE_AVAILABLE.gif new file mode 100644 index 000000000..ad1140c35 Binary files /dev/null and b/assets/cn/island/ISLAND_FREEBIE_AVAILABLE.gif differ diff --git a/assets/cn/island/ISLAND_FREEBIE_CLAIM.png b/assets/cn/island/ISLAND_FREEBIE_CLAIM.png new file mode 100644 index 000000000..ca6024822 Binary files /dev/null and b/assets/cn/island/ISLAND_FREEBIE_CLAIM.png differ diff --git a/assets/cn/island/ISLAND_FREEBIE_COOLDOWN.png b/assets/cn/island/ISLAND_FREEBIE_COOLDOWN.png new file mode 100644 index 000000000..98a72a700 Binary files /dev/null and b/assets/cn/island/ISLAND_FREEBIE_COOLDOWN.png differ diff --git a/assets/cn/island/ISLAND_FREEBIE_RECEIVE.png b/assets/cn/island/ISLAND_FREEBIE_RECEIVE.png new file mode 100644 index 000000000..02d90f710 Binary files /dev/null and b/assets/cn/island/ISLAND_FREEBIE_RECEIVE.png differ diff --git a/assets/cn/island/ISLAND_FREEBIE_SHARE.png b/assets/cn/island/ISLAND_FREEBIE_SHARE.png new file mode 100644 index 000000000..bfd6d2d90 Binary files /dev/null and b/assets/cn/island/ISLAND_FREEBIE_SHARE.png differ diff --git a/assets/cn/island/ISLAND_FREEBIE_SHARE_ALL.png b/assets/cn/island/ISLAND_FREEBIE_SHARE_ALL.png new file mode 100644 index 000000000..a30ebc666 Binary files /dev/null and b/assets/cn/island/ISLAND_FREEBIE_SHARE_ALL.png differ diff --git a/assets/cn/island/ISLAND_FREEBIE_SHARE_BACK.png b/assets/cn/island/ISLAND_FREEBIE_SHARE_BACK.png new file mode 100644 index 000000000..c2ce172ed Binary files /dev/null and b/assets/cn/island/ISLAND_FREEBIE_SHARE_BACK.png differ diff --git a/assets/cn/island/ISLAND_FREEBIE_UNAVAILABLE.png b/assets/cn/island/ISLAND_FREEBIE_UNAVAILABLE.png new file mode 100644 index 000000000..19dc4c70c Binary files /dev/null and b/assets/cn/island/ISLAND_FREEBIE_UNAVAILABLE.png differ diff --git a/assets/jp/island/ISLAND_FREEBIE_CLAIM.png b/assets/jp/island/ISLAND_FREEBIE_CLAIM.png new file mode 100644 index 000000000..5341bf7b1 Binary files /dev/null and b/assets/jp/island/ISLAND_FREEBIE_CLAIM.png differ diff --git a/assets/jp/island/ISLAND_FREEBIE_COOLDOWN.png b/assets/jp/island/ISLAND_FREEBIE_COOLDOWN.png new file mode 100644 index 000000000..2a2a2ec0e Binary files /dev/null and b/assets/jp/island/ISLAND_FREEBIE_COOLDOWN.png differ diff --git a/assets/jp/island/ISLAND_FREEBIE_RECEIVE.png b/assets/jp/island/ISLAND_FREEBIE_RECEIVE.png new file mode 100644 index 000000000..c2e58c15e Binary files /dev/null and b/assets/jp/island/ISLAND_FREEBIE_RECEIVE.png differ diff --git a/assets/jp/island/ISLAND_FREEBIE_SHARE.png b/assets/jp/island/ISLAND_FREEBIE_SHARE.png new file mode 100644 index 000000000..9a25ed8ce Binary files /dev/null and b/assets/jp/island/ISLAND_FREEBIE_SHARE.png differ diff --git a/assets/jp/island/ISLAND_FREEBIE_SHARE_ALL.png b/assets/jp/island/ISLAND_FREEBIE_SHARE_ALL.png new file mode 100644 index 000000000..f5282da4b Binary files /dev/null and b/assets/jp/island/ISLAND_FREEBIE_SHARE_ALL.png differ diff --git a/config/template.json b/config/template.json index cc3ae3536..39182a80e 100644 --- a/config/template.json +++ b/config/template.json @@ -1916,6 +1916,22 @@ "Storage": {} } }, + "IslandFreebie": { + "Scheduler": { + "Enable": false, + "NextRun": "2020-01-01 00:00:00", + "Command": "IslandFreebie", + "SuccessInterval": 0, + "FailureInterval": 120, + "ServerUpdate": "00:00" + }, + "IslandFreebie": { + "Share": true + }, + "Storage": { + "Storage": {} + } + }, "Daemon": { "Daemon": { "EnterMap": true diff --git a/module/config/argument/args.json b/module/config/argument/args.json index 0c46c9dd7..6168d5d7a 100644 --- a/module/config/argument/args.json +++ b/module/config/argument/args.json @@ -9319,6 +9319,57 @@ } } }, + "IslandFreebie": { + "Scheduler": { + "Enable": { + "type": "checkbox", + "value": false, + "option": [ + true, + false + ] + }, + "NextRun": { + "type": "datetime", + "value": "2020-01-01 00:00:00", + "validate": "datetime" + }, + "Command": { + "type": "input", + "value": "IslandFreebie", + "display": "hide" + }, + "SuccessInterval": { + "type": "input", + "value": 0, + "display": "hide" + }, + "FailureInterval": { + "type": "input", + "value": 120, + "display": "hide" + }, + "ServerUpdate": { + "type": "input", + "value": "00:00", + "display": "hide" + } + }, + "IslandFreebie": { + "Share": { + "type": "checkbox", + "value": true + } + }, + "Storage": { + "Storage": { + "type": "storage", + "value": {}, + "valuetype": "ignore", + "display": "disabled" + } + } + }, "Daemon": { "Daemon": { "EnterMap": { diff --git a/module/config/argument/argument.yaml b/module/config/argument/argument.yaml index e7ee8c6d9..1bd428aeb 100644 --- a/module/config/argument/argument.yaml +++ b/module/config/argument/argument.yaml @@ -745,6 +745,10 @@ OpsiHazard1Leveling: value: 0 option: [ 0, 44, 22 ] +# =================== Island ==================== +IslandFreebie: + Share: true + # ==================== Tools ==================== Daemon: diff --git a/module/config/argument/menu.json b/module/config/argument/menu.json index a745ee04e..e897df8d0 100644 --- a/module/config/argument/menu.json +++ b/module/config/argument/menu.json @@ -95,6 +95,13 @@ "OpsiCrossMonth" ] }, + "Island": { + "menu": "collapse", + "page": "setting", + "tasks": [ + "IslandFreebie" + ] + }, "Tool": { "menu": "collapse", "page": "tool", diff --git a/module/config/argument/task.yaml b/module/config/argument/task.yaml index 9fb52b375..c33309852 100644 --- a/module/config/argument/task.yaml +++ b/module/config/argument/task.yaml @@ -325,6 +325,15 @@ Opsi: OpsiCrossMonth: - Scheduler +# =================== Island =================== +Island: + menu: 'collapse' + page: 'setting' + tasks: + IslandFreebie: + - Scheduler + - IslandFreebie + # ==================== Tool ==================== Tool: diff --git a/module/config/config_generated.py b/module/config/config_generated.py index 101dc0b1f..67a9dba8b 100644 --- a/module/config/config_generated.py +++ b/module/config/config_generated.py @@ -439,6 +439,9 @@ class GeneratedConfig: # Group `OpsiHazard1Leveling` OpsiHazard1Leveling_TargetZone = 0 # 0, 44, 22 + # Group `IslandFreebie` + IslandFreebie_Share = True + # Group `Daemon` Daemon_EnterMap = True diff --git a/module/config/config_manual.py b/module/config/config_manual.py index b9f10fce2..7be78dc78 100644 --- a/module/config/config_manual.py +++ b/module/config/config_manual.py @@ -22,6 +22,7 @@ class ManualConfig: > OpsiAshBeacon > OpsiDaily > OpsiShop > OpsiVoucher > OpsiAbyssal > OpsiStronghold > OpsiObscure > OpsiArchive + > IslandFreebie > Daily > Hard > OpsiAshBeacon > OpsiAshAssist > OpsiMonthBoss > Sos > EventSp > EventA > EventB > EventC > EventD > RaidDaily > CoalitionSp > WarArchives > MaritimeEscort diff --git a/module/config/i18n/en-US.json b/module/config/i18n/en-US.json index f8839029e..08964d989 100644 --- a/module/config/i18n/en-US.json +++ b/module/config/i18n/en-US.json @@ -28,6 +28,10 @@ "name": "OpSi", "help": "" }, + "Island": { + "name": "Island Planner", + "help": "" + }, "Tool": { "name": "Tools", "help": "" @@ -250,6 +254,10 @@ "name": "Cross Month Daily", "help": " ALAS will enter OpSi 10min before OpSi reset, wait until OpSi reset but not exit OpSi. Then do the daily, obscure, abyssal and meowfficer farming to get extra gold plates. When running dailies, settings in task \"OpSiDaily\" are used, the rest function are the same.\n IMPORTANT: Please do not touch the game while ALAS is waiting for OpSi reset." }, + "IslandFreebie": { + "name": "Daily Supplies", + "help": "" + }, "Daemon": { "name": "Normal Semi-auto", "help": "" @@ -2575,6 +2583,16 @@ "22": "22 | NA Ocean SW Sector B" } }, + "IslandFreebie": { + "_info": { + "name": "Daily Supplies", + "help": "" + }, + "Share": { + "name": "Share Supplies with Friends", + "help": "" + } + }, "Daemon": { "_info": { "name": "Semi-auto Clicking", diff --git a/module/config/i18n/ja-JP.json b/module/config/i18n/ja-JP.json index c29abc74d..2f95f14a9 100644 --- a/module/config/i18n/ja-JP.json +++ b/module/config/i18n/ja-JP.json @@ -28,6 +28,10 @@ "name": "セイレーン作戦", "help": "" }, + "Island": { + "name": "離島開発", + "help": "" + }, "Tool": { "name": "ツール", "help": "" @@ -250,6 +254,10 @@ "name": "Cross Month Daily", "help": " ALAS will enter OpSi 10min before OpSi reset, wait until OpSi reset but not exit OpSi. Then do the daily, obscure, abyssal and meowfficer farming to get extra gold plates. When running dailies, settings in task \"OpSiDaily\" are used, the rest function are the same.\n IMPORTANT: Please do not touch the game while ALAS is waiting for OpSi reset." }, + "IslandFreebie": { + "name": "デイリー補給", + "help": "" + }, "Daemon": { "name": "半自動クリック", "help": "" @@ -2575,6 +2583,16 @@ "22": "22" } }, + "IslandFreebie": { + "_info": { + "name": "デイリー補給", + "help": "" + }, + "Share": { + "name": "補給を友達とシェアする", + "help": "" + } + }, "Daemon": { "_info": { "name": "Daemon._info.name", diff --git a/module/config/i18n/zh-CN.json b/module/config/i18n/zh-CN.json index 9ce8b48eb..61ac285ed 100644 --- a/module/config/i18n/zh-CN.json +++ b/module/config/i18n/zh-CN.json @@ -28,6 +28,10 @@ "name": "大世界", "help": "" }, + "Island": { + "name": "岛屿计划", + "help": "" + }, "Tool": { "name": "工具", "help": "" @@ -250,6 +254,10 @@ "name": "跨月每日", "help": " Alas将在大世界跨月重置之前10分钟进入大世界,等待大世界重置但不退出大世界,然后完成新一天的大世界每日、隐秘海域、深渊海域和短猫相接,以获得额外的金菜。运行大世界每日时,按\"大世界每日\"任务设置运行,其余同理。\n 重要:Alas等待跨月期间,请不要操作游戏。" }, + "IslandFreebie": { + "name": "每日补给", + "help": "" + }, "Daemon": { "name": "半自动点击", "help": "" @@ -2575,6 +2583,16 @@ "22": "22 | NA海域西南B" } }, + "IslandFreebie": { + "_info": { + "name": "每日补给", + "help": "" + }, + "Share": { + "name": "将补给分享给好友", + "help": "" + } + }, "Daemon": { "_info": { "name": "半自动点击", diff --git a/module/config/i18n/zh-TW.json b/module/config/i18n/zh-TW.json index 9ca1b9820..331017339 100644 --- a/module/config/i18n/zh-TW.json +++ b/module/config/i18n/zh-TW.json @@ -28,6 +28,10 @@ "name": "大世界", "help": "" }, + "Island": { + "name": "離島計劃", + "help": "Menu.Island.help" + }, "Tool": { "name": "工具", "help": "" @@ -250,6 +254,10 @@ "name": "跨月每日", "help": " Alas將在大世界跨月重置之前10分鐘進入大世界,等待大世界重置但不退出大世界,然後完成新一天的大世界每日、隱秘海域、深淵海域和短貓相接,以獲得額外的金菜。運行大世界每日時,按\"大世界每日\"任務設定運行,其餘同理。\n 重要:Alas等待跨月期間,請不要操作遊戲。" }, + "IslandFreebie": { + "name": "每日補給", + "help": "" + }, "Daemon": { "name": "半自動點擊", "help": "" @@ -2575,6 +2583,16 @@ "22": "22 | NA海域西南B" } }, + "IslandFreebie": { + "_info": { + "name": "每日補給", + "help": "" + }, + "Share": { + "name": "將補給分享給好友", + "help": "" + } + }, "Daemon": { "_info": { "name": "半自動點擊", diff --git a/module/island/assets.py b/module/island/assets.py index e8d88c222..88d7c25f6 100644 --- a/module/island/assets.py +++ b/module/island/assets.py @@ -5,4 +5,12 @@ from module.base.template import Template # Don't modify it manually. ISLAND_CLICK_SAFE_AREA = Button(area={'cn': (596, 687, 680, 720), 'en': (596, 687, 680, 720), 'jp': (596, 687, 680, 720), 'tw': (596, 687, 680, 720)}, color={'cn': (255, 255, 255), 'en': (255, 255, 255), 'jp': (255, 255, 255), 'tw': (255, 255, 255)}, button={'cn': (596, 687, 680, 720), 'en': (596, 687, 680, 720), 'jp': (596, 687, 680, 720), 'tw': (596, 687, 680, 720)}, file={'cn': './assets/cn/island/ISLAND_CLICK_SAFE_AREA.png', 'en': './assets/cn/island/ISLAND_CLICK_SAFE_AREA.png', 'jp': './assets/cn/island/ISLAND_CLICK_SAFE_AREA.png', 'tw': './assets/cn/island/ISLAND_CLICK_SAFE_AREA.png'}) +ISLAND_FREEBIE_AVAILABLE = Button(area={'cn': (23, 608, 102, 688), 'en': (23, 608, 102, 688), 'jp': (23, 608, 102, 688), 'tw': (23, 608, 102, 688)}, color={'cn': (129, 124, 97), 'en': (129, 124, 97), 'jp': (129, 124, 97), 'tw': (129, 124, 97)}, button={'cn': (37, 622, 87, 672), 'en': (37, 622, 87, 672), 'jp': (37, 622, 87, 672), 'tw': (37, 622, 87, 672)}, file={'cn': './assets/cn/island/ISLAND_FREEBIE_AVAILABLE.gif', 'en': './assets/cn/island/ISLAND_FREEBIE_AVAILABLE.gif', 'jp': './assets/cn/island/ISLAND_FREEBIE_AVAILABLE.gif', 'tw': './assets/cn/island/ISLAND_FREEBIE_AVAILABLE.gif'}) +ISLAND_FREEBIE_CLAIM = Button(area={'cn': (894, 381, 980, 406), 'en': (894, 381, 980, 406), 'jp': (890, 381, 984, 405), 'tw': (894, 381, 980, 406)}, color={'cn': (211, 211, 209), 'en': (211, 211, 209), 'jp': (194, 195, 196), 'tw': (211, 211, 209)}, button={'cn': (894, 381, 980, 406), 'en': (894, 381, 980, 406), 'jp': (890, 381, 984, 405), 'tw': (894, 381, 980, 406)}, file={'cn': './assets/cn/island/ISLAND_FREEBIE_CLAIM.png', 'en': './assets/cn/island/ISLAND_FREEBIE_CLAIM.png', 'jp': './assets/jp/island/ISLAND_FREEBIE_CLAIM.png', 'tw': './assets/cn/island/ISLAND_FREEBIE_CLAIM.png'}) +ISLAND_FREEBIE_COOLDOWN = Button(area={'cn': (871, 381, 1001, 406), 'en': (871, 381, 1001, 406), 'jp': (870, 380, 1003, 406), 'tw': (871, 381, 1001, 406)}, color={'cn': (215, 214, 213), 'en': (215, 214, 213), 'jp': (200, 202, 201), 'tw': (215, 214, 213)}, button={'cn': (871, 381, 1001, 406), 'en': (871, 381, 1001, 406), 'jp': (870, 380, 1003, 406), 'tw': (871, 381, 1001, 406)}, file={'cn': './assets/cn/island/ISLAND_FREEBIE_COOLDOWN.png', 'en': './assets/cn/island/ISLAND_FREEBIE_COOLDOWN.png', 'jp': './assets/jp/island/ISLAND_FREEBIE_COOLDOWN.png', 'tw': './assets/cn/island/ISLAND_FREEBIE_COOLDOWN.png'}) +ISLAND_FREEBIE_RECEIVE = Button(area={'cn': (893, 380, 980, 406), 'en': (893, 380, 980, 406), 'jp': (859, 380, 1012, 406), 'tw': (893, 380, 980, 406)}, color={'cn': (208, 207, 206), 'en': (208, 207, 206), 'jp': (205, 207, 206), 'tw': (208, 207, 206)}, button={'cn': (893, 380, 980, 406), 'en': (893, 380, 980, 406), 'jp': (859, 380, 1012, 406), 'tw': (893, 380, 980, 406)}, file={'cn': './assets/cn/island/ISLAND_FREEBIE_RECEIVE.png', 'en': './assets/cn/island/ISLAND_FREEBIE_RECEIVE.png', 'jp': './assets/jp/island/ISLAND_FREEBIE_RECEIVE.png', 'tw': './assets/cn/island/ISLAND_FREEBIE_RECEIVE.png'}) +ISLAND_FREEBIE_SHARE = Button(area={'cn': (871, 381, 1002, 406), 'en': (871, 381, 1002, 406), 'jp': (849, 380, 1024, 406), 'tw': (871, 381, 1002, 406)}, color={'cn': (208, 208, 207), 'en': (208, 208, 207), 'jp': (210, 214, 214), 'tw': (208, 208, 207)}, button={'cn': (871, 381, 1002, 406), 'en': (871, 381, 1002, 406), 'jp': (849, 380, 1024, 406), 'tw': (871, 381, 1002, 406)}, file={'cn': './assets/cn/island/ISLAND_FREEBIE_SHARE.png', 'en': './assets/cn/island/ISLAND_FREEBIE_SHARE.png', 'jp': './assets/jp/island/ISLAND_FREEBIE_SHARE.png', 'tw': './assets/cn/island/ISLAND_FREEBIE_SHARE.png'}) +ISLAND_FREEBIE_SHARE_ALL = Button(area={'cn': (728, 588, 810, 611), 'en': (728, 588, 810, 611), 'jp': (724, 587, 814, 613), 'tw': (728, 588, 810, 611)}, color={'cn': (93, 121, 142), 'en': (93, 121, 142), 'jp': (73, 104, 128), 'tw': (93, 121, 142)}, button={'cn': (728, 588, 810, 611), 'en': (728, 588, 810, 611), 'jp': (724, 587, 814, 613), 'tw': (728, 588, 810, 611)}, file={'cn': './assets/cn/island/ISLAND_FREEBIE_SHARE_ALL.png', 'en': './assets/cn/island/ISLAND_FREEBIE_SHARE_ALL.png', 'jp': './assets/jp/island/ISLAND_FREEBIE_SHARE_ALL.png', 'tw': './assets/cn/island/ISLAND_FREEBIE_SHARE_ALL.png'}) +ISLAND_FREEBIE_SHARE_BACK = Button(area={'cn': (844, 101, 878, 135), 'en': (844, 101, 878, 135), 'jp': (844, 101, 878, 135), 'tw': (844, 101, 878, 135)}, color={'cn': (170, 213, 232), 'en': (170, 213, 232), 'jp': (170, 213, 232), 'tw': (170, 213, 232)}, button={'cn': (844, 101, 878, 135), 'en': (844, 101, 878, 135), 'jp': (844, 101, 878, 135), 'tw': (844, 101, 878, 135)}, file={'cn': './assets/cn/island/ISLAND_FREEBIE_SHARE_BACK.png', 'en': './assets/cn/island/ISLAND_FREEBIE_SHARE_BACK.png', 'jp': './assets/cn/island/ISLAND_FREEBIE_SHARE_BACK.png', 'tw': './assets/cn/island/ISLAND_FREEBIE_SHARE_BACK.png'}) +ISLAND_FREEBIE_UNAVAILABLE = Button(area={'cn': (36, 631, 88, 683), 'en': (36, 631, 88, 683), 'jp': (36, 631, 88, 683), 'tw': (36, 631, 88, 683)}, color={'cn': (122, 122, 122), 'en': (122, 122, 122), 'jp': (122, 122, 122), 'tw': (122, 122, 122)}, button={'cn': (36, 631, 88, 683), 'en': (36, 631, 88, 683), 'jp': (36, 631, 88, 683), 'tw': (36, 631, 88, 683)}, file={'cn': './assets/cn/island/ISLAND_FREEBIE_UNAVAILABLE.png', 'en': './assets/cn/island/ISLAND_FREEBIE_UNAVAILABLE.png', 'jp': './assets/cn/island/ISLAND_FREEBIE_UNAVAILABLE.png', 'tw': './assets/cn/island/ISLAND_FREEBIE_UNAVAILABLE.png'}) ISLAND_LEVEL_UP = Button(area={'cn': (616, 339, 662, 377), 'en': (616, 339, 662, 377), 'jp': (616, 339, 662, 377), 'tw': (616, 339, 662, 377)}, color={'cn': (186, 213, 226), 'en': (186, 213, 226), 'jp': (186, 213, 226), 'tw': (186, 213, 226)}, button={'cn': (616, 339, 662, 377), 'en': (616, 339, 662, 377), 'jp': (616, 339, 662, 377), 'tw': (616, 339, 662, 377)}, file={'cn': './assets/cn/island/ISLAND_LEVEL_UP.png', 'en': './assets/cn/island/ISLAND_LEVEL_UP.png', 'jp': './assets/cn/island/ISLAND_LEVEL_UP.png', 'tw': './assets/cn/island/ISLAND_LEVEL_UP.png'}) diff --git a/module/island/freebie.py b/module/island/freebie.py new file mode 100644 index 000000000..1d6190677 --- /dev/null +++ b/module/island/freebie.py @@ -0,0 +1,130 @@ +from module.base.timer import Timer +from module.exception import GameStuckError +from module.handler.assets import STORY_SKIP +from module.island.ui import IslandUI +from module.island.assets import * +from module.logger import logger +from module.ui.page import page_island, page_island_manage, page_island_phone + + +class IslandFreebie(IslandUI): + def island_freebie_notice_appear(self): + """ + Returns: + bool: If appear. + + Page: + in: page_island_manage + """ + for _ in self.loop(timeout=5): + if self.match_template_color(ISLAND_FREEBIE_AVAILABLE, offset=(20, 20)): + return True + if self.match_template_color(ISLAND_FREEBIE_UNAVAILABLE, offset=(20, 20)): + return False + return False + + def freebie_move_to(self): + """ + Page: + in: page_island_manage + out: page_island + """ + for _ in self.loop(timeout=30): + if self.appear_then_click(ISLAND_FREEBIE_AVAILABLE, offset=(20, 20), interval=3): + continue + + if self.ui_page_appear(page_island_phone): + logger.info('Moved to location of freebie') + self.ui_goto(page_island) + break + else: + logger.warning('Failed to move to location of freebie after 30 seconds') + raise GameStuckError(f'Failed to move to location of freebie after 30 seconds') + + def freebie_claim(self): + if not self.appear(ISLAND_FREEBIE_CLAIM, offset=(20, 20)): + logger.warning('No freebie claim button') + return False + retry_wait = Timer(3, count=5).reset() + for _ in self.loop(timeout=30): + if self.appear_then_click(ISLAND_FREEBIE_CLAIM, offset=(20, 20), interval=3): + continue + + if self.appear(ISLAND_FREEBIE_COOLDOWN, offset=(20, 20)): + logger.info('Claimed freebie') + return True + elif self.ui_page_appear(page_island_phone): + logger.info('Misclicked into page_island_phone, go back') + self.ui_goto(page_island) + continue + elif retry_wait.reached_and_reset(): + self.device.click(STORY_SKIP) + continue + else: + logger.warning('Failed to claim freebie after 30 seconds') + return False + + def freebie_receive(self): + p1 = (217, 507) + p2 = (217 - 8, 507 + 36) + self.device.drag(p1, p2, point_random=(0, 0, 0, 0), shake_random=(0, 0, 0, 0), hold_duration=1.05) + self.device.screenshot() + if not self.appear(ISLAND_FREEBIE_RECEIVE, offset=(20, 20)): + logger.warning('Failed to receive freebie') + return False + confirm_timer = Timer(3, count=5).reset() + for _ in self.loop(timeout=30, skip_first=False): + if self.appear_then_click(ISLAND_FREEBIE_RECEIVE, offset=(20, 20), interval=3): + confirm_timer.reset() + continue + + if self.handle_island_additional(): + confirm_timer.reset() + continue + + # End + if self.appear(ISLAND_FREEBIE_SHARE, offset=(20, 20)): + if confirm_timer.reached(): + logger.info('Received freebie') + return True + else: + logger.warning('Failed to receive freebie after 30 seconds') + return False + + def freebie_share(self): + if not self.appear(ISLAND_FREEBIE_SHARE, offset=(20, 20)): + logger.warning('No freebie share button') + return False + + for _ in self.loop(timeout=30, skip_first=False): + if self.appear_then_click(ISLAND_FREEBIE_SHARE, offset=(20, 20), interval=3): + continue + if self.appear_then_click(ISLAND_FREEBIE_SHARE_ALL, offset=(20, 20), interval=3): + break + else: + logger.warning('Failed to open freebie share page after 30 seconds') + return False + + for _ in self.loop(timeout=30, skip_first=False): + if self.appear_then_click(ISLAND_FREEBIE_SHARE_BACK, offset=(20, 20), interval=3): + continue + if self.ui_page_appear(page_island): + logger.info('Shared freebie') + return True + else: + logger.warning('Failed to leave freebie share page after 30 seconds') + return False + + def run(self): + self.ui_ensure(page_island_manage) + + if self.island_freebie_notice_appear(): + self.freebie_move_to() + self.freebie_claim() + self.freebie_receive() + if self.config.IslandFreebie_Share: + self.freebie_share() + else: + logger.info('No freebie notice') + + self.config.task_delay(server_update=True)