Browse Source

renamed a module, fixed some bugs and added !game (not in the other wolfbot)

--HG--
rename : vars.py => var.py
master
jcao219 14 years ago
parent
commit
fef6d85d0c
  1. 60
      var.py
  2. 678
      wolfgame.py

60
vars.py → var.py

@ -14,13 +14,14 @@ MANSLAUGHTER_CHANCE = 1/5
GAME_MODES = {} GAME_MODES = {}
############################################################################################ ################################################################################################
# ROLE INDEX: PLAYERS SEER WOLF CURSED DRUNK HARLOT TRAITOR GUNNER CROW # # ROLE INDEX: PLAYERS SEER WOLF CURSED DRUNK HARLOT TRAITOR GUNNER CROW #
ROLES_GUIDE = { 4 : ( 0 , 1 , 0 , 0 , 0 , 0 , 2 , 0), # ROLES_GUIDE = { 4 : ( 1 , 1 , 0 , 0 , 0 , 0 , 0 , 0 ), #
6 : ( 0 , 1 , 0 , 0 , 0 , 0 , 4 , 0), # 6 : ( 1 , 1 , 1 , 1 , 0 , 0 , 0 , 0 ), #
8 : ( 1 , 2 , 1 , 1 , 1 , 0 , 0 , 0), # 8 : ( 1 , 2 , 1 , 1 , 1 , 0 , 0 , 0 ), #
10 : ( 1 , 2 , 1 , 1 , 1 , 1 , 1 , 0)} # 10 : ( 1 , 2 , 1 , 1 , 1 , 1 , 1 , 0 ), #
############################################################################################ None : ( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 )} #
################################################################################################
ROLE_INDICES = {0 : "seer", ROLE_INDICES = {0 : "seer",
1 : "wolf", 1 : "wolf",
@ -70,7 +71,7 @@ def del_player(pname):
class InvalidModeException(object): pass class InvalidModeException(Exception): pass
def game_mode(name): def game_mode(name):
def decor(c): def decor(c):
GAME_MODES[name] = c GAME_MODES[name] = c
@ -78,41 +79,40 @@ def game_mode(name):
return decor return decor
CHANGEABLE_ROLES = { "seer" : 0, CHANGEABLE_ROLES = { "seers" : 0,
"wolf" : 1, "wolves" : 1,
"drunk" : 3, "drunks" : 3,
"harlot" : 4, "harlots" : 4,
"traitor" : 5, "traitors" : 5,
"gunner" : 6, "gunners" : 6,
"werecrow" : 7 } "werecrows" : 7 }
# !game roles wolves:1 seers:0 # !game roles=wolves:1 seers:0, x=1
# TODO: implement game modes # TODO: implement game modes
@game_mode("roles") @game_mode("roles")
class ChangedRolesMode(object): class ChangedRolesMode(object):
ROLES_GUIDE = ROLES_GUIDE.copy() ROLES_GUIDE = ROLES_GUIDE.copy()
def __init__(self, arg): def __init__(self, arg):
pairs = arg.split(" ") pairs = arg.split(",")
if len(parts) == 1: pl = list_players()
raise InvalidModeException("Invalid syntax for !game roles.") if not pairs:
raise InvalidModeException("Invalid syntax for mode roles.")
for pair in pairs: for pair in pairs:
change = pair.split(":") change = pair.split(":")
if len(change) != 2: if len(change) != 2:
raise InvalidModeException("Invalid syntax for !game roles.") raise InvalidModeException("Invalid syntax for mode roles.")
role, num = change role, num = change
try: try:
num = int(num) num = int(num)
except ValueError: except ValueError:
raise InvalidModeException("A bad value was used in !game roles.") raise InvalidModeException("A bad value was used in mode roles.")
for x in self.ROLES_GUIDE.keys(): lx = list(ROLES_GUIDE[None])
lx = list(x) try:
try: lx[CHANGEABLE_ROLES[role.lower()]] = num
lx[CHANGEABLE_ROLES[role.lower()]] = num except KeyError:
except KeyError: raise InvalidModeException('"{0}" is not a changeable role.'.format(role))
raise InvalidModeException('"{0}" is not a changeable role.'.format(role)) self.ROLES_GUIDE[len(pl)] = tuple(lx)
self.ROLES_GUIDE[x] = tuple(lx) if len(pl) < sum(self.ROLES_GUIDE[len(pl)]):
pl = list_players()
if len(pl) < sum(self.ROLES_GUIDE[4]):
raise InvalidModeException("Too few players for such these custom roles.") raise InvalidModeException("Too few players for such these custom roles.")

678
wolfgame.py

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save