Commit bfccf5bf authored by Ferdinand Schober's avatar Ferdinand Schober 💬
Browse files

asdf

parent 1faac010
......@@ -4,12 +4,7 @@ from pprint import pprint
from discord.ext import commands
client = commands.Bot(command_prefix='.')
#client.load_extension('village_commands')
client.load_extension('werewolf_commands')
#client.load_extension('seer_commands')
#client.load_extension('witch_commands')
#client.load_extension('amor_commands')
client.load_extension('utility_commands')
client.run('Njk2MTEyNTQ1MDgxMDY1NTU0.Xoj_iQ.VXMY9AUo56o_k-QgLSUWtPldhjE')
\ No newline at end of file
import werewolf_roles
import random
import random
import asyncio
async def start(ctx, _players, _channels, _server_roles):
global role, players, channels, server_roles
......@@ -9,13 +10,12 @@ async def start(ctx, _players, _channels, _server_roles):
server_roles = _server_roles
await ctx.send(f'starting new game with {[member.mention for member in players]}')
await set_night()
def is_alive(player):
return player in players
def get_role(player):
return role[player]
l = list()
for player in players:
l.append(asyncio.create_task(player.add_roles([server_roles['alive']])))
for t in l:
await t
async def check_time_state():
if tasks == {}:
if state == 'day':
......@@ -24,19 +24,29 @@ async def check_time_state():
await set_day()
async def set_night():
global state, tasks, werewolf_votes
global state, tasks, werewolf_votes, killed
state = 'night'
tasks = { task for task in [tasks for tasks in [role[player]['tasks'] for player in players]]}
werewolf_votes = dict()
await channels['village_channel'].send('Wieder mal wird es dunkel im Düsterwald und das Dorf schläft ein...')
killed = dict()
await channels['village'].send('Wieder mal wird es dunkel im Düsterwald und das Dorf schläft ein...')
def check_killed():
global killed
tmp = killed.values()
for killed in tmp:
players.remove(killed)
return tmp
async def set_day():
dead = await check_killed()
await channels['village'].send(f'Das Dorf erwacht ... ohne {[p.mention for p in dead]}')
global state, accusations, votes, tasks
state = 'day'
accusations = set()
votes = dict()
tasks = {'accusation'}
await channels['village_channel'].send('Das Dorf erwacht...\n'
await channels['village'].send('Das Dorf erwacht...\n'
'Die Anklage ist eröffnet!\n'
'\n'
'Um eine Person anzuklagen schreibe $accuse @name!\n'
......@@ -91,8 +101,8 @@ async def werewolf_vote(ctx, player):
if werewolf_votes.keys() == { p for p in players if role[p] == werewolf_roles.werwolf }: #all werewolfs have submitted their vote
if len(set(werewolf_votes.values())) == 1: #all votes are equal
tasks.remove('werewolfs')
global werewolf_victim
werewolf_victim = list(werewolf_votes.values())[0]
global killed
killed['werewolfs'] = list(werewolf_votes.values())[0]
await notify_werewolf_vote()
async def see(ctx, player):
......@@ -105,10 +115,16 @@ async def see(ctx, player):
async def heal(ctx, player):
if 'heal' in tasks:
global werewolf_victim
healed = werewolf_victim
werewolf_victim = None
global killed
healed = killed['werewolfs']
del killed['werewolfs']
await ctx.send(f'{healed.mention} wurde geheilt!')
tasks.remove('heal')
async def poison(ctx, player):
if 'poison' in tasks:
if player in players:
killed['witch'] = player
async def notify_werewolf_vote():
pass
\ No newline at end of file
import asyncio
import discord
from discord.ext import commands
import game
......@@ -8,25 +9,29 @@ class Werewolf(commands.Cog):
async def log(self, message):
print(message)
await self.channels['info_channel'].send(message)
await self.channels['info'].send(message)
@commands.Cog.listener()
async def on_ready(self):
self.channels = {
'welcome_channel': await self.client.fetch_channel(696079221684175005),
'lobby_channel': await self.client.fetch_channel(696130304884211733),
'village_channel': await self.client.fetch_channel(696105930336632963),
'info_channel': await self.client.fetch_channel(696130399860162626),
'werewolf_channel': await self.client.fetch_channel(696323465195683891),
'couple_channel': await self.client.fetch_channel(696323604605960213),
'witch_channel': await self.client.fetch_channel(696776678541623336),
'seer_channel': await self.client.fetch_channel(696776695146872872),
'welcome': asyncio.create_task(self.client.fetch_channel(696079221684175005)),
'lobby': asyncio.create_task(self.client.fetch_channel(696130304884211733)),
'village': asyncio.create_task(self.client.fetch_channel(696105930336632963)),
'info': asyncio.create_task(self.client.fetch_channel(696130399860162626)),
'werewolf': asyncio.create_task(self.client.fetch_channel(696323465195683891)),
'couple': asyncio.create_task(self.client.fetch_channel(696323604605960213)),
'witch': asyncio.create_task(self.client.fetch_channel(696776678541623336)),
'seer': asyncio.create_task(self.client.fetch_channel(696776695146872872)),
}
self.server = await self.client.fetch_guild(696079221684175001)
self.server_roles = {
'alive': await self.server.get_role(697048340889731134),
'dead': await self.server.get_role(697048466978897990)
'alive': asyncio.create_task(self.server.get_role(697048340889731134)),
'dead': asyncio.create_task(self.server.get_role(697048466978897990))
}
for v in self.channels.values():
await v
for v in self.server_roles.values():
await v
@commands.Cog.listener()
async def on_message(self, message):
......@@ -39,46 +44,39 @@ class Werewolf(commands.Cog):
@commands.command()
async def start(self, ctx):
await ctx.message.delete()
if ctx.channel == self.channels['village_channel']:
await game.start(ctx, set(self.channels['lobby_channel'].members), self.channels, self.server_roles)
if ctx.channel == self.channels['village']:
await game.start(ctx, set(self.channels['lobby'].members), self.channels, self.server_roles)
@commands.command()
async def accuse(self, ctx, *, player: discord.Member):
await ctx.message.delete()
if ctx.message.channel == self.channels['village_channel']:
if ctx.message.channel == self.channels['village']:
await game.accuse(ctx, player)
@commands.command()
async def withdraw(self, ctx, *, player: discord.Member):
await ctx.message.delete()
if ctx.channel == self.channels['village_channel']:
if ctx.channel == self.channels['village']:
await game.withdraw(ctx, player)
@commands.command()
async def confirm(self, ctx):
await ctx.message.delete()
if ctx.channel == self.channels['village_channel']:
if ctx.channel == self.channels['village']:
await game.confirm_accusations(ctx)
@commands.command()
async def vote(self, ctx, *, player: discord.Member):
await ctx.message.delete()
if ctx.channel == self.channels['village_channel']:
if ctx.channel == self.channels['village']:
await game.citizen_vote(ctx, player)
elif ctx.channel == self.channels['werewolf_channel']:
elif ctx.channel == self.channels['werewolf']:
await game.werewolf_vote(ctx, player)
@commands.command()
async def see(self, ctx, *, player: discord.Member):
await ctx.message.delete()
if ctx.channel == self.channels['seer_channel']:
if ctx.channel == self.channels['seer']:
await game.see(ctx, player)
@commands.command()
async def heal(self, ctx, player: discord.Member):
await ctx.message.delete()
if ctx.channel == self.channels['witch_channel']:
if ctx.channel == self.channels['witch']:
await game.heal(ctx, player)
@commands.command()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment