more elegant setup function
This commit is contained in:
parent
caca8bc2e5
commit
be93817063
|
@ -36,15 +36,18 @@ class Game:
|
|||
|
||||
def setup(self):
|
||||
self.role = dict()
|
||||
# setting default value
|
||||
for r in Role.__subclasses__():
|
||||
if r not in [Werewolf, Mason, No_role]:
|
||||
if r == No_role:
|
||||
continue
|
||||
if r in [Werewolf, Mason]:
|
||||
self.role[r] = []
|
||||
else:
|
||||
r(self)
|
||||
self.role[Werewolf] = []
|
||||
self.role[Mason] = []
|
||||
self.voting_list = self.player_list + [No_player()]
|
||||
for c in self.voting_list:
|
||||
c.tally = 0
|
||||
c.won = c.dead = False
|
||||
c.reset()
|
||||
self.time = 0
|
||||
|
||||
def distribute_roles(self):
|
||||
shuffle(self.role_list)
|
||||
|
@ -74,6 +77,9 @@ class Game:
|
|||
async def start_day(self):
|
||||
await self.send("The day has started")
|
||||
|
||||
async def discussion_timer(self):
|
||||
pass
|
||||
|
||||
async def vote(self):
|
||||
|
||||
# vote
|
||||
|
@ -168,8 +174,8 @@ class Game:
|
|||
async def round(self):
|
||||
try:
|
||||
self.check()
|
||||
self.running = True
|
||||
self.setup()
|
||||
self.running = True
|
||||
self.distribute_roles()
|
||||
await self.start_night()
|
||||
await self.send_role()
|
||||
|
@ -177,7 +183,6 @@ class Game:
|
|||
await self.night_phases()
|
||||
|
||||
await self.start_day()
|
||||
# discussion timer
|
||||
|
||||
await self.vote()
|
||||
self.tally()
|
||||
|
|
|
@ -14,6 +14,10 @@ class Player:
|
|||
def setRole(self, role):
|
||||
self.day_role = self.night_role = role
|
||||
|
||||
def reset(self):
|
||||
self.tally = 0
|
||||
self.won = self.dead = False
|
||||
|
||||
def name(self):
|
||||
return self.member.name
|
||||
|
||||
|
|
Loading…
Reference in New Issue