Fix for stasising.
- Removes cloaks from var.STASISED when var.STASISED[cloak] <= 0 - Slight rewrite of fstasis(). The stasis value for a player can now be specified directly. If data[1] <= 0, stasis is removed for the player if player had one. If data[1] > 0, that amount is set for the player's stasis. It now catches ValueError exceptions for invalid values of data[1].
This commit is contained in:
parent
860af415c9
commit
959ef98f51
@ -199,8 +199,6 @@ def make_stasis(nick, penalty):
|
||||
cloak = var.USERS[nick]['cloak']
|
||||
if cloak is not None:
|
||||
var.STASISED[cloak] += penalty
|
||||
if var.STASISED[cloak] == 0:
|
||||
var.STASISED.remove(cloak)
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
@ -2564,8 +2562,9 @@ def start(cli, nick, chann_, rest):
|
||||
transition_day(cli)
|
||||
|
||||
for cloak in list(var.STASISED.keys()):
|
||||
if cloak in var.STASISED:
|
||||
var.STASISED[cloak] -= 1
|
||||
if var.STASISED[cloak] <= 0:
|
||||
del var.STASISED[cloak]
|
||||
|
||||
# DEATH TO IDLERS!
|
||||
reapertimer = threading.Thread(None, reaper, args=(cli,var.GAME_ID))
|
||||
@ -2585,40 +2584,38 @@ def on_error(cli, pfx, msg):
|
||||
@pmcmd("fstasis", admin_only=True)
|
||||
def fstasis(cli, nick, *rest):
|
||||
data = rest[0].split()
|
||||
if data and len(data) < 3:
|
||||
if data:
|
||||
lusers = {k.lower(): v for k, v in var.USERS.items()}
|
||||
user = data[0].lower()
|
||||
if user in lusers:
|
||||
cloak = lusers[user]['cloak']
|
||||
else:
|
||||
cloak = None
|
||||
if cloak is None:
|
||||
cli.msg(nick, "Sorry, that user cannot be found.")
|
||||
return
|
||||
if len(data) == 2:
|
||||
amt = int(data[1])
|
||||
if amt < 0 and cloak in var.STASISED:
|
||||
var.STASISED[cloak] += amt
|
||||
if var.STASISED[cloak] == 0:
|
||||
cli.msg(nick, "{0} ({1}) is no longer in stasis.".format(data[0], cloak))
|
||||
var.STASISED.remove(cloak)
|
||||
else:
|
||||
cli.msg(nick, "{0} ({1}) is now in stasis for {2} games.".format(data[0], cloak, var.STASISED[cloak]))
|
||||
elif amt <= 0:
|
||||
if cloak in var.STASISED:
|
||||
var.STASISED.remove(cloak)
|
||||
cli.msg(nick, "{0} ({1}) is no longer in stasis.".format(data[0], cloak))
|
||||
else:
|
||||
cli.msg(nick, "{0} ({1}) is not in stasis.".format(data[0], cloak))
|
||||
else:
|
||||
var.STASISED[cloak] = amt
|
||||
cli.msg(nick, "{0} ({1}) is now in stasis for {2} games.".format(data[0], cloak, amt))
|
||||
elif len(data) == 1:
|
||||
|
||||
if len(data) == 1:
|
||||
if cloak in var.STASISED:
|
||||
cli.msg(nick, "{0} ({1}) is in stasis for {2} games.".format(data[0], cloak, var.STASISED[cloak]))
|
||||
else:
|
||||
cli.msg(nick, "{0} ({1}) is not in stasis.".format(data[0], cloak))
|
||||
elif not data:
|
||||
else:
|
||||
try:
|
||||
amt = int(data[1])
|
||||
except ValueError:
|
||||
cli.msg(nick, "Sorry, invalid integer argument.")
|
||||
return
|
||||
|
||||
if amt > 0:
|
||||
var.STASISED[cloak] = amt
|
||||
cli.msg(nick, "{0} ({1}) is now in stasis for {2} games.".format(data[0], cloak, amt))
|
||||
else:
|
||||
if cloak in var.STASISED:
|
||||
del var.STASISED[cloak]
|
||||
cli.msg(nick, "{0} ({1}) is no longer in stasis.".format(data[0], cloak))
|
||||
else:
|
||||
cli.msg(nick, "{0} ({1}) is not in stasis.".format(data[0], cloak))
|
||||
else:
|
||||
if var.STASISED:
|
||||
cli.msg(nick, "Currently stasised: {0}".format(
|
||||
", ".join("{0}: {1}".format(cloak, number) for cloak, number in var.STASISED.items())))
|
||||
|
Loading…
Reference in New Issue
Block a user