can't be 0 game_start
Wasn't sending message or creating votegroups
This commit is contained in:
parent
70a5583d56
commit
6370eb0faf
@ -5,7 +5,7 @@ import discord
|
|||||||
from werewolf.role import Role
|
from werewolf.role import Role
|
||||||
from werewolf.roles.vanillawerewolf import VanillaWerewolf
|
from werewolf.roles.vanillawerewolf import VanillaWerewolf
|
||||||
from werewolf.roles.villager import Villager
|
from werewolf.roles.villager import Villager
|
||||||
|
from werewolf.roles.seer import Seer
|
||||||
|
|
||||||
# All roles in this list for iterating
|
# All roles in this list for iterating
|
||||||
role_list = [Villager, VanillaWerewolf]
|
role_list = [Villager, VanillaWerewolf]
|
||||||
@ -33,6 +33,8 @@ async def parse_code(code):
|
|||||||
role = Villager
|
role = Villager
|
||||||
if role_id == "VanillaWerewolf":
|
if role_id == "VanillaWerewolf":
|
||||||
role = VanillaWerewolf
|
role = VanillaWerewolf
|
||||||
|
if role_id == "Seer":
|
||||||
|
role = Seer
|
||||||
out.append(role)
|
out.append(role)
|
||||||
|
|
||||||
return out
|
return out
|
||||||
|
@ -71,7 +71,7 @@ class Game:
|
|||||||
|
|
||||||
1. Assign Roles
|
1. Assign Roles
|
||||||
2. Create Channels
|
2. Create Channels
|
||||||
2a. Channel Permissions :eyes:
|
2a. Channel Permissions
|
||||||
3. Check Initial role setup (including alerts)
|
3. Check Initial role setup (including alerts)
|
||||||
4. Start game
|
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)
|
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
|
# 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
|
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:
|
for channel_id in self.p_channels:
|
||||||
|
print("Channel id: "+channel_id)
|
||||||
overwrite = {
|
overwrite = {
|
||||||
self.guild.default_role: discord.PermissionOverwrite(read_messages=False),
|
self.guild.default_role: discord.PermissionOverwrite(read_messages=False),
|
||||||
self.guild.me: discord.PermissionOverwrite(read_messages=True)
|
self.guild.me: discord.PermissionOverwrite(read_messages=True)
|
||||||
@ -159,7 +160,7 @@ class Game:
|
|||||||
return
|
return
|
||||||
|
|
||||||
self.day_count += 1
|
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:
|
for result in self.night_results:
|
||||||
embed.add_field(name=result, value="________", inline=False)
|
embed.add_field(name=result, value="________", inline=False)
|
||||||
|
|
||||||
@ -337,7 +338,7 @@ class Game:
|
|||||||
if channel_id not in self.p_channels:
|
if channel_id not in self.p_channels:
|
||||||
self.p_channels[channel_id] = self.default_secret_channel.copy()
|
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)
|
self.p_channels[channel_id]["players"].append(role.player)
|
||||||
|
|
||||||
@ -453,11 +454,9 @@ class Game:
|
|||||||
await self._village_vote(target, author, id)
|
await self._village_vote(target, author, id)
|
||||||
elif self.p_channels[channel.name]["votegroup"] is not None:
|
elif self.p_channels[channel.name]["votegroup"] is not None:
|
||||||
await self.vote_groups[channel.name].vote(target, author, id)
|
await self.vote_groups[channel.name].vote(target, author, id)
|
||||||
else: # Private channel voting, send to role
|
else: # Somehow previous check failed
|
||||||
# await self.player.role.vote(target, id)
|
await channel.send("Cannot vote in this channel")
|
||||||
# I'll think of something later
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async def _village_vote(self, target, author, id):
|
async def _village_vote(self, target, author, id):
|
||||||
if author in self.day_vote:
|
if author in self.day_vote:
|
||||||
|
@ -11,13 +11,13 @@ class Player:
|
|||||||
|
|
||||||
def __init__(self, member: discord.Member):
|
def __init__(self, member: discord.Member):
|
||||||
self.member = member
|
self.member = member
|
||||||
|
self.mention = member.mention
|
||||||
self.role = None
|
self.role = None
|
||||||
self.id = None
|
self.id = None
|
||||||
|
|
||||||
self.alive = True
|
self.alive = True
|
||||||
self.muted = False
|
self.muted = False
|
||||||
self.protected = False
|
self.protected = False
|
||||||
self.mention = self.member.mention
|
|
||||||
|
|
||||||
async def assign_role(self, role):
|
async def assign_role(self, role):
|
||||||
"""
|
"""
|
||||||
|
@ -56,7 +56,7 @@ class Role:
|
|||||||
self.properties = {} # Extra data for other roles (i.e. arsonist)
|
self.properties = {} # Extra data for other roles (i.e. arsonist)
|
||||||
|
|
||||||
self.action_list = [
|
self.action_list = [
|
||||||
(self._at_game_start, 0), # (Action, Priority)
|
(self._at_game_start, 1), # (Action, Priority)
|
||||||
(self._at_day_start, 0),
|
(self._at_day_start, 0),
|
||||||
(self._at_voted, 0),
|
(self._at_voted, 0),
|
||||||
(self._at_kill, 0),
|
(self._at_kill, 0),
|
||||||
|
@ -24,7 +24,7 @@ class Seer(Role):
|
|||||||
# self.properties = {} # Extra data for other roles (i.e. arsonist)
|
# self.properties = {} # Extra data for other roles (i.e. arsonist)
|
||||||
self.see_target = None
|
self.see_target = None
|
||||||
self.action_list = [
|
self.action_list = [
|
||||||
(self._at_game_start, 0), # (Action, Priority)
|
(self._at_game_start, 1), # (Action, Priority)
|
||||||
(self._at_day_start, 0),
|
(self._at_day_start, 0),
|
||||||
(self._at_voted, 0),
|
(self._at_voted, 0),
|
||||||
(self._at_kill, 0),
|
(self._at_kill, 0),
|
||||||
|
@ -25,17 +25,16 @@ class VanillaWerewolf(Role):
|
|||||||
super().__init__(game)
|
super().__init__(game)
|
||||||
|
|
||||||
self.action_list = [
|
self.action_list = [
|
||||||
(self._at_game_start, 0), # (Action, Priority)
|
(self._at_game_start, 1), # (Action, Priority)
|
||||||
(self._at_day_start, 0),
|
(self._at_day_start, 0),
|
||||||
(self._at_voted, 0),
|
(self._at_voted, 0),
|
||||||
(self._at_kill, 0),
|
(self._at_kill, 0),
|
||||||
(self._at_hang, 0),
|
(self._at_hang, 0),
|
||||||
(self._at_day_end, 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_night_end, 0),
|
||||||
(self._at_visit, 0)
|
(self._at_visit, 0)
|
||||||
]
|
]
|
||||||
self.killer = None # Added killer
|
|
||||||
|
|
||||||
# async def on_event(self, event, data):
|
# async def on_event(self, event, data):
|
||||||
# """
|
# """
|
||||||
@ -83,6 +82,7 @@ class VanillaWerewolf(Role):
|
|||||||
|
|
||||||
async def _at_game_start(self, data=None):
|
async def _at_game_start(self, data=None):
|
||||||
if self.channel_id:
|
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.game.register_channel(self.channel_id, self, WolfVote) # Add VoteGroup WolfVote
|
||||||
|
|
||||||
await self.player.send_dm(self.game_start_message)
|
await self.player.send_dm(self.game_start_message)
|
||||||
|
@ -35,7 +35,7 @@ class Werewolf:
|
|||||||
if ctx.invoked_subcommand is None:
|
if ctx.invoked_subcommand is None:
|
||||||
await ctx.send_help()
|
await ctx.send_help()
|
||||||
|
|
||||||
@guild_only()
|
@commands.guild_only()
|
||||||
@ww.command()
|
@ww.command()
|
||||||
async def new(self, ctx, game_code):
|
async def new(self, ctx, game_code):
|
||||||
"""
|
"""
|
||||||
@ -50,7 +50,7 @@ class Werewolf:
|
|||||||
await ctx.send("New game has started")
|
await ctx.send("New game has started")
|
||||||
|
|
||||||
|
|
||||||
@guild_only()
|
@commands.guild_only()
|
||||||
@ww.command()
|
@ww.command()
|
||||||
async def join(self, ctx):
|
async def join(self, ctx):
|
||||||
"""
|
"""
|
||||||
@ -65,7 +65,7 @@ class Werewolf:
|
|||||||
|
|
||||||
await game.join(ctx.author, ctx.channel)
|
await game.join(ctx.author, ctx.channel)
|
||||||
|
|
||||||
@guild_only()
|
@commands.guild_only()
|
||||||
@ww.command()
|
@ww.command()
|
||||||
async def quit(self, ctx):
|
async def quit(self, ctx):
|
||||||
"""
|
"""
|
||||||
@ -76,7 +76,7 @@ class Werewolf:
|
|||||||
|
|
||||||
await game.quit(ctx.author, ctx.channel)
|
await game.quit(ctx.author, ctx.channel)
|
||||||
|
|
||||||
@guild_only()
|
@commands.guild_only()
|
||||||
@ww.command()
|
@ww.command()
|
||||||
async def start(self, ctx):
|
async def start(self, ctx):
|
||||||
"""
|
"""
|
||||||
@ -88,7 +88,7 @@ class Werewolf:
|
|||||||
|
|
||||||
await game.setup(ctx)
|
await game.setup(ctx)
|
||||||
|
|
||||||
@guild_only()
|
@commands.guild_only()
|
||||||
@ww.command()
|
@ww.command()
|
||||||
async def stop(self, ctx):
|
async def stop(self, ctx):
|
||||||
"""
|
"""
|
||||||
@ -100,7 +100,7 @@ class Werewolf:
|
|||||||
|
|
||||||
game.game_over = True
|
game.game_over = True
|
||||||
|
|
||||||
@guild_only()
|
@commands.guild_only()
|
||||||
@ww.command()
|
@ww.command()
|
||||||
async def vote(self, ctx, id: int):
|
async def vote(self, ctx, id: int):
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user