Lots of pep8

fight-fixes
bobloy 7 years ago
parent a0c7337e0c
commit fd835844f8

@ -327,11 +327,11 @@ class Game:
status = ""
else:
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)
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):
"""
@ -397,7 +398,6 @@ class Game:
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):
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,13 +547,13 @@ 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:

@ -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

@ -75,7 +75,6 @@ class Role:
await self.action_list[event][0](data)
async def assign_player(self, player):
"""
Give this role a player

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

@ -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
@ -44,26 +45,26 @@ class WolfVote(VoteGroup):
# """
# 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))
#
# async def _at_day_start(self, data=None):
# pass
#
# async def _at_voted(self, data=None):
# pass
#
# async def _at_kill(self, data=None):
# 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"])
#
# async def _at_day_end(self, data=None):
# pass
@ -96,13 +97,13 @@ class WolfVote(VoteGroup):
# async def _at_visit(self, data=None):
# pass
#
# async def register_players(self, *players):
# """
# Extend players by passed list
# """
# self.players.extend(players)
#
# async def remove_player(self, player):
# """
# Remove a player from player list
@ -110,11 +111,11 @@ class WolfVote(VoteGroup):
# 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))

Loading…
Cancel
Save