can't be 0 game_start

Wasn't sending message or creating votegroups
fight-fixes
bobloy 7 years ago
parent 70a5583d56
commit 6370eb0faf

@ -5,7 +5,7 @@ import discord
from werewolf.role import Role
from werewolf.roles.vanillawerewolf import VanillaWerewolf
from werewolf.roles.villager import Villager
from werewolf.roles.seer import Seer
# All roles in this list for iterating
role_list = [Villager, VanillaWerewolf]
@ -33,6 +33,8 @@ async def parse_code(code):
role = Villager
if role_id == "VanillaWerewolf":
role = VanillaWerewolf
if role_id == "Seer":
role = Seer
out.append(role)
return out

@ -71,7 +71,7 @@ class Game:
1. Assign Roles
2. Create Channels
2a. Channel Permissions :eyes:
2a. Channel Permissions
3. Check Initial role setup (including alerts)
4. Start game
"""
@ -99,10 +99,11 @@ class Game:
self.village_channel = await self.guild.create_text_channel("Village Square", overwrites=overwrite, reason="New game of werewolf", category=self.channel_category)
# Assuming everything worked so far
print("Pre-game_start")
print("Pre at_game_start")
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)
overwrite = {
self.guild.default_role: discord.PermissionOverwrite(read_messages=False),
self.guild.me: discord.PermissionOverwrite(read_messages=True)
@ -159,7 +160,7 @@ class Game:
return
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)
@ -337,7 +338,7 @@ class Game:
if channel_id not in self.p_channels:
self.p_channels[channel_id] = self.default_secret_channel.copy()
await asyncio.sleep(1)
await asyncio.sleep(1) # This will have multiple calls
self.p_channels[channel_id]["players"].append(role.player)
@ -453,12 +454,10 @@ class Game:
await self._village_vote(target, author, id)
elif self.p_channels[channel.name]["votegroup"] is not None:
await self.vote_groups[channel.name].vote(target, author, id)
else: # Private channel voting, send to role
# await self.player.role.vote(target, id)
# I'll think of something later
else: # Somehow previous check failed
await channel.send("Cannot vote in this channel")
return
async def _village_vote(self, target, author, id):
if author in self.day_vote:
self.vote_totals[self.day_vote[author]] -= 1

@ -11,14 +11,14 @@ class Player:
def __init__(self, member: discord.Member):
self.member = member
self.mention = member.mention
self.role = None
self.id = None
self.alive = True
self.muted = False
self.protected = False
self.mention = self.member.mention
async def assign_role(self, role):
"""
Give this player a role

@ -56,7 +56,7 @@ class Role:
self.properties = {} # Extra data for other roles (i.e. arsonist)
self.action_list = [
(self._at_game_start, 0), # (Action, Priority)
(self._at_game_start, 1), # (Action, Priority)
(self._at_day_start, 0),
(self._at_voted, 0),
(self._at_kill, 0),

@ -24,7 +24,7 @@ class Seer(Role):
# self.properties = {} # Extra data for other roles (i.e. arsonist)
self.see_target = None
self.action_list = [
(self._at_game_start, 0), # (Action, Priority)
(self._at_game_start, 1), # (Action, Priority)
(self._at_day_start, 0),
(self._at_voted, 0),
(self._at_kill, 0),

@ -25,17 +25,16 @@ class VanillaWerewolf(Role):
super().__init__(game)
self.action_list = [
(self._at_game_start, 0), # (Action, Priority)
(self._at_game_start, 1), # (Action, Priority)
(self._at_day_start, 0),
(self._at_voted, 0),
(self._at_kill, 0),
(self._at_hang, 0),
(self._at_day_end, 0),
(self._at_night_start, 2), # Get vote priority
(self._at_night_start, 0),
(self._at_night_end, 0),
(self._at_visit, 0)
]
self.killer = None # Added killer
# async def on_event(self, event, data):
# """
@ -83,6 +82,7 @@ class VanillaWerewolf(Role):
async def _at_game_start(self, data=None):
if self.channel_id:
print("Wolf has channel_id: "+self.channel_id)
await self.game.register_channel(self.channel_id, self, WolfVote) # Add VoteGroup WolfVote
await self.player.send_dm(self.game_start_message)

@ -35,7 +35,7 @@ class Werewolf:
if ctx.invoked_subcommand is None:
await ctx.send_help()
@guild_only()
@commands.guild_only()
@ww.command()
async def new(self, ctx, game_code):
"""
@ -50,7 +50,7 @@ class Werewolf:
await ctx.send("New game has started")
@guild_only()
@commands.guild_only()
@ww.command()
async def join(self, ctx):
"""
@ -65,7 +65,7 @@ class Werewolf:
await game.join(ctx.author, ctx.channel)
@guild_only()
@commands.guild_only()
@ww.command()
async def quit(self, ctx):
"""
@ -76,7 +76,7 @@ class Werewolf:
await game.quit(ctx.author, ctx.channel)
@guild_only()
@commands.guild_only()
@ww.command()
async def start(self, ctx):
"""
@ -88,7 +88,7 @@ class Werewolf:
await game.setup(ctx)
@guild_only()
@commands.guild_only()
@ww.command()
async def stop(self, ctx):
"""
@ -100,7 +100,7 @@ class Werewolf:
game.game_over = True
@guild_only()
@commands.guild_only()
@ww.command()
async def vote(self, ctx, id: int):
"""

Loading…
Cancel
Save