Goat revamp (#286)
This commit is contained in:
parent
47705fbb2c
commit
b631f75499
@ -22,6 +22,7 @@ PSTATS_RATE_LIMIT = 0
|
|||||||
TIME_RATE_LIMIT = 10
|
TIME_RATE_LIMIT = 10
|
||||||
START_RATE_LIMIT = 10 # (per-user)
|
START_RATE_LIMIT = 10 # (per-user)
|
||||||
WAIT_RATE_LIMIT = 10 # (per-user)
|
WAIT_RATE_LIMIT = 10 # (per-user)
|
||||||
|
GOAT_RATE_LIMIT = 300 # (per-user)
|
||||||
SHOTS_MULTIPLIER = .12 # ceil(shots_multiplier * len_players) = bullets given
|
SHOTS_MULTIPLIER = .12 # ceil(shots_multiplier * len_players) = bullets given
|
||||||
SHARPSHOOTER_MULTIPLIER = 0.06
|
SHARPSHOOTER_MULTIPLIER = 0.06
|
||||||
MIN_PLAYERS = 4
|
MIN_PLAYERS = 4
|
||||||
@ -108,8 +109,6 @@ ENABLE_DEADCHAT = True # dead players can communicate with each other
|
|||||||
|
|
||||||
DYNQUIT_DURING_GAME = False # are dynamic quit messages used while a game is in progress? Note that true will break certain stats scrapers
|
DYNQUIT_DURING_GAME = False # are dynamic quit messages used while a game is in progress? Note that true will break certain stats scrapers
|
||||||
|
|
||||||
GOAT_HERDER = True
|
|
||||||
|
|
||||||
ABSTAIN_ENABLED = True # whether village can !abstain in order to not vote anyone during day
|
ABSTAIN_ENABLED = True # whether village can !abstain in order to not vote anyone during day
|
||||||
LIMIT_ABSTAIN = True # if true, village will be limited to successfully !abstaining a vote only once
|
LIMIT_ABSTAIN = True # if true, village will be limited to successfully !abstaining a vote only once
|
||||||
SELF_LYNCH_ALLOWED = True
|
SELF_LYNCH_ALLOWED = True
|
||||||
|
@ -65,11 +65,11 @@ var.LAST_PSTATS = None
|
|||||||
var.LAST_TIME = None
|
var.LAST_TIME = None
|
||||||
var.LAST_START = {}
|
var.LAST_START = {}
|
||||||
var.LAST_WAIT = {}
|
var.LAST_WAIT = {}
|
||||||
|
var.LAST_GOAT = {}
|
||||||
|
|
||||||
var.USERS = {}
|
var.USERS = {}
|
||||||
|
|
||||||
var.ADMIN_PINGING = False
|
var.ADMIN_PINGING = False
|
||||||
var.SPECIAL_ROLES = {}
|
|
||||||
var.ORIGINAL_ROLES = {}
|
var.ORIGINAL_ROLES = {}
|
||||||
var.PLAYERS = {}
|
var.PLAYERS = {}
|
||||||
var.DCED_PLAYERS = {}
|
var.DCED_PLAYERS = {}
|
||||||
@ -2929,45 +2929,41 @@ def on_join(cli, raw_nick, chan, acc="*", rname=""):
|
|||||||
# if "@" + botconfig.NICK in names:
|
# if "@" + botconfig.NICK in names:
|
||||||
# var.OPPED = True
|
# var.OPPED = True
|
||||||
|
|
||||||
@cmd("goat", playing=True, phases=("day",))
|
@command("goat")
|
||||||
def goat(cli, nick, chan, rest):
|
def goat(var, wrapper, message):
|
||||||
"""Use a goat to interact with anyone in the channel during the day."""
|
"""Use a goat to interact with anyone in the channel during the day."""
|
||||||
|
|
||||||
if var.GOATED and nick not in var.SPECIAL_ROLES["goat herder"]:
|
if wrapper.source in var.LAST_GOAT and var.LAST_GOAT[wrapper.source][0] + timedelta(seconds=var.GOAT_RATE_LIMIT) > datetime.now():
|
||||||
cli.notice(nick, messages["goat_fail"])
|
wrapper.pm(messages["command_ratelimited"])
|
||||||
return
|
return
|
||||||
|
target = re.split(" +",message)[0]
|
||||||
ul = list(var.USERS.keys())
|
if not target:
|
||||||
ull = [x.lower() for x in ul]
|
wrapper.pm(messages["not_enough_parameters"])
|
||||||
|
return
|
||||||
rest = re.split(" +",rest)[0]
|
possible_users = {u.lower().nick for u in wrapper.target.users}
|
||||||
if not rest:
|
victim = complete_one_match(users.lower(target), possible_users)
|
||||||
cli.notice(nick, messages["not_enough_parameters"])
|
|
||||||
|
|
||||||
victim = complete_one_match(rest.lower(), ull)
|
|
||||||
if not victim:
|
if not victim:
|
||||||
cli.notice(nick, messages["goat_target_not_in_channel"].format(rest))
|
wrapper.pm(messages["goat_target_not_in_channel"].format(target))
|
||||||
return
|
return
|
||||||
victim = ul[ull.index(victim)]
|
|
||||||
|
|
||||||
|
var.LAST_GOAT[wrapper.source] = [datetime.now(), 1]
|
||||||
goatact = random.choice(messages["goat_actions"])
|
goatact = random.choice(messages["goat_actions"])
|
||||||
|
wrapper.send(messages["goat_success"].format(wrapper.source, goatact, victim))
|
||||||
|
|
||||||
cli.msg(chan, messages["goat_success"].format(
|
@command("fgoat", flag="j")
|
||||||
nick, goatact, victim))
|
def fgoat(var, wrapper, message):
|
||||||
|
|
||||||
var.GOATED = True
|
|
||||||
|
|
||||||
@cmd("fgoat", flag="j")
|
|
||||||
def fgoat(cli, nick, chan, rest):
|
|
||||||
"""Forces a goat to interact with anyone or anything, without limitations."""
|
"""Forces a goat to interact with anyone or anything, without limitations."""
|
||||||
nick_ = rest.split(' ')[0].strip()
|
|
||||||
if nick_.lower() in (x.lower() for x in users.users()):
|
nick = message.split(' ')[0].strip()
|
||||||
togoat = nick_
|
possible_users = {u.lower().nick for u in wrapper.target.users}
|
||||||
|
victim = complete_one_match(users.lower(nick), possible_users)
|
||||||
|
if victim:
|
||||||
|
togoat = victim
|
||||||
else:
|
else:
|
||||||
togoat = rest
|
togoat = message
|
||||||
goatact = random.choice(messages["goat_actions"])
|
goatact = random.choice(messages["goat_actions"])
|
||||||
|
|
||||||
cli.msg(chan, messages["goat_success"].format(nick, goatact, togoat))
|
wrapper.send(messages["goat_success"].format(wrapper.source, goatact, togoat))
|
||||||
|
|
||||||
@handle_error
|
@handle_error
|
||||||
def return_to_village(var, chan, target, *, show_message):
|
def return_to_village(var, chan, target, *, show_message):
|
||||||
@ -3190,6 +3186,10 @@ def nick_change(evt, var, user, old_rawnick):
|
|||||||
if nick not in var.DISCONNECTED: # FIXME: Need to update this once var.DISCONNECTED holds User instances
|
if nick not in var.DISCONNECTED: # FIXME: Need to update this once var.DISCONNECTED holds User instances
|
||||||
rename_player(var, user, nick) # FIXME: Fix when rename_player supports the new interface
|
rename_player(var, user, nick) # FIXME: Fix when rename_player supports the new interface
|
||||||
|
|
||||||
|
@event_listener("cleanup_user")
|
||||||
|
def cleanup_user(evt, var, user):
|
||||||
|
var.LAST_GOAT.pop(user, None)
|
||||||
|
|
||||||
@event_listener("nick_change")
|
@event_listener("nick_change")
|
||||||
def update_users(evt, var, user, old_rawnick): # FIXME: This is a temporary hack while var.USERS still exists
|
def update_users(evt, var, user, old_rawnick): # FIXME: This is a temporary hack while var.USERS still exists
|
||||||
nick = users.parse_rawnick_as_dict(old_rawnick)["nick"]
|
nick = users.parse_rawnick_as_dict(old_rawnick)["nick"]
|
||||||
@ -3350,7 +3350,7 @@ def begin_day(cli):
|
|||||||
var.DISEASED = set()
|
var.DISEASED = set()
|
||||||
var.MISDIRECTED = set()
|
var.MISDIRECTED = set()
|
||||||
var.DYING = set()
|
var.DYING = set()
|
||||||
|
var.LAST_GOAT.clear()
|
||||||
msg = messages["villagers_lynch"].format(botconfig.CMD_CHAR, len(list_players()) // 2 + 1)
|
msg = messages["villagers_lynch"].format(botconfig.CMD_CHAR, len(list_players()) // 2 + 1)
|
||||||
cli.msg(chan, msg)
|
cli.msg(chan, msg)
|
||||||
|
|
||||||
@ -3409,7 +3409,6 @@ def transition_day(cli, gameid=0):
|
|||||||
return
|
return
|
||||||
|
|
||||||
var.PHASE = "day"
|
var.PHASE = "day"
|
||||||
var.GOATED = False
|
|
||||||
var.DAY_COUNT += 1
|
var.DAY_COUNT += 1
|
||||||
var.FIRST_DAY = (var.DAY_COUNT == 1)
|
var.FIRST_DAY = (var.DAY_COUNT == 1)
|
||||||
var.DAY_START_TIME = datetime.now()
|
var.DAY_START_TIME = datetime.now()
|
||||||
@ -5888,11 +5887,6 @@ def start(cli, nick, chan, forced = False, restart = ""):
|
|||||||
|
|
||||||
var.ROLES["sharpshooter"].discard(None)
|
var.ROLES["sharpshooter"].discard(None)
|
||||||
|
|
||||||
if not restart:
|
|
||||||
var.SPECIAL_ROLES["goat herder"] = []
|
|
||||||
if var.GOAT_HERDER:
|
|
||||||
var.SPECIAL_ROLES["goat herder"] = [ nick ]
|
|
||||||
|
|
||||||
with var.WARNING_LOCK: # cancel timers
|
with var.WARNING_LOCK: # cancel timers
|
||||||
for name in ("join", "join_pinger", "start_votes"):
|
for name in ("join", "join_pinger", "start_votes"):
|
||||||
if name in var.TIMERS:
|
if name in var.TIMERS:
|
||||||
|
Loading…
Reference in New Issue
Block a user