Fix get_victim not caring about channel vs PM commands

Why do I keep trying to code while short on sleep. It's obviously a
failure.
This commit is contained in:
Vgr E.Barry 2015-03-21 22:14:19 -04:00
parent 667b7513d3
commit eb724bb3fc

View File

@ -267,8 +267,11 @@ def complete_match(string, matches):
return bestmatch, 1 return bestmatch, 1
#wrapper around complete_match() used for roles #wrapper around complete_match() used for roles
def get_victim(cli, nick, victim, self_in_list = False): def get_victim(cli, nick, victim, in_chan, self_in_list = False):
if not victim: if not victim:
if in_chan:
cli.notice(nick, "Not enough parameters.")
else:
pm(cli, nick, "Not enough parameters") pm(cli, nick, "Not enough parameters")
return return
pl = [x for x in var.list_players() if x != nick or self_in_list] pl = [x for x in var.list_players() if x != nick or self_in_list]
@ -279,6 +282,9 @@ def get_victim(cli, nick, victim, self_in_list = False):
#ensure messages about not being able to act on yourself work #ensure messages about not being able to act on yourself work
if num_matches == 0 and nick.lower().startswith(victim.lower()): if num_matches == 0 and nick.lower().startswith(victim.lower()):
return nick return nick
if in_chan:
cli.notice(nick, "\u0002{0}\u0002 is currently not playing.".format(victim))
else:
pm(cli, nick, "\u0002{0}\u0002 is currently not playing.".format(victim)) pm(cli, nick, "\u0002{0}\u0002 is currently not playing.".format(victim))
return return
return pl[pll.index(tempvictim)] #convert back to normal casing return pl[pll.index(tempvictim)] #convert back to normal casing
@ -3809,7 +3815,7 @@ def lynch(cli, nick, chan, rest):
if nick in var.NO_LYNCH: if nick in var.NO_LYNCH:
var.NO_LYNCH.remove(nick) var.NO_LYNCH.remove(nick)
voted = get_victim(cli, nick, rest, var.SELF_LYNCH_ALLOWED) voted = get_victim(cli, nick, rest, True, var.SELF_LYNCH_ALLOWED)
if not voted: if not voted:
return return
@ -4202,7 +4208,7 @@ def shoot(cli, nick, chan, rest):
elif nick in var.SILENCED: elif nick in var.SILENCED:
cli.notice(nick, "You have been silenced, and are unable to use any special powers.") cli.notice(nick, "You have been silenced, and are unable to use any special powers.")
return return
victim = get_victim(cli, nick, re.split(" +",rest)[0]) victim = get_victim(cli, nick, re.split(" +",rest)[0], True)
if not victim: if not victim:
return return
if victim == nick: if victim == nick:
@ -4330,11 +4336,11 @@ def kill(cli, nick, chan, rest):
"you are physically unable to kill a villager.")) "you are physically unable to kill a villager."))
return return
victim = get_victim(cli, nick, victim) victim = get_victim(cli, nick, victim, False)
if not victim: if not victim:
return return
if victim2 != None: if victim2 != None:
victim2 = get_victim(cli, nick, victim2) victim2 = get_victim(cli, nick, victim2, False)
if not victim2: if not victim2:
return return
@ -4415,7 +4421,7 @@ def guard(cli, nick, chan, rest):
pm(cli, nick, "You are already protecting someone tonight.") pm(cli, nick, "You are already protecting someone tonight.")
return return
role = var.get_role(nick) role = var.get_role(nick)
victim = get_victim(cli, nick, re.split(" +",rest)[0], role == "bodyguard" or var.GUARDIAN_ANGEL_CAN_GUARD_SELF) victim = get_victim(cli, nick, re.split(" +",rest)[0], False, role == "bodyguard" or var.GUARDIAN_ANGEL_CAN_GUARD_SELF)
if not victim: if not victim:
return return
@ -4458,7 +4464,7 @@ def observe(cli, nick, chan, rest):
if nick in var.SILENCED: if nick in var.SILENCED:
pm(cli, nick, "You have been silenced, and are unable to use any special powers.") pm(cli, nick, "You have been silenced, and are unable to use any special powers.")
return return
victim = get_victim(cli, nick, re.split(" +",rest)[0]) victim = get_victim(cli, nick, re.split(" +",rest)[0], False)
if not victim: if not victim:
return return
@ -4515,7 +4521,7 @@ def investigate(cli, nick, chan, rest):
if nick in var.INVESTIGATED: if nick in var.INVESTIGATED:
pm(cli, nick, "You may only investigate one person per round.") pm(cli, nick, "You may only investigate one person per round.")
return return
victim = get_victim(cli, nick, re.split(" +",rest)[0]) victim = get_victim(cli, nick, re.split(" +",rest)[0], False)
if not victim: if not victim:
return return
@ -4550,7 +4556,7 @@ def hvisit(cli, nick, chan, rest):
pm(cli, nick, ("You are already spending the night "+ pm(cli, nick, ("You are already spending the night "+
"with \u0002{0}\u0002.").format(var.HVISITED[nick])) "with \u0002{0}\u0002.").format(var.HVISITED[nick]))
return return
victim = get_victim(cli, nick, re.split(" +",rest)[0], True) victim = get_victim(cli, nick, re.split(" +",rest)[0], False, True)
if not victim: if not victim:
return return
@ -4585,7 +4591,7 @@ def see(cli, nick, chan, rest):
if nick in var.SEEN: if nick in var.SEEN:
pm(cli, nick, "You may only have one vision per round.") pm(cli, nick, "You may only have one vision per round.")
return return
victim = get_victim(cli, nick, re.split(" +",rest)[0]) victim = get_victim(cli, nick, re.split(" +",rest)[0], False)
if not victim: if not victim:
return return
@ -4650,7 +4656,7 @@ def totem(cli, nick, chan, rest):
if nick in var.SHAMANS: if nick in var.SHAMANS:
pm(cli, nick, "You have already given out your totem this round.") pm(cli, nick, "You have already given out your totem this round.")
return return
victim = get_victim(cli, nick, re.split(" +",rest)[0], True) victim = get_victim(cli, nick, re.split(" +",rest)[0], False, True)
if not victim: if not victim:
return return
if nick in var.LASTGIVEN and var.LASTGIVEN[nick] == victim: if nick in var.LASTGIVEN and var.LASTGIVEN[nick] == victim:
@ -4728,7 +4734,7 @@ def immunize(cli, nick, chan, rest):
return return
if not nick in var.DOCTORS: # something with amnesiac or clone or exchange totem if not nick in var.DOCTORS: # something with amnesiac or clone or exchange totem
var.DOCTORS[nick] = math.ceil(var.DOCTOR_IMMUNIZATION_MULTIPLIER * len(var.ALL_PLAYERS)) var.DOCTORS[nick] = math.ceil(var.DOCTOR_IMMUNIZATION_MULTIPLIER * len(var.ALL_PLAYERS))
victim = get_victim(cli, nick, re.split(" +",rest)[0], True) victim = get_victim(cli, nick, re.split(" +",rest)[0], False, True)
if not victim: if not victim:
return return
victim = choose_target(nick, victim) victim = choose_target(nick, victim)
@ -4798,7 +4804,7 @@ def bite_cmd(cli, nick, chan, rest):
pm(cli, nick, "You may only bite someone after another wolf has died during the day.") pm(cli, nick, "You may only bite someone after another wolf has died during the day.")
return return
victim = get_victim(cli, nick, re.split(" +",rest)[0], False) victim = get_victim(cli, nick, re.split(" +",rest)[0], False, False)
vrole = None vrole = None
# also mark the victim as the kill target # also mark the victim as the kill target
if victim: if victim:
@ -4867,10 +4873,10 @@ def choose(cli, nick, chan, rest):
else: else:
victim2 = None victim2 = None
victim = get_victim(cli, nick, victim, True) victim = get_victim(cli, nick, victim, False, True)
if not victim: if not victim:
return return
victim2 = get_victim(cli, nick, victim2, True) victim2 = get_victim(cli, nick, victim2, False, True)
if not victim2: if not victim2:
return return
@ -4922,7 +4928,7 @@ def target(cli, nick, chan, rest):
if nick in var.SILENCED: if nick in var.SILENCED:
pm(cli, nick, "You have been silenced, and are unable to use any special powers.") pm(cli, nick, "You have been silenced, and are unable to use any special powers.")
return return
victim = get_victim(cli, nick, re.split(" +",rest)[0]) victim = get_victim(cli, nick, re.split(" +",rest)[0], False)
if not victim: if not victim:
return return
@ -4949,7 +4955,7 @@ def hex(cli, nick, chan, rest):
if nick in var.SILENCED: if nick in var.SILENCED:
pm(cli, nick, "You have been silenced, and are unable to use any special powers.") pm(cli, nick, "You have been silenced, and are unable to use any special powers.")
return return
victim = get_victim(cli, nick, re.split(" +",rest)[0]) victim = get_victim(cli, nick, re.split(" +",rest)[0], False)
if not victim: if not victim:
return return
@ -4989,7 +4995,7 @@ def clone(cli, nick, chan, rest):
# but just in case, it also sucks if the one night you're allowed to act is when you are # but just in case, it also sucks if the one night you're allowed to act is when you are
# silenced, so we ignore it here anyway. # silenced, so we ignore it here anyway.
victim = get_victim(cli, nick, re.split(" +",rest)[0]) victim = get_victim(cli, nick, re.split(" +",rest)[0], False)
if not victim: if not victim:
return return