Fix circular imports

This commit is contained in:
Vgr E. Barry 2015-10-30 17:38:39 -04:00
parent e860eeabdd
commit 2cf3852518
3 changed files with 8 additions and 4 deletions

View File

@ -9,7 +9,6 @@ from src.utilities import *
import botconfig import botconfig
from src import events from src import events
from src import decorators
def game_mode(name, minp, maxp, likelihood = 0): def game_mode(name, minp, maxp, likelihood = 0):
def decor(c): def decor(c):
@ -766,6 +765,7 @@ class SleepyMode(GameMode):
self.having_nightmare = None self.having_nightmare = None
def startup(self): def startup(self):
from src import decorators
events.add_listener("dullahan_targets", self.dullahan_targets) events.add_listener("dullahan_targets", self.dullahan_targets)
events.add_listener("transition_night_begin", self.setup_nightmares) events.add_listener("transition_night_begin", self.setup_nightmares)
events.add_listener("chk_nightdone", self.prolong_night) events.add_listener("chk_nightdone", self.prolong_night)
@ -777,6 +777,7 @@ class SleepyMode(GameMode):
self.west_cmd = decorators.cmd("west", "w", chan=False, pm=True, playing=True, phases=("night",))(self.west) self.west_cmd = decorators.cmd("west", "w", chan=False, pm=True, playing=True, phases=("night",))(self.west)
def teardown(self): def teardown(self):
from src import decorators
events.remove_listener("dullahan_targets", self.dullahan_targets) events.remove_listener("dullahan_targets", self.dullahan_targets)
events.remove_listener("transition_night_begin", self.setup_nightmares) events.remove_listener("transition_night_begin", self.setup_nightmares)
events.remove_listener("chk_nightdone", self.prolong_night) events.remove_listener("chk_nightdone", self.prolong_night)

View File

@ -2,8 +2,6 @@ import src.settings as var
import botconfig import botconfig
import re import re
from src.__init__ import debuglog
# Some miscellaneous helper functions # Some miscellaneous helper functions
def mass_mode(cli, md_param, md_plain): def mass_mode(cli, md_param, md_plain):

View File

@ -44,7 +44,10 @@ from oyoyo.parse import parse_nick
import botconfig import botconfig
import src.settings as var import src.settings as var
from src.utilities import * from src.utilities import *
from src import decorators, events, logger, debuglog from src import decorators, events, logger, utilities, debuglog
# make debuglog accessible anywhere
utilities.debuglog = debuglog
# done this way so that events is accessible in !eval (useful for debugging) # done this way so that events is accessible in !eval (useful for debugging)
Event = events.Event Event = events.Event
@ -4856,6 +4859,8 @@ def chk_nightdone(cli):
if var.PHASE == "night": # Double check if var.PHASE == "night": # Double check
transition_day(cli) transition_day(cli)
utilities.chk_nightdone = chk_nightdone # for some events to access
@cmd("nolynch", "nl", "novote", "nv", "abstain", "abs", playing=True, phases=("day",)) @cmd("nolynch", "nl", "novote", "nv", "abstain", "abs", playing=True, phases=("day",))
def no_lynch(cli, nick, chan, rest): def no_lynch(cli, nick, chan, rest):
"""Allows you to abstain from voting for the day.""" """Allows you to abstain from voting for the day."""