You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Fox-V3/werewolf/Game.py

60 lines
1.4 KiB

import asyncio
import discord
from datetime import datetime,timedelta
from .builder import parse_code
class Game:
"""
Base to host a game of werewolf
"""
def __init__(self, role_code=None):
self.roles = []
self.role_code = role_code
if self.role_code:
self.get_roles()
self.players = []
self.start_vote = 0
self.started = False
async def setup(self, ctx):
"""
Runs the initial setup
"""
if self.role_code:
if not await self.get_roles():
if not self.roles:
ctx.send("No game code set, cannot start until this is set")
async def join(self, member: discord.Member):
"""
Joins a game
"""
if self.started:
return "**Game has already started!**"
if member in self.players:
return "{} is already in the game!".format(member.mention)
self.started.append(member)
return "{} has been added to the game, total players is **{}**".format(member.mention, len(self.players))
async def get_roles(self, role_code=None):
if role_code:
self.role_code=role_code
if not self.role_code:
return False
self.roles = await parse_code(self.role_code)
if not self.roles:
return False