mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-12 06:18:21 +08:00
Add: ensure_time handles string such as '10, 40'
This commit is contained in:
@@ -75,11 +75,11 @@ def random_line_segments(p1, p2, n, random_range=(0, 0, 0, 0)):
|
||||
for index in range(0, n + 1)]
|
||||
|
||||
|
||||
def ensure_time(second, n=5, precision=3):
|
||||
def ensure_time(second, n=3, precision=3):
|
||||
"""Ensure to be time.
|
||||
|
||||
Args:
|
||||
second (int, float, tuple): time.
|
||||
second (int, float, tuple): time, such as 10, (10, 30), '10, 30'
|
||||
n (int): The amount of numbers in simulation. Default to 5.
|
||||
precision (int): Decimals.
|
||||
|
||||
@@ -89,6 +89,10 @@ def ensure_time(second, n=5, precision=3):
|
||||
if isinstance(second, tuple):
|
||||
multiply = 10 ** precision
|
||||
return random_normal_distribution_int(second[0] * multiply, second[1] * multiply, n) / multiply
|
||||
elif isinstance(second, str):
|
||||
lower, upper = second.replace(' ', '').split(',')
|
||||
lower, upper = int(lower), int(upper)
|
||||
return ensure_time((lower, upper), n=n, precision=precision)
|
||||
else:
|
||||
return second
|
||||
|
||||
|
||||
Reference in New Issue
Block a user