|
|
@@ -2,6 +2,7 @@ import json
|
|
|
# from pprint import pprint
|
|
|
import re
|
|
|
|
|
|
+import arrow
|
|
|
from dotenv import load_dotenv
|
|
|
import os
|
|
|
import random
|
|
|
@@ -133,8 +134,29 @@ def extract_hospital_time(this_message_text):
|
|
|
return hours * 60 * 60 + minutes * 60 + seconds
|
|
|
|
|
|
|
|
|
-"""
|
|
|
def calculate_time_to_next_attack(this_player_id):
|
|
|
- pass
|
|
|
- # this_status_json, this_status = _read_json_file(this_player_id)
|
|
|
-"""
|
|
|
+ this_status_json, this_status_integer = _read_json_file(this_player_id)
|
|
|
+ if this_status_json == -1 or this_status_integer == -1:
|
|
|
+ return -1
|
|
|
+ seconds_till_level_iv = 0
|
|
|
+ starting_time = int(this_status_json['timestamp'])
|
|
|
+ if this_status_integer >= 0:
|
|
|
+ status_text = this_status_json['text']
|
|
|
+ seconds_till_level_iv += extract_hospital_time(status_text)
|
|
|
+ if this_status_integer >= 1:
|
|
|
+ seconds_till_level_iv += 30 * 60
|
|
|
+ if this_status_integer >= 2:
|
|
|
+ seconds_till_level_iv += 90 * 60
|
|
|
+ if this_status_integer >= 3:
|
|
|
+ seconds_till_level_iv += 210 * 60
|
|
|
+ if this_status_integer == 4:
|
|
|
+ seconds_till_level_iv = 0
|
|
|
+ apocalypse_time = starting_time + seconds_till_level_iv
|
|
|
+ time_now = arrow.utcnow().timestamp
|
|
|
+ diff = apocalypse_time - time_now
|
|
|
+ print(diff)
|
|
|
+ diff_in_minutes = int(diff//60)
|
|
|
+ print(
|
|
|
+ f'starting time {starting_time}, seconds_till_level_iv {seconds_till_level_iv}, apocalypse_time {apocalypse_time}')
|
|
|
+ return diff, apocalypse_time
|
|
|
+
|