Skip to content

Commit

Permalink
feat(#293): Added context
Browse files Browse the repository at this point in the history
  • Loading branch information
lxgr-linux committed Jul 16, 2024
1 parent 9f2ab84 commit e8bfee8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
6 changes: 6 additions & 0 deletions pokete_classes/game/periodic_event_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ def __init__(self, events: list[PeriodicEvent]):
self.events = events
self.tick = 0

def with_events(
self,
events: list[PeriodicEvent]
) -> "PeriodicEventManager":
return PeriodicEventManager(self.events + events)

def event(self):
"""Executes the events"""
for event in self.events:
Expand Down
25 changes: 21 additions & 4 deletions pokete_classes/roadmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import pokete_data as p_data
import pokete_classes.ob_maps as obmp
from pokete_classes.game import PeriodicEvent, PeriodicEventManager
from util import liner
from .input import ACTION_DIRECTIONS, Action, ActionList, get_action
from .color import Color
Expand Down Expand Up @@ -179,7 +180,8 @@ def rechar_info(self, name):
self.info_label.rechar(name)
self.box.add_ob(self.info_label, self.box.width - 2 - len(name), 0)

def __call__(self, _map: se.Submap, pevm, choose=False):
def __call__(self, _map: se.Submap, pevm: PeriodicEventManager,
choose=False):
"""Shows the roadmap
ARGS:
_map: se.Map this is shown on
Expand All @@ -197,7 +199,6 @@ def __call__(self, _map: se.Submap, pevm, choose=False):
)
in i.associates
][0].choose()
blinker = Blinker()
with self.box.center_add(_map):
while True:
action = get_action()
Expand Down Expand Up @@ -237,8 +238,10 @@ def __call__(self, _map: se.Submap, pevm, choose=False):
overview=self.box,
) as box:
loops.easy_exit(box=box)
loops.std(box=self.box, pevm=pevm)
blinker(self.sta)
loops.std(
box=self.box,
pevm=pevm.with_events([BlinkerEvent(self.sta)])
)
_map.full_show()
self.sta.unchoose()

Expand Down Expand Up @@ -268,5 +271,19 @@ def __call__(self, station: Station):
self.idx = 0


class BlinkerEvent(PeriodicEvent):
def __init__(self, station: Station):
self.station = station
self.blink = False

def tick(self, tick: int):
if tick % 10 == 0:
if self.blink:
self.station.blink()
else:
self.station.un_blink()
self.blink = not self.blink


if __name__ == "__main__":
print("\033[31;1mDo not execute this!\033[0m")

0 comments on commit e8bfee8

Please sign in to comment.