Skip to content

Instantly share code, notes, and snippets.

@sekaiwish
Last active July 15, 2021 20:33
Show Gist options
  • Save sekaiwish/4d6160371996001667ac68428e4c41f8 to your computer and use it in GitHub Desktop.
Save sekaiwish/4d6160371996001667ac68428e4c41f8 to your computer and use it in GitHub Desktop.
PSO2NGS Console Storm Tracker
storms = {
-88: 1, -78: 1, 16: 1, 104: 1, 120: 1, 133: 1, 213: 1, 286: 1, 296: 1, 337: 1, 391: 1, 422: 1, 582: 2, 621: 1, 646: 1, 699: 1, 752: 1, 772: 1, 818: 1, 832: 1, 857: 1, 879: 1, 900: 1, 928: 1, 968: 1, 998: 1, 1063: 1, 1143: 1, 1157: 2,
1180: 4, 1222: 1, 1234: 1, 1282: 1, 1347: 2, 1497: 1, 1570: 1, 1595: 2, 1725: 1, 1753: 1, 1761: 1, 1814: 1, 1836: 1, 1864: 1, 1881: 1, 1920: 1, 1945: 1, 1965: 1, 2106: 1, 2114: 1, 2180: 1, 2190: 1, 2266: 1, 2317: 1, 2333: 1, 2350: 1,
2420: 1, 2437: 1, 2493: 1, 2555: 1, 2583: 1, 2658: 1, 2672: 1, 2724: 1, 2734: 1, 2762: 1, 2772: 1, 2790: 1, 2835: 1, 2845: 1, 2855: 2, 2916: 1, 2940: 1, 3013: 1, 3091: 1, 3122: 1, 3140: 1, 3162: 2, 3209: 1, 3255: 1, 3282: 1, 3339: 1,
3369: 3, 3423: 1, 3433: 1, 3488: 1, 3503: 2, 3564: 1, 3573: 1, 3679: 1, 3695: 1, 3711: 1, 3727: 1, 3741: 1, 3791: 1, 3869: 1, 3986: 1, 4009: 1, 4078: 1, 4099: 1, 4117: 3, 4164: 1, 4190: 1, 4236: 1, 4278: 1, 4340: 1, 4369: 1, 4402: 1,
4457: 1, 4539: 1, 4610: 1, 4666: 1, 4841: 1, 4866: 1, 4876: 1, 4996: 1, 5004: 1, 5035: 1, 5066: 1, 5100: 1, 5184: 1, 5197: 2, 5251: 1, 5330: 1, 5425: 1, 5435: 1, 5475: 1, 5488: 1, 5522: 2, 5537: 1, 5575: 1, 5695: 1, 5721: 1, 5771: 1,
5803: 1, 5862: 1, 5942: 1, 6011: 1, 6062: 1, 6096: 1, 6148: 1, 6164: 1, 6189: 1, 6338: 1, 6351: 1, 6414: 1, 6428: 2, 6452: 1, 6499: 1, 6562: 1, 6576: 1, 6743: 1, 6764: 1, 6812: 2, 6886: 1, 6900: 1, 6917: 1, 6932: 1, 6954: 1, 6969: 2,
7007: 1, 7017: 1, 7067: 1, 7080: 1, 7164: 1, 7184: 1, 7230: 2, 7306: 1, 7448: 1, 7500: 1, 7513: 3, 7535: 1, 7551: 1, 7569: 1, 7592: 1, 7625: 1, 7658: 1, 7720: 1, 7730: 1, 7751: 1, 7779: 1, 7831: 1, 7913: 1, 7927: 1, 7952: 1, 7990: 1,
8021: 1, 8044: 1, 8060: 1, 8100: 1, 8181: 1, 8233: 1, 8262: 1, 8328: 1, 8349: 1, 8372: 1, 8405: 1, 8444: 1, 8453: 1, 8580: 1, 8597: 1, 8656: 1, 8726: 1, 8739: 1, 8754: 1, 8860: 1, 8874: 1, 8967: 1, 8982: 1, 9026: 1, 9036: 1, 9088: 1,
9098: 1, 9190: 1, 9335: 1, 9437: 1, 9550: 1, 9657: 1
}
import time, datetime
maint_offset = 1625043600 # a previous maint end timestamp
manual_offset = 0 # in minutes
update_frequency = 60 # in seconds
debug = False
def get_maint_offset():
offset = int(((int(time.time()) - maint_offset) % 604800) / 60)
return offset
def get_timestamp(offset=0):
current_time = datetime.datetime.now() + datetime.timedelta(minutes=offset)
return current_time.strftime('%I:%M%p')
while True:
next_storm = None
for storm in storms.items():
if (storm[0] + manual_offset) < get_maint_offset():
continue
else:
next_storm = storm; break
if next_storm == None:
print('No upcoming storms.'); exit()
while True:
current_offset = get_maint_offset()
storm_delta = (storm[0] + manual_offset) - current_offset
if storm_delta > 3:
print(f'[{get_timestamp()}] Next storm in {storm_delta} minutes ({get_timestamp(storm_delta)}).' + (f'{str(storm):>16}' if debug else ''))
time.sleep(update_frequency)
continue
else:
print(f'[{get_timestamp()}] Storm of length {storm[1]} cycle(s) is beginning soon.')
time.sleep(storm_delta * 60)
print(f'[{get_timestamp()}] Storm has begun.')
time.sleep(storm[1] * 360)
print(f'[{get_timestamp()}] Storm has ended.')
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment