|
|
|
@ -13,15 +13,15 @@ class Game:
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
default_secret_channel = {
|
|
|
|
|
"channel": None,
|
|
|
|
|
"players": [],
|
|
|
|
|
"votegroup": None # uninitialized VoteGroup
|
|
|
|
|
}
|
|
|
|
|
"channel": None,
|
|
|
|
|
"players": [],
|
|
|
|
|
"votegroup": None # uninitialized VoteGroup
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
morning_messages = [
|
|
|
|
|
"**The sun rises on day {} in the village..**",
|
|
|
|
|
"**Morning has arrived on day {}..**"
|
|
|
|
|
]
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
day_vote_count = 3
|
|
|
|
|
|
|
|
|
@ -81,9 +81,9 @@ class Game:
|
|
|
|
|
|
|
|
|
|
# Create category and channel with individual overwrites
|
|
|
|
|
overwrite = {
|
|
|
|
|
self.guild.default_role: discord.PermissionOverwrite(read_messages=False, send_messages=True),
|
|
|
|
|
self.guild.me: discord.PermissionOverwrite(read_messages=True, send_messages=True)
|
|
|
|
|
}
|
|
|
|
|
self.guild.default_role: discord.PermissionOverwrite(read_messages=False, send_messages=True),
|
|
|
|
|
self.guild.me: discord.PermissionOverwrite(read_messages=True, send_messages=True)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
self.channel_category = await self.guild.create_category("ww-game", overwrites=overwrite, reason="New game of "
|
|
|
|
|
"werewolf")
|
|
|
|
@ -101,11 +101,11 @@ class Game:
|
|
|
|
|
await self._at_game_start() # This will queue channels and votegroups to be made
|
|
|
|
|
print("Post at_game_start")
|
|
|
|
|
for channel_id in self.p_channels:
|
|
|
|
|
print("Channel id: "+channel_id)
|
|
|
|
|
print("Channel id: " + channel_id)
|
|
|
|
|
overwrite = {
|
|
|
|
|
self.guild.default_role: discord.PermissionOverwrite(read_messages=False),
|
|
|
|
|
self.guild.me: discord.PermissionOverwrite(read_messages=True)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for player in self.p_channels[channel_id]["players"]:
|
|
|
|
|
overwrite[player.member] = discord.PermissionOverwrite(read_messages=True)
|
|
|
|
@ -126,7 +126,7 @@ class Game:
|
|
|
|
|
|
|
|
|
|
print("Pre-cycle")
|
|
|
|
|
await asyncio.sleep(1)
|
|
|
|
|
asyncio.ensure_future(self._cycle()) # Start the loop
|
|
|
|
|
asyncio.ensure_future(self._cycle()) # Start the loop
|
|
|
|
|
|
|
|
|
|
############START Notify structure############
|
|
|
|
|
async def _cycle(self):
|
|
|
|
@ -165,7 +165,7 @@ class Game:
|
|
|
|
|
return not self.can_vote or not self.day_time or self.game_over
|
|
|
|
|
|
|
|
|
|
self.day_count += 1
|
|
|
|
|
embed=discord.Embed(title=random.choice(self.morning_messages).format(self.day_count))
|
|
|
|
|
embed = discord.Embed(title=random.choice(self.morning_messages).format(self.day_count))
|
|
|
|
|
for result in self.night_results:
|
|
|
|
|
embed.add_field(name=result, value="________", inline=False)
|
|
|
|
|
|
|
|
|
@ -231,9 +231,9 @@ class Game:
|
|
|
|
|
down_votes = sum(p.emoji == "👎" and not p.me for p in reaction_list)
|
|
|
|
|
|
|
|
|
|
if len(down_votes) > len(up_votes):
|
|
|
|
|
embed=discord.Embed(title="Vote Results", color=0xff0000)
|
|
|
|
|
embed = discord.Embed(title="Vote Results", color=0xff0000)
|
|
|
|
|
else:
|
|
|
|
|
embed=discord.Embed(title="Vote Results", color=0x80ff80)
|
|
|
|
|
embed = discord.Embed(title="Vote Results", color=0x80ff80)
|
|
|
|
|
|
|
|
|
|
embed.add_field(name="👎", value="**{}**".format(len(up_votes)), inline=True)
|
|
|
|
|
embed.add_field(name="👍", value="**{}**".format(len(down_votes)), inline=True)
|
|
|
|
@ -295,7 +295,7 @@ class Game:
|
|
|
|
|
|
|
|
|
|
await asyncio.sleep(120) # 2 minutes
|
|
|
|
|
await self.village_channel.send(embed=discord.Embed(title="**Two minutes of night remain...**"))
|
|
|
|
|
await asyncio.sleep(90) # 1.5 minutes
|
|
|
|
|
await asyncio.sleep(90) # 1.5 minutes
|
|
|
|
|
await self.village_channel.send(embed=discord.Embed(title="**Thirty seconds until sunrise...**"))
|
|
|
|
|
await asyncio.sleep(30) # .5 minutes
|
|
|
|
|
|
|
|
|
@ -316,14 +316,14 @@ class Game:
|
|
|
|
|
await self._notify(8, data)
|
|
|
|
|
|
|
|
|
|
async def _notify(self, event, data=None):
|
|
|
|
|
for i in range(1,7): # action guide 1-6 (0 is no action)
|
|
|
|
|
for i in range(1, 7): # action guide 1-6 (0 is no action)
|
|
|
|
|
tasks = []
|
|
|
|
|
# Role priorities
|
|
|
|
|
role_order = [role for role in self.roles if role.action_list[event][1]==i]
|
|
|
|
|
role_order = [role for role in self.roles if role.action_list[event][1] == i]
|
|
|
|
|
for role in role_order:
|
|
|
|
|
tasks.append(asyncio.ensure_future(role.on_event(event, data), loop=self.loop))
|
|
|
|
|
# VoteGroup priorities
|
|
|
|
|
vote_order = [vg for vg in self.vote_groups.values() if vg.action_list[event][1]==i]
|
|
|
|
|
vote_order = [vg for vg in self.vote_groups.values() if vg.action_list[event][1] == i]
|
|
|
|
|
for vote_group in vote_order:
|
|
|
|
|
tasks.append(asyncio.ensure_future(vote_group.on_event(event, data), loop=self.loop))
|
|
|
|
|
if tasks:
|
|
|
|
@ -333,7 +333,7 @@ class Game:
|
|
|
|
|
############END Notify structure############
|
|
|
|
|
|
|
|
|
|
async def generate_targets(self, channel):
|
|
|
|
|
embed=discord.Embed(title="Remaining Players")
|
|
|
|
|
embed = discord.Embed(title="Remaining Players")
|
|
|
|
|
for i in range(len(self.players)):
|
|
|
|
|
player = self.players[i]
|
|
|
|
|
if player.alive:
|
|
|
|
@ -517,7 +517,7 @@ class Game:
|
|
|
|
|
await self.dead_perms(self.village_channel, player.member)
|
|
|
|
|
# Add a punishment system for quitting games later
|
|
|
|
|
|
|
|
|
|
async def kill(self, target_id, source=None, method: str=None, novisit=False):
|
|
|
|
|
async def kill(self, target_id, source=None, method: str = None, novisit=False):
|
|
|
|
|
"""
|
|
|
|
|
Attempt to kill a target
|
|
|
|
|
Source allows admin override
|
|
|
|
|