Refactor: Gacha module

This commit is contained in:
LmeSzinc 2021-10-03 00:36:14 +08:00
parent fe46b8ad93
commit 77ace49c2e
13 changed files with 228 additions and 24 deletions

View File

@ -129,6 +129,14 @@ class AzurLaneAutoScript:
from module.shop.shop_reward import RewardShop
RewardShop(config=self.config, device=self.device).run()
def shipyard(self):
from module.shipyard.shipyard_reward import RewardShipyard
RewardShipyard(config=self.config, device=self.device).run()
def gacha(self):
from module.gacha.gacha_reward import RewardGacha
RewardGacha(config=self.config, device=self.device).run()
def daily(self):
from module.daily.daily import Daily
Daily(config=self.config, device=self.device).run()

View File

@ -739,6 +739,21 @@
"BuyAmount": 2
}
},
"Gacha": {
"Scheduler": {
"Enable": false,
"NextRun": "2020-01-01 00:00:00",
"Command": "Gacha",
"SuccessInterval": 30,
"FailureInterval": 30,
"ServerUpdate": "00:00"
},
"Gacha": {
"Pool": "light",
"Amount": 1,
"UseDrill": false
}
},
"Daily": {
"Scheduler": {
"Enable": false,

View File

@ -3281,6 +3281,67 @@
}
}
},
"Gacha": {
"Scheduler": {
"Enable": {
"type": "checkbox",
"value": false
},
"NextRun": {
"type": "input",
"value": "2020-01-01 00:00:00"
},
"Command": {
"type": "disable",
"value": "Gacha"
},
"SuccessInterval": {
"type": "disable",
"value": 30
},
"FailureInterval": {
"type": "disable",
"value": 30
},
"ServerUpdate": {
"type": "disable",
"value": "00:00"
}
},
"Gacha": {
"Pool": {
"type": "select",
"value": "light",
"option": [
"light",
"heavy",
"special",
"event",
"wishing_well"
]
},
"Amount": {
"type": "select",
"value": 1,
"option": [
1,
2,
3,
4,
5,
6,
7,
8,
9,
10
]
},
"UseDrill": {
"type": "checkbox",
"value": false
}
}
},
"Daily": {
"Scheduler": {
"Enable": {

View File

@ -300,6 +300,14 @@ Shipyard:
ResearchSeries: 1
ShipIndex: 0
BuyAmount: 2
Gacha:
Pool:
value: light
option: [light, heavy, special, event, wishing_well]
Amount:
value: 1
option: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
UseDrill: false
# ==================== Daily ====================

View File

@ -24,7 +24,8 @@
"Guild",
"Reward",
"Shop",
"Shipyard"
"Shipyard",
"Gacha"
],
"Daily": [
"Daily",

View File

@ -143,6 +143,11 @@ Shipyard:
SuccessInterval: 30
FailureInterval: 30
ServerUpdate: 04:00
Gacha:
Scheduler:
SuccessInterval: 30
FailureInterval: 30
ServerUpdate: 00:00
# ==================== Daily ====================

View File

@ -116,6 +116,9 @@ Shop:
Shipyard:
- Scheduler
- Shipyard
Gacha:
- Scheduler
- Gacha
# ==================== Daily ====================

View File

@ -210,6 +210,11 @@ class GeneratedConfig:
Shipyard_ShipIndex = 0
Shipyard_BuyAmount = 2
# Group `Gacha`
Gacha_Pool = 'light' # light, heavy, special, event, wishing_well
Gacha_Amount = 1 # 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
Gacha_UseDrill = False
# Group `Daily`
Daily_UseDailySkip = True
Daily_EscortMission = 'first' # skip, first, second, third

View File

@ -106,6 +106,10 @@
"name": "Task.Shipyard.name",
"help": "Task.Shipyard.help"
},
"Gacha": {
"name": "Task.Gacha.name",
"help": "Task.Gacha.help"
},
"Daily": {
"name": "Task.Daily.name",
"help": "Task.Daily.help"
@ -1086,6 +1090,39 @@
"help": "Shipyard.BuyAmount.help"
}
},
"Gacha": {
"_info": {
"name": "Gacha._info.name",
"help": "Gacha._info.help"
},
"Pool": {
"name": "Gacha.Pool.name",
"help": "Gacha.Pool.help",
"light": "light",
"heavy": "heavy",
"special": "special",
"event": "event",
"wishing_well": "wishing_well"
},
"Amount": {
"name": "Gacha.Amount.name",
"help": "Gacha.Amount.help",
"1": "1",
"2": "2",
"3": "3",
"4": "4",
"5": "5",
"6": "6",
"7": "7",
"8": "8",
"9": "9",
"10": "10"
},
"UseDrill": {
"name": "Gacha.UseDrill.name",
"help": "Gacha.UseDrill.help"
}
},
"Daily": {
"_info": {
"name": "Daily._info.name",

View File

@ -106,6 +106,10 @@
"name": "Task.Shipyard.name",
"help": "Task.Shipyard.help"
},
"Gacha": {
"name": "Task.Gacha.name",
"help": "Task.Gacha.help"
},
"Daily": {
"name": "Task.Daily.name",
"help": "Task.Daily.help"
@ -1086,6 +1090,39 @@
"help": "Shipyard.BuyAmount.help"
}
},
"Gacha": {
"_info": {
"name": "Gacha._info.name",
"help": "Gacha._info.help"
},
"Pool": {
"name": "Gacha.Pool.name",
"help": "Gacha.Pool.help",
"light": "light",
"heavy": "heavy",
"special": "special",
"event": "event",
"wishing_well": "wishing_well"
},
"Amount": {
"name": "Gacha.Amount.name",
"help": "Gacha.Amount.help",
"1": "1",
"2": "2",
"3": "3",
"4": "4",
"5": "5",
"6": "6",
"7": "7",
"8": "8",
"9": "9",
"10": "10"
},
"UseDrill": {
"name": "Gacha.UseDrill.name",
"help": "Gacha.UseDrill.help"
}
},
"Daily": {
"_info": {
"name": "Daily._info.name",

View File

@ -106,6 +106,10 @@
"name": "Task.Shipyard.name",
"help": "Task.Shipyard.help"
},
"Gacha": {
"name": "Task.Gacha.name",
"help": "Task.Gacha.help"
},
"Daily": {
"name": "Task.Daily.name",
"help": "Task.Daily.help"
@ -1086,6 +1090,39 @@
"help": "Shipyard.BuyAmount.help"
}
},
"Gacha": {
"_info": {
"name": "Gacha._info.name",
"help": "Gacha._info.help"
},
"Pool": {
"name": "Gacha.Pool.name",
"help": "Gacha.Pool.help",
"light": "light",
"heavy": "heavy",
"special": "special",
"event": "event",
"wishing_well": "wishing_well"
},
"Amount": {
"name": "Gacha.Amount.name",
"help": "Gacha.Amount.help",
"1": "1",
"2": "2",
"3": "3",
"4": "4",
"5": "5",
"6": "6",
"7": "7",
"8": "8",
"9": "9",
"10": "10"
},
"UseDrill": {
"name": "Gacha.UseDrill.name",
"help": "Gacha.UseDrill.help"
}
},
"Daily": {
"_info": {
"name": "Daily._info.name",

View File

@ -279,7 +279,7 @@ class RewardGacha(GachaUI, GeneralShop, Retirement):
# Transition to appropriate target construction pool
# Returns appropriate costs for gacha as well
actual_pool = self.gacha_goto_pool(self.config.GACHA_POOL_TARGET)
actual_pool = self.gacha_goto_pool(self.config.Gacha_Pool)
# Determine appropriate cost based on gacha_goto_pool
gold_cost = 600
@ -290,7 +290,7 @@ class RewardGacha(GachaUI, GeneralShop, Retirement):
# Calculate rolls allowed based on
# configurations and resources
buy_count = self.gacha_calculate(self.config.BUY_GACHA_ORDER, gold_cost, cube_cost)
buy_count = self.gacha_calculate(self.config.Gacha_Amount, gold_cost, cube_cost)
# Submit 'buy_count' and execute if capable
# Cannot use handle_popup_confirm, this window
@ -300,28 +300,20 @@ class RewardGacha(GachaUI, GeneralShop, Retirement):
self.gacha_submit()
# If configured to use drill after build
if self.config.DRILL_AFTER_GACHA:
if self.config.Gacha_UseDrill:
self.gacha_flush_queue()
result = True
return result
def handle_gacha(self):
def run(self):
"""
Handle gacha operations if configured to do so.
Returns:
bool: True if called gacha_run otherwise False
Pages:
in: Any page
out: page_build
"""
if self.config.record_executed_since(RECORD_GACHA_OPTION, since=RECORD_GACHA_SINCE):
return False
if self.config.BUY_GACHA_ORDER <= 0:
return False
if self.gacha_run():
self.config.record_save(option=RECORD_GACHA_OPTION)
self.ui_goto_main()
return True
self.gacha_run()
self.config.task_delay(server_update=True)

View File

@ -25,7 +25,6 @@ class GachaUI(UI):
Returns:
bool: Whether expected assets loaded completely
"""
confirm_timer = Timer(1.5, count=3).start()
ensure_timeout = Timer(3, count=6).start()
while 1:
if skip_first_screenshot:
@ -36,11 +35,7 @@ class GachaUI(UI):
# End
results = [self.appear(button) for button in GACHA_LOAD_ENSURE_BUTTONS]
if any(results):
if confirm_timer.reached():
return True
ensure_timeout.reset()
continue
confirm_timer.reset()
break
# Exception
if ensure_timeout.reached():