Merge pull request #2 from NikolajDanger/remove-developing
Removed everything currently in development.
This commit is contained in:
@ -88,11 +88,6 @@ class GamesCog(commands.Cog):
|
|||||||
async def fourinarow(self, ctx, *, content = ""):
|
async def fourinarow(self, ctx, *, content = ""):
|
||||||
await self.bot.gameLoops.fiar(ctx.message.channel,content,"#"+str(ctx.message.author.id))
|
await self.bot.gameLoops.fiar(ctx.message.channel,content,"#"+str(ctx.message.author.id))
|
||||||
|
|
||||||
# Runs a game of Monopoly
|
|
||||||
@commands.command(aliases = ["m","mon","mono"])
|
|
||||||
async def monopoly(self, ctx, *, content = ""):
|
|
||||||
await self.bot.gameLoops.runMonopoly(ctx.message.channel,content,"#"+str(ctx.message.author.id))
|
|
||||||
|
|
||||||
# Runs a game of Hangman
|
# Runs a game of Hangman
|
||||||
@commands.command(aliases = ["hm"])
|
@commands.command(aliases = ["hm"])
|
||||||
async def hangman(self, ctx, *, content = "start"):
|
async def hangman(self, ctx, *, content = "start"):
|
||||||
@ -103,15 +98,5 @@ class GamesCog(commands.Cog):
|
|||||||
async def hexCommand(self, ctx, *, content = ""):
|
async def hexCommand(self, ctx, *, content = ""):
|
||||||
await self.bot.gameLoops.runHex(ctx.message.channel,content,"#"+str(ctx.message.author.id))
|
await self.bot.gameLoops.runHex(ctx.message.channel,content,"#"+str(ctx.message.author.id))
|
||||||
|
|
||||||
# Runs a game of Love Letter
|
|
||||||
@commands.command(aliases = ["ll"])
|
|
||||||
async def loveletter(self, ctx, *, content = ""):
|
|
||||||
await self.bot.gameLoops.runLoveletter(ctx.message.channel,content,"#"+str(ctx.message.author.id),ctx.message.author)
|
|
||||||
|
|
||||||
# Runs a game of Werewolf
|
|
||||||
@commands.command()
|
|
||||||
async def werewolf(self,ctx, *,content = "start"):
|
|
||||||
await self.bot.werewolf.parseWerewolf(ctx,content.lower())
|
|
||||||
|
|
||||||
def setup(bot):
|
def setup(bot):
|
||||||
bot.add_cog(GamesCog(bot))
|
bot.add_cog(GamesCog(bot))
|
@ -1,81 +0,0 @@
|
|||||||
import random
|
|
||||||
|
|
||||||
from funcs import logThis
|
|
||||||
from .loveletterDraw import DrawLove
|
|
||||||
|
|
||||||
class LoveLetter():
|
|
||||||
def __init__(self,bot):
|
|
||||||
self.bot = bot
|
|
||||||
self.draw = DrawLove(bot)
|
|
||||||
|
|
||||||
# Parses command
|
|
||||||
def parseLove(self, command, channel, user, userchannel):
|
|
||||||
commands = command.lower().split()
|
|
||||||
game = self.bot.database["loveletter games"].find_one({"_id":channel})
|
|
||||||
|
|
||||||
if command == "" or command == " ":
|
|
||||||
logThis(str(user)+" created a Love Letter game with loveStart(). ")
|
|
||||||
return self.loveStart(channel)
|
|
||||||
|
|
||||||
# If using a command with no game, return error
|
|
||||||
elif game == None:
|
|
||||||
return "There's no game in this channel", False, False
|
|
||||||
|
|
||||||
# Joining the game
|
|
||||||
elif commands[0] == "join":
|
|
||||||
if game["round"] == 0:
|
|
||||||
if user not in game["player hands"]:
|
|
||||||
# Deal cards
|
|
||||||
card = game["deck"].pop()
|
|
||||||
username = self.bot.funcs.getName(user)
|
|
||||||
game["player hands"][username] = card
|
|
||||||
game["discard piles"][username] = []
|
|
||||||
game["user channel"][username] = userchannel # Used for direct (private) messages to the users
|
|
||||||
self.bot.database["loveletter games"].replace_one({"_id":channel},game)
|
|
||||||
return username+" joined the game! Type \"!loveletter begin\" once all players have joined.", False, False
|
|
||||||
else:
|
|
||||||
return "You're already playing!", False, False
|
|
||||||
else:
|
|
||||||
return "It's too late to join", False, False
|
|
||||||
|
|
||||||
# Beginning the game
|
|
||||||
elif commands[0] == "begin":
|
|
||||||
if user in game["player hands"]:
|
|
||||||
if len(game["player hands"]) > 1:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
return "AI functionality hasn't been implemented yet. Get another player to join!", False, False
|
|
||||||
else:
|
|
||||||
return "You can't begin a game, when you're not a player!", False, False
|
|
||||||
|
|
||||||
# Stopping the game
|
|
||||||
elif commands[0] == "stop":
|
|
||||||
if user in game["player hands"]:
|
|
||||||
return "Ending game.", False, False
|
|
||||||
else:
|
|
||||||
return "You can't end a game where you're not a player.", False, False
|
|
||||||
|
|
||||||
else:
|
|
||||||
return "I didn't get that. Use \"!loveletter\" to start a game or \"!loveletter join\" to join a game. ", False, False
|
|
||||||
|
|
||||||
# Starts the game
|
|
||||||
def loveStart(self, channel):
|
|
||||||
game = self.bot.database["loveletter games"].find_one({"_id":channel})
|
|
||||||
|
|
||||||
if game == None:
|
|
||||||
|
|
||||||
|
|
||||||
deck = [1,1,1,1,1, 2,2, 3,3, 4,4, 5,5, 6, 7, 8]
|
|
||||||
random.shuffle(deck)
|
|
||||||
cardAside = deck[0]
|
|
||||||
del deck[0] # The card that is set aside
|
|
||||||
|
|
||||||
newGame = {"_id":channel,"player hands": {},"discard piles":{},"deck":deck,"round":0,"cardAside":cardAside}
|
|
||||||
|
|
||||||
self.bot.database["loveletter games"].insert_one(newGame)
|
|
||||||
|
|
||||||
return ""
|
|
||||||
else:
|
|
||||||
logThis("There's already a Love Letter game going on in this channel",str(channel))
|
|
||||||
return "There's already a Love Letter game going on in this channel"
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
|||||||
import math
|
|
||||||
|
|
||||||
from PIL import Image, ImageDraw, ImageFont
|
|
||||||
from funcs import logThis
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class DrawLove():
|
|
||||||
def __init__(self,bot):
|
|
||||||
self.bot = bot
|
|
||||||
|
|
||||||
def drawBoard(self, channel):
|
|
||||||
logThis("Drawing empty Hex board")
|
|
@ -1,144 +0,0 @@
|
|||||||
import random
|
|
||||||
|
|
||||||
from funcs import logThis
|
|
||||||
from .monopolyDraw import DrawMonopoly
|
|
||||||
|
|
||||||
rulesAndTerms = {
|
|
||||||
"pass go money" : 200,
|
|
||||||
"money term" : "GP"
|
|
||||||
}
|
|
||||||
|
|
||||||
class Monopoly():
|
|
||||||
def __init__(self, bot):
|
|
||||||
self.bot = bot
|
|
||||||
self.draw = DrawMonopoly(bot)
|
|
||||||
|
|
||||||
def monopolyStart(self, channel):
|
|
||||||
logThis("Starting a monopoly game")
|
|
||||||
game = self.bot.database["monopoly games"].find_one({"_id":channel})
|
|
||||||
|
|
||||||
if game == None:
|
|
||||||
buildings = [0] * 40
|
|
||||||
|
|
||||||
newGame = {"_id":channel,"players" : {}, "player list" : [],"turn" : 0, "buildings" : buildings, "last roll" : [0,0], "started" : False}
|
|
||||||
|
|
||||||
self.bot.database["monopoly games"].insert_one(newGame)
|
|
||||||
|
|
||||||
#try:
|
|
||||||
self.draw.drawImage(channel)
|
|
||||||
#except:
|
|
||||||
# logThis("Error drawing board (error code 1640)")
|
|
||||||
|
|
||||||
return "Started a monopoly game. Use \"!monopoly join\" to join within the next minute.", True, False, True, True
|
|
||||||
else:
|
|
||||||
return "There's already a monopoly game going on.", False, False, False, False
|
|
||||||
|
|
||||||
def monopolyJoin(self,channel,user):
|
|
||||||
game = self.bot.database["monopoly games"].find_one({"_id":channel})
|
|
||||||
|
|
||||||
if game != None:
|
|
||||||
if not game["started"]:
|
|
||||||
if user not in game["players"]:
|
|
||||||
if len(game["players"]) < 6:
|
|
||||||
|
|
||||||
newPlayer = {"position" : 0, "properties" : [], "money" : 1500, "doubles" : 0}
|
|
||||||
|
|
||||||
self.bot.database["monopoly games"].update_one({"_id":channel},{"$set":{"players."+user:newPlayer}})
|
|
||||||
|
|
||||||
return self.bot.funcs.getName(user)+" has joined the game.", False, False, False, False
|
|
||||||
else:
|
|
||||||
return "There are already 6 players in the game.", False, False, False, False
|
|
||||||
else:
|
|
||||||
return "You're already in the game!", False, False, False, False
|
|
||||||
else:
|
|
||||||
return "It's too late to join.", False, False, False, False
|
|
||||||
else:
|
|
||||||
return "There's no game going on.", False, False, False, False
|
|
||||||
|
|
||||||
def parseMonopoly(self, command, channel, user):
|
|
||||||
logThis("Parsing "+command)
|
|
||||||
commands = command.split()
|
|
||||||
if command in [" ", ""] or commands[0] == "start":
|
|
||||||
try:
|
|
||||||
return self.monopolyStart(channel)
|
|
||||||
except:
|
|
||||||
logThis("Error starting game (error code 1620)")
|
|
||||||
elif commands[0] == "join":
|
|
||||||
try:
|
|
||||||
return self.monopolyJoin(channel,user)
|
|
||||||
except:
|
|
||||||
logThis("Error joining game (error code 1630)")
|
|
||||||
elif commands[0] == "roll":
|
|
||||||
try:
|
|
||||||
return self.monopolyRoll(channel,user)
|
|
||||||
except:
|
|
||||||
logThis("Error rolling (error code 1650)")
|
|
||||||
elif commands[0] == "stop":
|
|
||||||
return self.monopolyStop(channel)
|
|
||||||
else:
|
|
||||||
return "I didn't understand that (error code 1602)", False, False, False, False
|
|
||||||
|
|
||||||
def monopolyContinue(self, channel):
|
|
||||||
game = self.bot.database["monopoly games"].find_one({"_id":channel})
|
|
||||||
|
|
||||||
if game != None:
|
|
||||||
if game["started"] == False:
|
|
||||||
self.bot.database["monopoly games"].update_one({"_id":channel},{"$set":{"started":True}})
|
|
||||||
playerList = list(game["players"].keys())
|
|
||||||
random.shuffle(playerList)
|
|
||||||
self.bot.database["monopoly games"].update_one({"_id":channel},{"$set":{"player list":playerList}})
|
|
||||||
turn = 0
|
|
||||||
|
|
||||||
else:
|
|
||||||
if game["last roll"][0] == game["last roll"][1]:
|
|
||||||
turn = game["turn"]
|
|
||||||
else:
|
|
||||||
turn = (game["turn"] + 1)%len(game["player list"])
|
|
||||||
self.bot.database["monopoly games"].update_one({"_id":channel},{"$set":{"turn":turn}})
|
|
||||||
playerList = list(game["players"].keys())
|
|
||||||
|
|
||||||
#try:
|
|
||||||
self.draw.drawImage(channel)
|
|
||||||
#except:
|
|
||||||
# logThis("Error drawing board (error code 1640)")
|
|
||||||
|
|
||||||
if playerList == []:
|
|
||||||
return "No one joined. Ending game.", False, True, True
|
|
||||||
else:
|
|
||||||
message = "It's "+self.bot.funcs.getName(playerList[turn])+"'s turn. Use the 🎲 reaction to roll. You can also use \"!monopoly trade\" at any time."
|
|
||||||
return message, True, True, False
|
|
||||||
|
|
||||||
def monopolyRoll(self, channel,user):
|
|
||||||
game = self.bot.database["monopoly games"].find_one({"_id":channel})
|
|
||||||
|
|
||||||
turn = game["turn"]
|
|
||||||
currentPlayer = game["player list"][turn]
|
|
||||||
|
|
||||||
if user == currentPlayer or self.bot.options.testing:
|
|
||||||
rolls = [random.randint(1,6),random.randint(1,6)]
|
|
||||||
message = self.bot.funcs.getName(user)+" rolled a "+str(rolls[0])+" and a "+str(rolls[1])+"."
|
|
||||||
if rolls[0] == rolls[1]:
|
|
||||||
message += " Doubbles!"
|
|
||||||
|
|
||||||
roll = rolls[0] + rolls[1]
|
|
||||||
oldPosition = game["players"][user]["position"]
|
|
||||||
newPosition = (oldPosition + roll)%40
|
|
||||||
if newPosition < oldPosition:
|
|
||||||
self.bot.database["monopoly games"].update_one({"_id":channel},
|
|
||||||
{"$inc":{"players."+user+".money":rulesAndTerms["pass go money"]}})
|
|
||||||
message += "\nYou passed go and got "+str(rulesAndTerms["pass go money"])+" "+rulesAndTerms["money term"]+"."
|
|
||||||
|
|
||||||
self.bot.database["monopoly games"].update_one({"_id":channel},{"$set":{"players."+user+".position":newPosition}})
|
|
||||||
self.bot.database["monopoly games"].update_one({"_id":channel},{"$set":{"last roll":rolls}})
|
|
||||||
|
|
||||||
#try:
|
|
||||||
self.draw.drawImage(channel)
|
|
||||||
#except:
|
|
||||||
# logThis("Error drawing board (error code 1640)")
|
|
||||||
|
|
||||||
return message, True, True, False, True
|
|
||||||
else: return "", False, False, False, False
|
|
||||||
|
|
||||||
def monopolyStop(self,channel):
|
|
||||||
self.bot.funcs.deleteGame("monopoly games",channel)
|
|
||||||
return "Stopped game", False, False, False, False
|
|
@ -1,76 +0,0 @@
|
|||||||
import math
|
|
||||||
|
|
||||||
from funcs import logThis
|
|
||||||
|
|
||||||
from PIL import Image, ImageDraw
|
|
||||||
|
|
||||||
w, h = 1440, 1440
|
|
||||||
largeSpace = 190
|
|
||||||
smallSpace = math.floor((w - 2*largeSpace)/9)
|
|
||||||
avatarSize = 50
|
|
||||||
avatarHalf = math.floor(avatarSize/2)
|
|
||||||
avatarBuffer = 10
|
|
||||||
|
|
||||||
class DrawMonopoly():
|
|
||||||
def __init__(self,bot):
|
|
||||||
self.bot = bot
|
|
||||||
|
|
||||||
def drawImage(self, channel):
|
|
||||||
logThis("Drawing monopoly board for "+channel)
|
|
||||||
game = self.bot.database["monopoly games"].find_one({"_id":channel})
|
|
||||||
|
|
||||||
board = Image.open("resources/games/monopolyBoard.png")
|
|
||||||
d = ImageDraw.Draw(board,"RGBA")
|
|
||||||
places = {}
|
|
||||||
|
|
||||||
for key, value in list(game["players"].items()):
|
|
||||||
logThis("Drawing "+key)
|
|
||||||
if value["position"] in places:
|
|
||||||
places[value["position"]].append(key)
|
|
||||||
else:
|
|
||||||
places[value["position"]] = [key]
|
|
||||||
|
|
||||||
for key, value in list(places.items()):
|
|
||||||
for number, player in enumerate(value):
|
|
||||||
try:
|
|
||||||
x, y = self.getPosition(key,number)
|
|
||||||
except:
|
|
||||||
logThis("Error getting position (error code 1641)")
|
|
||||||
d.ellipse([(x-avatarHalf,y-avatarHalf),(x+avatarHalf,y+avatarHalf)],fill=(255,0,0))
|
|
||||||
|
|
||||||
board.save("resources/games/monopolyBoards/monopolyBoard"+channel+".png")
|
|
||||||
|
|
||||||
|
|
||||||
def getPosition(self, positionNumber, number):
|
|
||||||
x, y = 0, 0
|
|
||||||
if positionNumber == 0 or positionNumber >= 30:
|
|
||||||
x = math.floor(largeSpace/2)
|
|
||||||
elif positionNumber > 0 and positionNumber < 10:
|
|
||||||
x = math.floor(largeSpace - (smallSpace/2)) + (smallSpace*positionNumber)
|
|
||||||
elif positionNumber >= 10 and positionNumber <= 20:
|
|
||||||
x = w - math.floor(largeSpace/2)
|
|
||||||
elif positionNumber > 20 and positionNumber < 30:
|
|
||||||
x = w - math.floor(largeSpace - (smallSpace/2)) - (smallSpace*(positionNumber - 20))
|
|
||||||
|
|
||||||
if positionNumber >= 0 and positionNumber <= 10:
|
|
||||||
y = math.floor(largeSpace/2)
|
|
||||||
elif positionNumber > 10 and positionNumber < 20:
|
|
||||||
y = math.floor(largeSpace - (smallSpace/2)) + (smallSpace*(positionNumber-10))
|
|
||||||
elif positionNumber >= 20 and positionNumber <= 30:
|
|
||||||
y = h - math.floor(largeSpace/2)
|
|
||||||
elif positionNumber > 30:
|
|
||||||
y = h - math.floor(largeSpace - (smallSpace/2)) - (smallSpace*(positionNumber - 30))
|
|
||||||
|
|
||||||
if number%2 == 1:
|
|
||||||
x -= avatarBuffer + avatarSize
|
|
||||||
|
|
||||||
if math.floor(number/2) == 1:
|
|
||||||
y += avatarBuffer + avatarSize
|
|
||||||
elif math.floor(number/2) == 2:
|
|
||||||
y -= avatarBuffer + avatarSize
|
|
||||||
|
|
||||||
x += avatarSize
|
|
||||||
|
|
||||||
return x, y
|
|
||||||
|
|
||||||
|
|
@ -1,155 +0,0 @@
|
|||||||
import datetime
|
|
||||||
import discord
|
|
||||||
import asyncio
|
|
||||||
from funcs import logThis
|
|
||||||
from enum import Enum
|
|
||||||
|
|
||||||
minimumPlayers = 1
|
|
||||||
minimumPlayersWithAI = 5
|
|
||||||
|
|
||||||
class Team(Enum):
|
|
||||||
Villager = 1
|
|
||||||
Werewolf = 2
|
|
||||||
|
|
||||||
class Role():
|
|
||||||
def __init__(self,team,isWerewolf=False,isSeer=False,isSorcerer=False):
|
|
||||||
self.alive = True
|
|
||||||
self.team = team
|
|
||||||
self.isWerewolf = isWerewolf
|
|
||||||
self.isSeer = isSeer
|
|
||||||
self.isSorcerer = isSorcerer
|
|
||||||
|
|
||||||
class VillagerRole(Role):
|
|
||||||
def __init__(self):
|
|
||||||
super().__init__(Team.Villager)
|
|
||||||
|
|
||||||
class WerewolfRole(Role):
|
|
||||||
def __init__(self):
|
|
||||||
super.__init__(Team.Werewolf,isWerewolf=True)
|
|
||||||
|
|
||||||
class SeerRole(Role):
|
|
||||||
def __init__(self):
|
|
||||||
super.__init__(Team.Villager,isSeer=True)
|
|
||||||
|
|
||||||
class SorcererRole(Role):
|
|
||||||
def __init__(self):
|
|
||||||
super.__init__(Team.Werewolf,isSorcerer=True)
|
|
||||||
|
|
||||||
class SorcererWerewolfRole(Role):
|
|
||||||
def __init__(self):
|
|
||||||
super.__init__(Team.Werewolf,isWerewolf=True,isSorcerer=True)
|
|
||||||
|
|
||||||
class Werewolf():
|
|
||||||
def __init__(self,bot):
|
|
||||||
self.bot = bot
|
|
||||||
|
|
||||||
# Starts a game of werewolf
|
|
||||||
def werewolfStart(self,channel:str):
|
|
||||||
game = self.bot.database["werewolf games"].find_one({"_id":channel})
|
|
||||||
|
|
||||||
logThis("Trying to start a werewolf game in "+channel)
|
|
||||||
|
|
||||||
if game == None:
|
|
||||||
|
|
||||||
gameID = datetime.datetime.now().strftime('%Y%m%d%H%M%S')
|
|
||||||
|
|
||||||
newGame = {"_id":channel,"users": {},"round":0,"turn":0,"turnOrder":[],"current message":None,"gameID":gameID}
|
|
||||||
|
|
||||||
self.bot.database["werewolf games"].insert_one(newGame)
|
|
||||||
|
|
||||||
return "Started a game of werewolf. Use \"!werewolf join\" to join the game", True
|
|
||||||
else:
|
|
||||||
logThis("There is already a werewolf game going on in "+channel)
|
|
||||||
return "There's already a werewolf game going on in this channel. Try again in a few minutes.", False
|
|
||||||
|
|
||||||
# Stops the game of werewolf
|
|
||||||
def werewolfStop(self,channel:str):
|
|
||||||
game = self.bot.database["werewolf games"].find_one({"_id":channel})
|
|
||||||
|
|
||||||
if game != None:
|
|
||||||
self.bot.database["werewolf games"].delete_one({"_id":channel})
|
|
||||||
return "Ended the werewolf game"
|
|
||||||
else:
|
|
||||||
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):
|
|
||||||
logThis(f"Starting loop {round} of Werewolf game")
|
|
||||||
channel = "#"+str(ctx.channel.id)
|
|
||||||
if round == 0:
|
|
||||||
await asyncio.sleep(90)
|
|
||||||
|
|
||||||
game = self.bot.database["werewolf games"].find_one({"_id":channel})
|
|
||||||
if len(game["users"].keys()) >= minimumPlayers:
|
|
||||||
while len(game["users"].keys()) < minimumPlayersWithAI:
|
|
||||||
user = {"role": None}
|
|
||||||
self.bot.database["werewolf games"].update_one({"_id":"#"+str(ctx.channel.id)},
|
|
||||||
{"$set":{"users."+self.bot.generator.nameGen()[:-1]+" (AI player)":user}})
|
|
||||||
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}})
|
|
||||||
await self.werewolfLoop(ctx,round+1)
|
|
||||||
else:
|
|
||||||
ctx.send("Not enough players. Ending game.")
|
|
||||||
self.werewolfStop("#"+str(ctx.channel.id))
|
|
||||||
else:
|
|
||||||
await asyncio.sleep(30)
|
|
||||||
|
|
||||||
|
|
||||||
async def werewolfJoin(self,ctx):
|
|
||||||
currentGames = list(self.bot.database["werewolf games"].find({}))
|
|
||||||
for game in currentGames:
|
|
||||||
if "#"+str(ctx.message.author.id) in game["users"].keys():
|
|
||||||
return f"{ctx.message.author.display_name} is already in a werewolf game", False
|
|
||||||
|
|
||||||
game = self.bot.database["werewolf games"].find_one({"_id":"#"+str(ctx.channel.id)})
|
|
||||||
if game["round"] == 0:
|
|
||||||
user = {"role": None}
|
|
||||||
self.bot.database["werewolf games"].update_one({"_id":"#"+str(ctx.channel.id)},
|
|
||||||
{"$set":{"users."+"#"+str(ctx.message.author.id):user}})
|
|
||||||
return "You joined the werewolf game", True
|
|
||||||
else:
|
|
||||||
return "It's too late to join", False
|
|
||||||
|
|
||||||
async def parseWerewolf(self,ctx,content):
|
|
||||||
if content == "start":
|
|
||||||
response, started = self.werewolfStart("#"+str(ctx.channel.id))
|
|
||||||
await ctx.send(response)
|
|
||||||
if started:
|
|
||||||
await self.werewolfLoop(ctx,0)
|
|
||||||
|
|
||||||
elif content == "stop":
|
|
||||||
await ctx.send(self.werewolfStop("#"+str(ctx.channel.id)))
|
|
||||||
|
|
||||||
elif content == "join":
|
|
||||||
response, joined = await self.werewolfJoin(ctx)
|
|
||||||
await ctx.send(response)
|
|
||||||
if joined:
|
|
||||||
game = self.bot.database["werewolf games"].find_one({"_id":"#"+str(ctx.channel.id)})
|
|
||||||
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"
|
|
||||||
|
|
||||||
if len(list(game["users"].keys())) < minimumPlayers:
|
|
||||||
users += f"You need at least {minimumPlayers} players to play werewolf."
|
|
||||||
em = discord.Embed(title="Current Players",description=users,colour=0x00FF00)
|
|
||||||
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