🐺
This commit is contained in:
@ -72,23 +72,44 @@ class Werewolf():
|
|||||||
else:
|
else:
|
||||||
return "There's no game going on right now"
|
return "There's no game going on right now"
|
||||||
|
|
||||||
|
def allotRoles(self,channel):
|
||||||
|
game = self.bot.database["werewolf games"].find_one({"_id":channel})
|
||||||
|
players = len(game["users"])
|
||||||
|
|
||||||
async def werewolfLoop(self,ctx,round):
|
async def werewolfLoop(self,ctx,round):
|
||||||
logThis(f"Starting loop {round} of Werewolf game")
|
logThis(f"Starting loop {round} of Werewolf game")
|
||||||
channel = "#"+str(ctx.channel.id)
|
channel = "#"+str(ctx.channel.id)
|
||||||
if round == 0:
|
if round == 0:
|
||||||
await asyncio.sleep(120)
|
await asyncio.sleep(90)
|
||||||
|
|
||||||
game = self.bot.database["werewolf games"].find_one({"_id":channel})
|
game = self.bot.database["werewolf games"].find_one({"_id":channel})
|
||||||
while len(game["users"].keys()) >= minimumPlayers and len(game["users"].keys()) < minimumPlayersWithAI:
|
if len(game["users"].keys()) >= minimumPlayers:
|
||||||
|
while len(game["users"].keys()) < minimumPlayersWithAI:
|
||||||
user = {"role": None}
|
user = {"role": None}
|
||||||
self.bot.database["werewolf games"].update_one({"_id":"#"+str(ctx.channel.id)},
|
self.bot.database["werewolf games"].update_one({"_id":"#"+str(ctx.channel.id)},
|
||||||
{"$set":{"users."+self.bot.generator.nameGen():user}})
|
{"$set":{"users."+self.bot.generator.nameGen()[:-1]+" (AI player)":user}})
|
||||||
game = self.bot.database["werewolf games"].find_one({"_id":channel})
|
game = self.bot.database["werewolf games"].find_one({"_id":channel})
|
||||||
|
|
||||||
|
if game["current message"] != None:
|
||||||
|
await ctx.channel.fetch_message(game["current message"]).delete()
|
||||||
|
users = ""
|
||||||
|
for x, user in enumerate(list(game["users"].keys())):
|
||||||
|
users += str(x+1)+") "+self.bot.funcs.getName(user)+"\n"
|
||||||
|
|
||||||
|
em = discord.Embed(title="Game started with the following players:",description=users,colour=0x00FF00)
|
||||||
|
oldMessage = await ctx.send(embed=em)
|
||||||
|
|
||||||
|
self.bot.database["werewolf games"].update_one({"_id":channel},{"$set":{"current message":oldMessage.id}})
|
||||||
|
|
||||||
|
self.allotRoles(channel)
|
||||||
|
|
||||||
self.bot.database["werewolf games"].update_one({"_id":channel},{"$inc":{"round":1}})
|
self.bot.database["werewolf games"].update_one({"_id":channel},{"$inc":{"round":1}})
|
||||||
await self.werewolfLoop(ctx,round+1)
|
await self.werewolfLoop(ctx,round+1)
|
||||||
else:
|
else:
|
||||||
await asyncio.sleep(60)
|
ctx.send("Not enough players. Ending game.")
|
||||||
|
self.werewolfStop("#"+str(ctx.channel.id))
|
||||||
|
else:
|
||||||
|
await asyncio.sleep(30)
|
||||||
|
|
||||||
|
|
||||||
async def werewolfJoin(self,ctx):
|
async def werewolfJoin(self,ctx):
|
||||||
@ -130,4 +151,5 @@ class Werewolf():
|
|||||||
if len(list(game["users"].keys())) < minimumPlayers:
|
if len(list(game["users"].keys())) < minimumPlayers:
|
||||||
users += f"You need at least {minimumPlayers} players to play werewolf."
|
users += f"You need at least {minimumPlayers} players to play werewolf."
|
||||||
em = discord.Embed(title="Current Players",description=users,colour=0x00FF00)
|
em = discord.Embed(title="Current Players",description=users,colour=0x00FF00)
|
||||||
await ctx.send(embed=em)
|
oldMessage = await ctx.send(embed=em)
|
||||||
|
self.bot.database["werewolf games"].update_one({"_id":"#"+str(ctx.channel.id)},{"$set":{"current message":oldMessage.id}})
|
||||||
|
Reference in New Issue
Block a user