some cleaning up

This commit is contained in:
Nikolaj
2022-01-28 13:20:15 +01:00
parent 08435d6934
commit 2b21d43627
6 changed files with 320 additions and 325 deletions

View File

@ -2,27 +2,27 @@ class StarWarsDestiny():
def __init__(self, bot):
self.bot = bot
def destinyNew(self, num : int):
def destiny_new(self, num : int):
self.bot.log("Creating a new destiny pool with "+str(num)+" players")
roll, diceResults = self.bot.star_wars.roll.roll(0,0,0,0,0,0,num)
roll, dice_results = self.bot.star_wars.roll.roll(0,0,0,0,0,0,num)
roll = "".join(sorted(roll))
with open("gwendolyn/resources/star_wars/destinyPoints.txt","wt") as f:
f.write(roll)
with open("gwendolyn/resources/star_wars/destinyPoints.txt","wt") as file_pointer:
file_pointer.write(roll)
return "Rolled for Destiny Points and got:\n"+self.bot.star_wars.roll.diceResultToEmoji(diceResults)+"\n"+self.bot.star_wars.roll.resultToEmoji(roll)
return "Rolled for Destiny Points and got:\n"+self.bot.star_wars.roll.diceResultToEmoji(dice_results)+"\n"+self.bot.star_wars.roll.resultToEmoji(roll)
def destinyUse(self, user : str):
with open("gwendolyn/resources/star_wars/destinyPoints.txt","rt") as f:
points = f.read()
def destiny_use(self, user : str):
with open("gwendolyn/resources/star_wars/destinyPoints.txt","rt") as file_pointer:
points = file_pointer.read()
if user == "Nikolaj":
self.bot.log("Trying to use a dark side destiny point")
if 'B' in points:
points = points.replace("B","L",1)
points = "".join(sorted(points))
with open("gwendolyn/resources/star_wars/destinyPoints.txt","wt") as f:
f.write(points)
with open("gwendolyn/resources/star_wars/destinyPoints.txt","wt") as file_pointer:
file_pointer.write(points)
self.bot.log("Did it")
return "Used a dark side destiny point. Destiny pool is now:\n"+self.bot.star_wars.roll.resultToEmoji(points)
else:
@ -33,15 +33,15 @@ class StarWarsDestiny():
if 'L' in points:
points = points.replace("L","B",1)
points = "".join(sorted(points))
with open("gwendolyn/resources/star_wars/destinyPoints.txt","wt") as f:
f.write(points)
with open("gwendolyn/resources/star_wars/destinyPoints.txt","wt") as file_pointer:
file_pointer.write(points)
self.bot.log("Did it")
return "Used a light side destiny point. Destiny pool is now:\n"+self.bot.star_wars.roll.resultToEmoji(points)
else:
self.bot.log("There were no dark side destiny points")
return "No light side destiny points"
async def parseDestiny(self, ctx, cmd : str):
async def parse_destiny(self, ctx, cmd : str):
user = f"#{ctx.author.id}"
if cmd != "":
while cmd[0] == ' ':
@ -51,22 +51,22 @@ class StarWarsDestiny():
if cmd == "":
self.bot.log("Retrieving destiny pool info")
with open("gwendolyn/resources/star_wars/destinyPoints.txt","rt") as f:
send_message = self.bot.star_wars.roll.resultToEmoji(f.read())
with open("gwendolyn/resources/star_wars/destinyPoints.txt","rt") as file_pointer:
send_message = self.bot.star_wars.roll.resultToEmoji(file_pointer.read())
else:
commands = cmd.upper().split(" ")
if commands[0] == "N":
if len(commands) > 1:
send_message = self.destinyNew(int(commands[1]))
send_message = self.destiny_new(int(commands[1]))
else:
send_message = "You need to give an amount of players"
elif commands[0] == "U":
send_message = self.destinyUse(user)
send_message = self.destiny_use(user)
else:
send_message = "I didn't quite understand that"
message_list = send_message.split("\n")
await ctx.send(message_list[0])
if len(message_list) > 1:
for messageItem in message_list[1:]:
await ctx.channel.send(messageItem)
for message_item in message_list[1:]:
await ctx.channel.send(message_item)