Fix bug with nightmares attempting to message/kill dead people

This commit is contained in:
skizzerz 2015-10-31 23:31:59 -05:00
parent ac1bfb778f
commit d8f1a5d946

View File

@ -805,15 +805,17 @@ class SleepyMode(GameMode):
if random.random() < 1/5: if random.random() < 1/5:
self.having_nightmare = True self.having_nightmare = True
with var.WARNING_LOCK: with var.WARNING_LOCK:
t = threading.Timer(60, self.do_nightmare, (cli, random.choice(var.list_players()), var.NIGHT_COUNT)) t = threading.Timer(60, self.do_nightmare, (cli, var, random.choice(var.list_players()), var.NIGHT_COUNT))
t.daemon = True t.daemon = True
t.start() t.start()
else: else:
self.having_nightmare = None self.having_nightmare = None
def do_nightmare(self, cli, target, night): def do_nightmare(self, cli, var, target, night):
if var.PHASE != "night" or var.NIGHT_COUNT != night: if var.PHASE != "night" or var.NIGHT_COUNT != night:
return return
if target not in var.list_players():
return
self.having_nightmare = target self.having_nightmare = target
pm(cli, self.having_nightmare, ("While walking through the woods, you hear the clopping of hooves behind you. Turning around, " + pm(cli, self.having_nightmare, ("While walking through the woods, you hear the clopping of hooves behind you. Turning around, " +
"you see a large black horse with dark red eyes and flames where its mane and tail would be. " + "you see a large black horse with dark red eyes and flames where its mane and tail would be. " +
@ -1029,7 +1031,7 @@ class SleepyMode(GameMode):
def nightmare_kill(self, evt, cli, var): def nightmare_kill(self, evt, cli, var):
# if True, it means night ended before 1 minute # if True, it means night ended before 1 minute
if self.having_nightmare is not None and self.having_nightmare is not True: if self.having_nightmare is not None and self.having_nightmare is not True and self.having_nightmare in var.list_players():
var.DYING.add(self.having_nightmare) var.DYING.add(self.having_nightmare)
pm(cli, self.having_nightmare, ("As the sun starts rising, your legs give out, causing the beast to descend upon you and snuff out your life.")) pm(cli, self.having_nightmare, ("As the sun starts rising, your legs give out, causing the beast to descend upon you and snuff out your life."))