Some fixes to stasis (cf. GH-5).
This commit is contained in:
parent
29473b2098
commit
6943dbdd4e
@ -69,7 +69,7 @@ var.GAME_ID = 0
|
|||||||
|
|
||||||
var.DISCONNECTED = {} # players who got disconnected
|
var.DISCONNECTED = {} # players who got disconnected
|
||||||
|
|
||||||
var.illegal_joins = defaultdict(int)
|
var.STASISED = defaultdict(int)
|
||||||
|
|
||||||
var.LOGGER = WolfgameLogger(var.LOG_FILENAME, var.BARE_LOG_FILENAME)
|
var.LOGGER = WolfgameLogger(var.LOG_FILENAME, var.BARE_LOG_FILENAME)
|
||||||
|
|
||||||
@ -193,7 +193,7 @@ def make_stasis(nick, penalty):
|
|||||||
try:
|
try:
|
||||||
cloak = var.USERS[nick]['cloak']
|
cloak = var.USERS[nick]['cloak']
|
||||||
if cloak is not None:
|
if cloak is not None:
|
||||||
var.illegal_joins[cloak] += penalty
|
var.STASISED[cloak] += penalty
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -267,7 +267,7 @@ def pinger(cli, nick, chan, rest):
|
|||||||
if (all((not var.OPT_IN_PING,
|
if (all((not var.OPT_IN_PING,
|
||||||
'G' not in status, # not /away
|
'G' not in status, # not /away
|
||||||
'+' not in status, # not already joined (voiced)
|
'+' not in status, # not already joined (voiced)
|
||||||
cloak not in var.illegal_joins, # not in stasis
|
cloak not in var.STASISED, # not in stasis
|
||||||
cloak not in var.AWAY)) or
|
cloak not in var.AWAY)) or
|
||||||
all((var.OPT_IN_PING, '+' not in status,
|
all((var.OPT_IN_PING, '+' not in status,
|
||||||
cloak in var.PING_IN))):
|
cloak in var.PING_IN))):
|
||||||
@ -389,8 +389,8 @@ def join(cli, nick, chann_, rest):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
cloak = var.USERS[nick]['cloak']
|
cloak = var.USERS[nick]['cloak']
|
||||||
if cloak is not None and cloak in var.illegal_joins and var.illegal_joins[cloak] > 0:
|
if cloak is not None and cloak in var.STASISED and var.STASISED[cloak] > 0:
|
||||||
cli.notice(nick, "Sorry, but you are in stasis for {0} games.".format(var.illegal_joins[cloak]))
|
cli.notice(nick, "Sorry, but you are in stasis for {0} games.".format(var.STASISED[cloak]))
|
||||||
return
|
return
|
||||||
except KeyError:
|
except KeyError:
|
||||||
cloak = None
|
cloak = None
|
||||||
@ -2492,11 +2492,11 @@ def start(cli, nick, chann_, rest):
|
|||||||
else:
|
else:
|
||||||
transition_day(cli)
|
transition_day(cli)
|
||||||
|
|
||||||
for cloak in list(var.illegal_joins.keys()):
|
for cloak in list(var.STASISED.keys()):
|
||||||
if var.illegal_joins[cloak] != 0:
|
if var.STASISED[cloak] != 0:
|
||||||
var.illegal_joins[cloak] -= 1
|
var.STASISED[cloak] -= 1
|
||||||
else:
|
else:
|
||||||
del var.illegal_joins[cloak]
|
del var.STASISED[cloak]
|
||||||
|
|
||||||
# DEATH TO IDLERS!
|
# DEATH TO IDLERS!
|
||||||
reapertimer = threading.Thread(None, reaper, args=(cli,var.GAME_ID))
|
reapertimer = threading.Thread(None, reaper, args=(cli,var.GAME_ID))
|
||||||
@ -2517,19 +2517,21 @@ def on_error(cli, pfx, msg):
|
|||||||
def fstasis(cli, nick, *rest):
|
def fstasis(cli, nick, *rest):
|
||||||
data = rest[0].split()
|
data = rest[0].split()
|
||||||
if len(data) == 2:
|
if len(data) == 2:
|
||||||
if data[0] in var.USERS:
|
lusers = {k.lower(): v for k, v in var.USERS.items()}
|
||||||
cloak = var.USERS[str(data[0])]['cloak']
|
user = data[0].lower()
|
||||||
|
if user in lusers:
|
||||||
|
cloak = lusers[str(user)]['cloak']
|
||||||
else:
|
else:
|
||||||
cloak = None
|
cloak = None
|
||||||
amt = data[1]
|
amt = data[1]
|
||||||
if cloak is not None:
|
if cloak is not None:
|
||||||
var.illegal_joins[cloak] = int(amt)
|
var.STASISED[cloak] = int(amt)
|
||||||
cli.msg(nick, "{0} is now in stasis for {1} games".format(data[0], amt))
|
cli.msg(nick, "{0} ({1}) is now in stasis for {2} games.".format(data[0], cloak, amt))
|
||||||
else:
|
else:
|
||||||
cli.msg(nick, "Sorry, that user cannot be found.")
|
cli.msg(nick, "Sorry, that user cannot be found.")
|
||||||
else:
|
else:
|
||||||
cli.msg(nick, "Currently stasised: {0}".format(
|
cli.msg(nick, "Currently stasised: {0}".format(
|
||||||
", ".join("{0}: {1}".format(cloak, number) for cloak, number in var.illegal_joins.items())))
|
", ".join("{0}: {1}".format(cloak, number) for cloak, number in var.STASISED.items())))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user