Skip to content

Commit

Permalink
better quest resets
Browse files Browse the repository at this point in the history
  • Loading branch information
ccev committed Dec 11, 2020
1 parent 2d5d312 commit 9b04345
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
10 changes: 3 additions & 7 deletions autoevents.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ def perform_operation(self):

self.__quests_enable = self._pluginconfig.getboolean("Quest Resets", "enable", fallback=False)
self.__quests_default_time = self._pluginconfig.get("Quest Resets", "default_time")
self.__quests_min_length = self._pluginconfig.getint("Quest Resets", "min_event_length")
self.__quests_confidence = self._pluginconfig.getint("Quest Resets", "min_confidence")

max_time = self._pluginconfig.get("Quest Resets", "max_time").split(":")
Expand Down Expand Up @@ -106,25 +105,22 @@ def _update_event(self, event):
self._mad['logger'].success(f"Auto Events: Put {event['name']} in your DB")

def _check_quest_resets(self):
def time_limit(time):
return time.hour > self.__quests_max_hour and time.minute > self.__quests_max_minute
def to_timestring(time):
return time.strftime("%H:%M")
all_quest_resets = requests.get("https://raw.githubusercontent.com/ccev/pogoinfo/info/events/quest_resets.json").json()
self._mad['logger'].success(all_quest_resets)
smallest_time = datetime(2100, 1, 1, 0, 0, 0)
final_time = None

now = datetime.now()
for event in all_quest_resets:
if event["confidence"] < self.__quests_confidence:
continue
if event["length"] < self.__quests_min_length:
continue

time = self._convert_time(event["time"])
if time < now:
continue
if time_limit(time):
if time.hour > self.__quests_max_hour and time.minute >= self.__quests_max_minute:
continue

if time < smallest_time:
Expand All @@ -133,7 +129,7 @@ def to_timestring(time):
if smallest_time.year == 2100:
final_time = self.__quests_default_time
else:
if (smallest_time.date() == datetime.today().date()) or (smallest_time.date() == (datetime.today() + timedelta(days=1)).date()):
if smallest_time.date() == (datetime.today() + timedelta(days=1)).date():
final_time = to_timestring(smallest_time)
else:
final_time = self.__quests_default_time
Expand Down
3 changes: 1 addition & 2 deletions plugin.ini.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ delete_events = false
enable = true
default_time = 02:00
max_time = 12:00
min_event_length = 24
min_confidence = 9
min_confidence = 9
2 changes: 1 addition & 1 deletion version.mpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ pluginname = EventWatcher
description = Automatically put Events that boost Spawns in your database
author = ccev
url = https://github.com/ccev/mp-eventwatcher
version = 2.0.1
version = 2.1.0

0 comments on commit 9b04345

Please sign in to comment.