You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
118 lines
4.5 KiB
118 lines
4.5 KiB
14 years ago
|
PING_WAIT = 300 # Seconds
|
||
14 years ago
|
MINIMUM_WAIT = 0 # debug, change to 60 for normal
|
||
14 years ago
|
EXTRA_WAIT = 20
|
||
|
MAXIMUM_WAITED = 2 # limit for amount of !wait's
|
||
|
MAX_SHOTS = 2
|
||
14 years ago
|
DRUNK_SHOTS_MULTIPLIER = 3
|
||
14 years ago
|
NIGHT_TIME_LIMIT = 0
|
||
|
DAY_TIME_LIMIT = 0
|
||
14 years ago
|
|
||
14 years ago
|
# HIT MISS SUICIDE
|
||
|
GUN_CHANCES = ( 5/7 , 1/7 , 1/7 )
|
||
|
DRUNK_GUN_CHANCES = ( 4/7 , 2/7 , 1/7 )
|
||
|
MANSLAUGHTER_CHANCE = 1/5
|
||
|
|
||
14 years ago
|
GAME_MODES = {}
|
||
|
|
||
14 years ago
|
################################################################################################
|
||
|
# ROLE INDEX: PLAYERS SEER WOLF CURSED DRUNK HARLOT TRAITOR GUNNER CROW #
|
||
|
ROLES_GUIDE = { 4 : ( 1 , 1 , 0 , 0 , 0 , 0 , 0 , 0 ), #
|
||
|
6 : ( 1 , 1 , 1 , 1 , 0 , 0 , 0 , 0 ), #
|
||
|
8 : ( 1 , 2 , 1 , 1 , 1 , 0 , 0 , 0 ), #
|
||
|
10 : ( 1 , 2 , 1 , 1 , 1 , 1 , 1 , 0 ), #
|
||
|
None : ( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 )} #
|
||
|
################################################################################################
|
||
14 years ago
|
|
||
14 years ago
|
ROLE_INDICES = {0 : "seer",
|
||
|
1 : "wolf",
|
||
|
2 : "cursed",
|
||
|
3 : "village drunk",
|
||
|
4 : "harlot",
|
||
|
5 : "traitor",
|
||
14 years ago
|
6 : "gunner",
|
||
|
7 : "werecrow"}
|
||
14 years ago
|
|
||
14 years ago
|
|
||
|
|
||
|
NO_VICTIMS_MESSAGES = ("The body of a young penguin pet is found.",
|
||
14 years ago
|
"A pool of blood and wolf paw prints are found.",
|
||
14 years ago
|
"Traces of wolf fur are found.")
|
||
14 years ago
|
LYNCH_MESSAGES = ("The villagers, after much debate, finally decide on lynching \u0002{0}\u0002, who turned out to be... a \u0002{1}\u0002.",
|
||
|
"Under a lot of noise, the pitchfork-bearing villagers lynch \u0002{0}\u0002, who turned out to be... a \u0002{1}\u0002.",
|
||
|
"The mob drags a protesting \u0002{0}\u0002 to the hanging tree. S/He succumbs to the will of the horde, and is hanged. It is discovered (s)he was a \u0002{1}\u0002.",
|
||
|
"Resigned to his/her fate, \u0002{0}\u0002 is led to the gallows. After death, it is discovered (s)he was a \u0002{1}\u0002.")
|
||
14 years ago
|
|
||
14 years ago
|
|
||
14 years ago
|
is_role = lambda plyr, rol: rol in ROLES and plyr in ROLES[rol]
|
||
|
|
||
|
def plural(role):
|
||
|
if role == "wolf": return "wolves"
|
||
|
elif role == "person": return "people"
|
||
14 years ago
|
else: return role + "s"
|
||
|
|
||
|
def list_players():
|
||
|
pl = []
|
||
|
for x in ROLES.values():
|
||
|
pl.extend(x)
|
||
|
return pl
|
||
|
|
||
|
def list_players_and_roles():
|
||
|
plr = {}
|
||
|
for x in ROLES.keys():
|
||
|
for p in ROLES[x]:
|
||
|
plr[p] = x
|
||
14 years ago
|
return plr
|
||
|
|
||
|
get_role = lambda plyr: list_players_and_roles()[plyr]
|
||
|
|
||
|
def del_player(pname):
|
||
|
prole = get_role(pname)
|
||
14 years ago
|
ROLES[prole].remove(pname)
|
||
|
|
||
|
|
||
|
|
||
14 years ago
|
class InvalidModeException(Exception): pass
|
||
14 years ago
|
def game_mode(name):
|
||
|
def decor(c):
|
||
|
GAME_MODES[name] = c
|
||
|
return c
|
||
|
return decor
|
||
|
|
||
|
|
||
14 years ago
|
CHANGEABLE_ROLES = { "seers" : 0,
|
||
|
"wolves" : 1,
|
||
|
"drunks" : 3,
|
||
|
"harlots" : 4,
|
||
|
"traitors" : 5,
|
||
|
"gunners" : 6,
|
||
|
"werecrows" : 7 }
|
||
14 years ago
|
|
||
14 years ago
|
# !game roles=wolves:1 seers:0, x=1
|
||
14 years ago
|
|
||
|
# TODO: implement game modes
|
||
|
@game_mode("roles")
|
||
|
class ChangedRolesMode(object):
|
||
|
ROLES_GUIDE = ROLES_GUIDE.copy()
|
||
|
def __init__(self, arg):
|
||
14 years ago
|
pairs = arg.split(",")
|
||
|
pl = list_players()
|
||
|
if not pairs:
|
||
|
raise InvalidModeException("Invalid syntax for mode roles.")
|
||
14 years ago
|
for pair in pairs:
|
||
|
change = pair.split(":")
|
||
|
if len(change) != 2:
|
||
14 years ago
|
raise InvalidModeException("Invalid syntax for mode roles.")
|
||
14 years ago
|
role, num = change
|
||
|
try:
|
||
|
num = int(num)
|
||
|
except ValueError:
|
||
14 years ago
|
raise InvalidModeException("A bad value was used in mode roles.")
|
||
|
lx = list(ROLES_GUIDE[None])
|
||
|
try:
|
||
|
lx[CHANGEABLE_ROLES[role.lower()]] = num
|
||
|
except KeyError:
|
||
|
raise InvalidModeException('"{0}" is not a changeable role.'.format(role))
|
||
|
self.ROLES_GUIDE[len(pl)] = tuple(lx)
|
||
|
if len(pl) < sum(self.ROLES_GUIDE[len(pl)]):
|
||
14 years ago
|
raise InvalidModeException("Too few players for such these custom roles.")
|
||
|
|