Skip to content

Commit

Permalink
[Runescape] Add Stryke the Wyrm wilderness event
Browse files Browse the repository at this point in the history
  • Loading branch information
TrustyJAID committed Feb 5, 2024
1 parent 036fd36 commit 7e4c0c1
Showing 1 changed file with 24 additions and 18 deletions.
42 changes: 24 additions & 18 deletions runescape/wilderness.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,48 @@
class WildernessFlashEvents(Enum):
spider_swarm = 0
unnatural_outcrop = 1
demon_stragglers = 2
butterfly_swarm = 3
king_black_dragon_rampage = 4
forgotten_soldiers = 5
surprising_seedlings = 6
hellhound_pack = 7
infernal_star = 8
lost_souls = 9
ramokee_incursion = 10
displaced_energy = 11
evil_bloodwood_tree = 12
stryke_the_wyrm = 2
demon_stragglers = 3
butterfly_swarm = 4
king_black_dragon_rampage = 5
forgotten_soldiers = 6
surprising_seedlings = 7
hellhound_pack = 8
infernal_star = 9
lost_souls = 10
ramokee_incursion = 11
displaced_energy = 12
evil_bloodwood_tree = 13

def __str__(self):
return self.name.replace("_", " ").title()

def __len__(self):
return len(WildernessFlashEvents)

@property
def special(self):
return self in (
WildernessFlashEvents.stryke_the_wyrm,
WildernessFlashEvents.king_black_dragon_rampage,
WildernessFlashEvents.infernal_star,
WildernessFlashEvents.evil_bloodwood_tree,
)

def get_next(self, today: datetime) -> datetime:
# represents the hours since the first spider swarm
# we add 10 hours because the first spiderswarm in relation to the Runedate
# is 10 hours after
hours_since = int((int((today - RUNEDATE_EPOCH).total_seconds()) / 3600)) + 10
# we add 14 hours because the first spiderswarm in relation to the Runedate
# is 14 hours after
# this offset needs to be adjusted since the addition of the stryke the wyrm event
hours_since = int((int((today - RUNEDATE_EPOCH).total_seconds()) / 3600)) + 14
# the offset mapping how many hours until this even should be next
offset = hours_since % 13
# the number of hours until this event should be nect
offset = hours_since % len(self)
# the number of hours until this event should be next
hour = self.value - offset
# Since the hour can be in the past and we don't care about the past
# we add 13 hours, the total number of events.
# we add the total number of events.
if hour < 0:
hour += 13
hour += len(self)
# add 1 hour because it's off by 1 hour
next_event = today + timedelta(hours=hour + 1)
return next_event

0 comments on commit 7e4c0c1

Please sign in to comment.