diff --git a/werewolf/game.py b/werewolf/game.py index 534aea2..1dfce9a 100644 --- a/werewolf/game.py +++ b/werewolf/game.py @@ -324,14 +324,14 @@ class Game: for i in range(len(self.players)): player = self.players[i] if player.alive: - status="" + status = "" else: - status="*Dead*" - embed.add_field(name="ID# **{}**".format(i), value="{} {}".format(status, player.member.display_name), inline=True) + status = "*Dead*" + embed.add_field(name="ID# **{}**".format(i), + value="{} {}".format(status, player.member.display_name), inline=True) return await channel.send(embed=embed) - - + async def register_channel(self, channel_id, role, votegroup=None): """ Queue a channel to be created by game_start @@ -360,7 +360,8 @@ class Game: self.players.append(Player(member)) - await channel.send("{} has been added to the game, total players is **{}**".format(member.mention, len(self.players))) + await channel.send("{} has been added to the game, " + "total players is **{}**".format(member.mention, len(self.players))) async def quit(self, member: discord.Member, channel: discord.TextChannel = None): """ @@ -396,8 +397,7 @@ class Game: if player.role.blocked: await ctx.send("Something is preventing you from doing this...") return - - + # Let role do target validation, might be alternate targets # I.E. Go on alert? y/n @@ -419,7 +419,7 @@ class Game: await self._visit(target, source) return target - async def vote(self, author, id, channel): + async def vote(self, author, target_id, channel): """ Member attempts to cast a vote (usually to lynch) Also used in vote groups @@ -446,7 +446,7 @@ class Game: return try: - target = self.players[id] + target = self.players[target_id] except IndexError: target = None @@ -456,39 +456,42 @@ class Game: # Now handle village vote or send to votegroup if channel == self.village_channel: - await self._village_vote(target, author, id) + await self._village_vote(target, author, target_id) 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, target_id) else: # Somehow previous check failed await channel.send("Cannot vote in this channel") return - async def _village_vote(self, target, author, id): + async def _village_vote(self, target, author, target_id): if author in self.day_vote: self.vote_totals[self.day_vote[author]] -= 1 - self.day_vote[author] = id - if id not in self.vote_totals: - self.vote_totals[id] = 1 + self.day_vote[author] = target_id + if target_id not in self.vote_totals: + self.vote_totals[target_id] = 1 else: - self.vote_totals[id] += 1 + self.vote_totals[target_id] += 1 required_votes = len([player for player in self.players if player.alive]) // 7 + 2 - if self.vote_totals[id] < required_votes: - await self.village_channel.send("{} has voted to put {} to trial. {} more votes needed".format(author.mention, target.member.mention, required_votes - self.vote_totals[id])) + if self.vote_totals[target_id] < required_votes: + await self.village_channel.send("" + "{} has voted to put {} to trial. " + "{} more votes needed".format(author.mention, + target.member.mention, + required_votes - self.vote_totals[target_id])) else: - self.vote_totals[id] = 0 - self.day_vote = {k:v for k,v in self.day_vote.items() if v != id} # Remove votes for this id + self.vote_totals[target_id] = 0 + self.day_vote = {k: v for k, v in self.day_vote.items() if v != target_id} # Remove votes for this id await self._at_voted(target) - - - async def eval_results(self, target, source=None, method = None): + + async def eval_results(self, target, source=None, method=None): if method is not None: out = "**{ID}** - " + method return out.format(ID=target.id, target=target.member.display_name) else: - return "**{ID}** - {} was found dead".format(ID=target.id, target=target.member.display_name) + return "**{ID}** - {target} was found dead".format(ID=target.id, target=target.member.display_name) async def _quit(self, player): """ @@ -498,7 +501,7 @@ class Game: player.alive = False await self._at_kill(player) player.alive = False # Do not allow resurrection - await self.dead_perms(player.member) + 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): @@ -531,7 +534,7 @@ class Game: if not target.alive: # Still dead after notifying if not self.day_time: self.night_results.append(await self.eval_results(target, source, method)) - await self.dead_perms(target.member) + await self.dead_perms(self.village_channel, target.member) else: target.protected = False @@ -544,17 +547,17 @@ class Game: target.alive = False await self._at_hang(target) if not target.alive: # Still dead after notifying - await self.dead_perms(target.member) + await self.dead_perms(self.village_channel, target.member) async def get_night_target(self, target_id, source=None): return self.players[target_id] # For now async def get_day_target(self, target_id, source=None): - return self.player[target_id] # For now + return self.players[target_id] # For now async def get_roles(self, game_code=None): if game_code is not None: - self.game_code=game_code + self.game_code = game_code if self.game_code is None: return False @@ -607,9 +610,9 @@ class Game: await channel.set_permissions(member, read_messages=True) async def _check_game_over(self): - #ToDo + # ToDo pass async def _end_game(self): - #ToDo + # ToDo pass diff --git a/werewolf/player.py b/werewolf/player.py index a90a8be..df19c28 100644 --- a/werewolf/player.py +++ b/werewolf/player.py @@ -24,8 +24,8 @@ class Player: role.player = self self.role = role - async def assign_id(self, id): - self.id = id + async def assign_id(self, target_id): + self.id = target_id async def send_dm(self, message): await self.member.send(message) # Lets do embeds later diff --git a/werewolf/role.py b/werewolf/role.py index a0c692b..6187830 100644 --- a/werewolf/role.py +++ b/werewolf/role.py @@ -44,7 +44,7 @@ class Role: alignment = 0 # 1: Town, 2: Werewolf, 3: Neutral channel_id = "" # Empty for no private channel unique = False # Only one of this role per game - game_start_message= ( + game_start_message = ( "Your role is **Default**\n" "You win by testing the game\n" "Lynch players during the day with `[p]ww vote `" @@ -74,7 +74,6 @@ class Role: """ await self.action_list[event][0](data) - async def assign_player(self, player): """ @@ -161,4 +160,4 @@ class Role: async def choose(self, ctx, data): """Handle night actions""" - pass \ No newline at end of file + pass diff --git a/werewolf/votegroup.py b/werewolf/votegroup.py index d78cee8..2fcb0ec 100644 --- a/werewolf/votegroup.py +++ b/werewolf/votegroup.py @@ -2,8 +2,6 @@ import asyncio import discord -import random - class VoteGroup: """ diff --git a/werewolf/votegroups/wolfvote.py b/werewolf/votegroups/wolfvote.py index b5e6bb5..99a8124 100644 --- a/werewolf/votegroups/wolfvote.py +++ b/werewolf/votegroups/wolfvote.py @@ -20,11 +20,12 @@ class WolfVote(VoteGroup): "**{ID}** - {target} was found torn to shreds"] def __init__(self, game, channel): - self.game = game - self.channel = channel - self.players = [] - self.vote_results = {} - self.properties = {} # Extra data for other options + super().__init__(game, channel) + # self.game = game + # self.channel = channel + # self.players = [] + # self.vote_results = {} + # self.properties = {} # Extra data for other options self.killer = None # Added killer @@ -41,31 +42,31 @@ class WolfVote(VoteGroup): ] # async def on_event(self, event, data): - # """ - # See Game class for event guide - # """ - - # await action_list[event][0](data) - + # """ + # See Game class for event guide + # """ + # + # await action_list[event][0](data) + # # async def _at_game_start(self, data=None): - # await self.channel.send(" ".join(player.mention for player in self.players)) - + # await self.channel.send(" ".join(player.mention for player in self.players)) + # # async def _at_day_start(self, data=None): - # pass - + # pass + # # async def _at_voted(self, data=None): - # pass - + # pass + # # async def _at_kill(self, data=None): - # if data["player"] in self.players: - # self.players.pop(data["player"]) - + # if data["player"] in self.players: + # self.players.pop(data["player"]) + # # async def _at_hang(self, data=None): - # if data["player"] in self.players: - # self.players.pop(data["player"]) - + # if data["player"] in self.players: + # self.players.pop(data["player"]) + # # async def _at_day_end(self, data=None): - # pass + # pass async def _at_night_start(self, data=None): if self.channel is None: @@ -95,26 +96,26 @@ class WolfVote(VoteGroup): await self.channel.send("**No kill will be attempted tonight...**") # async def _at_visit(self, data=None): - # pass - + # pass + # # async def register_players(self, *players): - # """ - # Extend players by passed list - # """ - # self.players.extend(players) - + # """ + # Extend players by passed list + # """ + # self.players.extend(players) + # # async def remove_player(self, player): - # """ - # Remove a player from player list - # """ - # if player.id in self.players: - # self.players.remove(player) + # """ + # Remove a player from player list + # """ + # if player.id in self.players: + # self.players.remove(player) - async def vote(self, target, author, id): + async def vote(self, target, author, target_id): """ Receive vote from game """ - self.vote_results[author.id] = id + self.vote_results[author.id] = target_id await self.channel.send("{} has voted to kill {}".format(author.mention, target.member.display_name))