Lots of pep8

fight-fixes
bobloy 7 years ago
parent a0c7337e0c
commit fd835844f8

@ -324,14 +324,14 @@ class Game:
for i in range(len(self.players)): for i in range(len(self.players)):
player = self.players[i] player = self.players[i]
if player.alive: if player.alive:
status="" status = ""
else: else:
status="*Dead*" status = "*Dead*"
embed.add_field(name="ID# **{}**".format(i), value="{} {}".format(status, player.member.display_name), inline=True) embed.add_field(name="ID# **{}**".format(i),
value="{} {}".format(status, player.member.display_name), inline=True)
return await channel.send(embed=embed) return await channel.send(embed=embed)
async def register_channel(self, channel_id, role, votegroup=None): async def register_channel(self, channel_id, role, votegroup=None):
""" """
Queue a channel to be created by game_start Queue a channel to be created by game_start
@ -360,7 +360,8 @@ class Game:
self.players.append(Player(member)) 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): async def quit(self, member: discord.Member, channel: discord.TextChannel = None):
""" """
@ -396,8 +397,7 @@ class Game:
if player.role.blocked: if player.role.blocked:
await ctx.send("Something is preventing you from doing this...") await ctx.send("Something is preventing you from doing this...")
return return
# Let role do target validation, might be alternate targets # Let role do target validation, might be alternate targets
# I.E. Go on alert? y/n # I.E. Go on alert? y/n
@ -419,7 +419,7 @@ class Game:
await self._visit(target, source) await self._visit(target, source)
return target 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) Member attempts to cast a vote (usually to lynch)
Also used in vote groups Also used in vote groups
@ -446,7 +446,7 @@ class Game:
return return
try: try:
target = self.players[id] target = self.players[target_id]
except IndexError: except IndexError:
target = None target = None
@ -456,39 +456,42 @@ class Game:
# Now handle village vote or send to votegroup # Now handle village vote or send to votegroup
if channel == self.village_channel: 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: 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 else: # Somehow previous check failed
await channel.send("Cannot vote in this channel") await channel.send("Cannot vote in this channel")
return return
async def _village_vote(self, target, author, id): async def _village_vote(self, target, author, target_id):
if author in self.day_vote: if author in self.day_vote:
self.vote_totals[self.day_vote[author]] -= 1 self.vote_totals[self.day_vote[author]] -= 1
self.day_vote[author] = id self.day_vote[author] = target_id
if id not in self.vote_totals: if target_id not in self.vote_totals:
self.vote_totals[id] = 1 self.vote_totals[target_id] = 1
else: 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 required_votes = len([player for player in self.players if player.alive]) // 7 + 2
if self.vote_totals[id] < required_votes: 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[id])) 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: else:
self.vote_totals[id] = 0 self.vote_totals[target_id] = 0
self.day_vote = {k:v for k,v in self.day_vote.items() if v != id} # Remove votes for this id 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) 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: if method is not None:
out = "**{ID}** - " + method out = "**{ID}** - " + method
return out.format(ID=target.id, target=target.member.display_name) return out.format(ID=target.id, target=target.member.display_name)
else: 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): async def _quit(self, player):
""" """
@ -498,7 +501,7 @@ class Game:
player.alive = False player.alive = False
await self._at_kill(player) await self._at_kill(player)
player.alive = False # Do not allow resurrection 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 # 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):
@ -531,7 +534,7 @@ class Game:
if not target.alive: # Still dead after notifying if not target.alive: # Still dead after notifying
if not self.day_time: if not self.day_time:
self.night_results.append(await self.eval_results(target, source, method)) 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: else:
target.protected = False target.protected = False
@ -544,17 +547,17 @@ class Game:
target.alive = False target.alive = False
await self._at_hang(target) await self._at_hang(target)
if not target.alive: # Still dead after notifying 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): async def get_night_target(self, target_id, source=None):
return self.players[target_id] # For now return self.players[target_id] # For now
async def get_day_target(self, target_id, source=None): 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): async def get_roles(self, game_code=None):
if game_code is not None: if game_code is not None:
self.game_code=game_code self.game_code = game_code
if self.game_code is None: if self.game_code is None:
return False return False
@ -607,9 +610,9 @@ class Game:
await channel.set_permissions(member, read_messages=True) await channel.set_permissions(member, read_messages=True)
async def _check_game_over(self): async def _check_game_over(self):
#ToDo # ToDo
pass pass
async def _end_game(self): async def _end_game(self):
#ToDo # ToDo
pass pass

@ -24,8 +24,8 @@ class Player:
role.player = self role.player = self
self.role = role self.role = role
async def assign_id(self, id): async def assign_id(self, target_id):
self.id = id self.id = target_id
async def send_dm(self, message): async def send_dm(self, message):
await self.member.send(message) # Lets do embeds later await self.member.send(message) # Lets do embeds later

@ -44,7 +44,7 @@ class Role:
alignment = 0 # 1: Town, 2: Werewolf, 3: Neutral alignment = 0 # 1: Town, 2: Werewolf, 3: Neutral
channel_id = "" # Empty for no private channel channel_id = "" # Empty for no private channel
unique = False # Only one of this role per game unique = False # Only one of this role per game
game_start_message= ( game_start_message = (
"Your role is **Default**\n" "Your role is **Default**\n"
"You win by testing the game\n" "You win by testing the game\n"
"Lynch players during the day with `[p]ww vote <ID>`" "Lynch players during the day with `[p]ww vote <ID>`"
@ -74,7 +74,6 @@ class Role:
""" """
await self.action_list[event][0](data) await self.action_list[event][0](data)
async def assign_player(self, player): async def assign_player(self, player):
""" """
@ -161,4 +160,4 @@ class Role:
async def choose(self, ctx, data): async def choose(self, ctx, data):
"""Handle night actions""" """Handle night actions"""
pass pass

@ -2,8 +2,6 @@ import asyncio
import discord import discord
import random
class VoteGroup: class VoteGroup:
""" """

@ -20,11 +20,12 @@ class WolfVote(VoteGroup):
"**{ID}** - {target} was found torn to shreds"] "**{ID}** - {target} was found torn to shreds"]
def __init__(self, game, channel): def __init__(self, game, channel):
self.game = game super().__init__(game, channel)
self.channel = channel # self.game = game
self.players = [] # self.channel = channel
self.vote_results = {} # self.players = []
self.properties = {} # Extra data for other options # self.vote_results = {}
# self.properties = {} # Extra data for other options
self.killer = None # Added killer self.killer = None # Added killer
@ -41,31 +42,31 @@ class WolfVote(VoteGroup):
] ]
# async def on_event(self, event, data): # async def on_event(self, event, data):
# """ # """
# See Game class for event guide # See Game class for event guide
# """ # """
#
# await action_list[event][0](data) # await action_list[event][0](data)
#
# async def _at_game_start(self, data=None): # 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): # async def _at_day_start(self, data=None):
# pass # pass
#
# async def _at_voted(self, data=None): # async def _at_voted(self, data=None):
# pass # pass
#
# async def _at_kill(self, data=None): # async def _at_kill(self, data=None):
# if data["player"] in self.players: # if data["player"] in self.players:
# self.players.pop(data["player"]) # self.players.pop(data["player"])
#
# async def _at_hang(self, data=None): # async def _at_hang(self, data=None):
# if data["player"] in self.players: # if data["player"] in self.players:
# self.players.pop(data["player"]) # self.players.pop(data["player"])
#
# async def _at_day_end(self, data=None): # async def _at_day_end(self, data=None):
# pass # pass
async def _at_night_start(self, data=None): async def _at_night_start(self, data=None):
if self.channel is None: if self.channel is None:
@ -95,26 +96,26 @@ class WolfVote(VoteGroup):
await self.channel.send("**No kill will be attempted tonight...**") await self.channel.send("**No kill will be attempted tonight...**")
# async def _at_visit(self, data=None): # async def _at_visit(self, data=None):
# pass # pass
#
# async def register_players(self, *players): # async def register_players(self, *players):
# """ # """
# Extend players by passed list # Extend players by passed list
# """ # """
# self.players.extend(players) # self.players.extend(players)
#
# async def remove_player(self, player): # async def remove_player(self, player):
# """ # """
# Remove a player from player list # Remove a player from player list
# """ # """
# if player.id in self.players: # if player.id in self.players:
# self.players.remove(player) # self.players.remove(player)
async def vote(self, target, author, id): async def vote(self, target, author, target_id):
""" """
Receive vote from game 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)) await self.channel.send("{} has voted to kill {}".format(author.mention, target.member.display_name))

Loading…
Cancel
Save