Fix: Prevent repeated ShipYard runs

This commit is contained in:
LmeSzinc 2023-02-21 21:36:22 +08:00
parent ad5dd520e1
commit 5874e1214c
9 changed files with 73 additions and 10 deletions

View File

@ -1481,12 +1481,14 @@
"ShipyardDr": {
"ResearchSeries": 2,
"ShipIndex": 0,
"BuyAmount": 2
"BuyAmount": 2,
"LastRun": "2020-01-01 00:00:00"
},
"Shipyard": {
"ResearchSeries": 1,
"ShipIndex": 0,
"BuyAmount": 2
"BuyAmount": 2,
"LastRun": "2020-01-01 00:00:00"
},
"Storage": {
"Storage": {}

View File

@ -7625,6 +7625,11 @@
"BuyAmount": {
"type": "input",
"value": 2
},
"LastRun": {
"type": "datetime",
"value": "2020-01-01 00:00:00",
"validate": "datetime"
}
},
"Shipyard": {
@ -7653,6 +7658,11 @@
"BuyAmount": {
"type": "input",
"value": 2
},
"LastRun": {
"type": "datetime",
"value": "2020-01-01 00:00:00",
"validate": "datetime"
}
},
"Storage": {

View File

@ -479,6 +479,7 @@ ShipyardDr:
value: 0
option: [ 0, 1, 2, 3, 4, 5, 6 ]
BuyAmount: 2
LastRun: 2020-01-01 00:00:00
Shipyard:
ResearchSeries:
value: 1
@ -487,6 +488,7 @@ Shipyard:
value: 0
option: [ 0, 1, 2, 3, 4, 5, 6 ]
BuyAmount: 2
LastRun: 2020-01-01 00:00:00
Gacha:
Pool:
value: light

View File

@ -287,11 +287,13 @@ class GeneratedConfig:
ShipyardDr_ResearchSeries = 2 # 2
ShipyardDr_ShipIndex = 0 # 0, 1, 2, 3, 4, 5, 6
ShipyardDr_BuyAmount = 2
ShipyardDr_LastRun = datetime.datetime(2020, 1, 1, 0, 0)
# Group `Shipyard`
Shipyard_ResearchSeries = 1 # 1, 2, 3
Shipyard_ShipIndex = 0 # 0, 1, 2, 3, 4, 5, 6
Shipyard_BuyAmount = 2
Shipyard_LastRun = datetime.datetime(2020, 1, 1, 0, 0)
# Group `Gacha`
Gacha_Pool = 'light' # light, heavy, special, event, wishing_well

View File

@ -1721,6 +1721,10 @@
"BuyAmount": {
"name": "Buy Amount",
"help": "The 1st and 2nd purchase everyday are free\nDiscounts are applied to the 3rd and onwards, gradually minimizing until full price\nExact discounts found at <https://azurlane.koumakan.jp/Research#Strengthening>"
},
"LastRun": {
"name": "Last Purchase Time",
"help": "Because AL does not display how many blueprints have been purchased today, the time of the last purchase is recorded here to prevent the task from running repeatedly. This value is automatically recorded and generally does not need to be modified."
}
},
"Shipyard": {
@ -1749,6 +1753,10 @@
"BuyAmount": {
"name": "Buy Amount",
"help": "The 1st and 2nd purchase everyday are free\nDiscounts are applied to the 3rd and onwards, gradually minimizing until full price\nExact discounts found at <https://azurlane.koumakan.jp/Research#Strengthening>"
},
"LastRun": {
"name": "Last Purchase Time",
"help": "Because AL does not display how many blueprints have been purchased today, the time of the last purchase is recorded here to prevent the task from running repeatedly. This value is automatically recorded and generally does not need to be modified."
}
},
"Gacha": {

View File

@ -1721,6 +1721,10 @@
"BuyAmount": {
"name": "ShipyardDr.BuyAmount.name",
"help": "ShipyardDr.BuyAmount.help"
},
"LastRun": {
"name": "ShipyardDr.LastRun.name",
"help": "ShipyardDr.LastRun.help"
}
},
"Shipyard": {
@ -1749,6 +1753,10 @@
"BuyAmount": {
"name": "Shipyard.BuyAmount.name",
"help": "Shipyard.BuyAmount.help"
},
"LastRun": {
"name": "Shipyard.LastRun.name",
"help": "Shipyard.LastRun.help"
}
},
"Gacha": {

View File

@ -1721,6 +1721,10 @@
"BuyAmount": {
"name": "购买数量",
"help": "每天前两张免费"
},
"LastRun": {
"name": "上一次购买时间",
"help": "因为游戏不显示今天已经购买了几张,所以这里记录上一次购买的时间以防止任务重复运行,这个数值是自动记录的,一般不需要修改"
}
},
"Shipyard": {
@ -1749,6 +1753,10 @@
"BuyAmount": {
"name": "购买数量",
"help": "每天前两张免费"
},
"LastRun": {
"name": "上一次购买时间",
"help": "因为游戏不显示今天已经购买了几张,所以这里记录上一次购买的时间以防止任务重复运行,这个数值是自动记录的,一般不需要修改"
}
},
"Gacha": {

View File

@ -1721,6 +1721,10 @@
"BuyAmount": {
"name": "購買數量",
"help": "每天前兩張免費"
},
"LastRun": {
"name": "上一次購買時間",
"help": "因為遊戲不顯示今天已經購買了幾張,所以這裡記錄上一次購買的時間以防止任務重複運行,這個數值是自動記錄的,一般不需要修改"
}
},
"Shipyard": {
@ -1749,6 +1753,10 @@
"BuyAmount": {
"name": "購買數量",
"help": "每天前兩張免費"
},
"LastRun": {
"name": "上一次購買時間",
"help": "因為遊戲不顯示今天已經購買了幾張,所以這裡記錄上一次購買的時間以防止任務重複運行,這個數值是自動記錄的,一般不需要修改"
}
},
"Gacha": {

View File

@ -1,8 +1,11 @@
from datetime import datetime
from module.exception import ScriptError
from module.logger import logger
from module.shipyard.ui import ShipyardUI
from module.shop.shop_general import GeneralShop
from module.ui.page import page_main, page_shipyard
from module.config.utils import get_server_last_update
PRBP_BUY_PRIZE = {
(1, 2): 0,
@ -200,15 +203,27 @@ class RewardShipyard(ShipyardUI, GeneralShop):
self.config.task_stop()
logger.hr('Shipyard DR', level=1)
self._shipyard_bp_rarity = 'DR'
self.shipyard_run(series=self.config.ShipyardDr_ResearchSeries,
index=self.config.ShipyardDr_ShipIndex,
count=self.config.ShipyardDr_BuyAmount)
logger.attr('ShipyardDr_LastRun', self.config.ShipyardDr_LastRun)
if self.config.ShipyardDr_LastRun > get_server_last_update('04:00'):
logger.warning('Task Shipyard DR has already been run today, skip')
else:
self.config.ShipyardDr_LastRun = datetime.now().replace(microsecond=0)
self._shipyard_bp_rarity = 'DR'
self.shipyard_run(series=self.config.ShipyardDr_ResearchSeries,
index=self.config.ShipyardDr_ShipIndex,
count=self.config.ShipyardDr_BuyAmount)
logger.hr('Shipyard PR', level=1)
self._shipyard_bp_rarity = 'PR'
self.shipyard_run(series=self.config.Shipyard_ResearchSeries,
index=self.config.Shipyard_ShipIndex,
count=self.config.Shipyard_BuyAmount)
logger.attr('Shipyard_LastRun', self.config.Shipyard_LastRun)
if self.config.Shipyard_LastRun > get_server_last_update('04:00'):
logger.warning('Task Shipyard PR has already been run today, stop')
self.config.task_delay(server_update=True)
self.config.task_stop()
else:
self.config.Shipyard_LastRun = datetime.now().replace(microsecond=0)
self._shipyard_bp_rarity = 'PR'
self.shipyard_run(series=self.config.Shipyard_ResearchSeries,
index=self.config.Shipyard_ShipIndex,
count=self.config.Shipyard_BuyAmount)
self.config.task_delay(server_update=True)