From b82d233faf3c849901be2b4f93878aaa9cc4720e Mon Sep 17 00:00:00 2001 From: NikolajDanger Date: Thu, 13 Aug 2020 16:59:31 +0200 Subject: [PATCH] :bug: --- funcs/__init__.py | 4 +-- funcs/games/__init__.py | 2 +- funcs/games/blackjack.py | 7 ++-- funcs/games/money.py | 2 -- funcs/swfuncs/swchar.py | 22 ++++++------ funcs/swfuncs/swroll.py | 76 ++++++++++++++++++++-------------------- 6 files changed, 55 insertions(+), 58 deletions(-) diff --git a/funcs/__init__.py b/funcs/__init__.py index e27ffa3..36bc1ea 100644 --- a/funcs/__init__.py +++ b/funcs/__init__.py @@ -1,8 +1,8 @@ """A collection of all Gwendolyn functions.""" -#__all__ = ["Games" ,"helloFunc", "cap", "imageFunc", "logThis", "findWikiPage", "makeFiles", "emojiToCommand", "Money", "spellFunc", "monsterFunc", "nameGen", "tavernGen", "movieFunc", "roll_dice", "SwChar", "SwDestiny", "SwRoll", "addToDict", "replaceMultiple", "transferUsers","Funcs"] +__all__ = ["Games" ,"helloFunc", "cap", "imageFunc", "logThis", "findWikiPage", "makeFiles", "emojiToCommand", "Money", "spellFunc", "monsterFunc", "nameGen", "tavernGen", "movieFunc", "roll_dice", "SwChar", "SwDestiny", "SwRoll", "replaceMultiple","Funcs"] -from .miscFuncs import helloFunc, cap, imageFunc, logThis, findWikiPage, makeFiles, replaceMultiple, emojiToCommand, addToDict, transferUsers +from .miscFuncs import helloFunc, cap, imageFunc, logThis, findWikiPage, makeFiles, replaceMultiple, emojiToCommand from .funcs import Funcs diff --git a/funcs/games/__init__.py b/funcs/games/__init__.py index 102b69f..b1839ad 100644 --- a/funcs/games/__init__.py +++ b/funcs/games/__init__.py @@ -1,6 +1,6 @@ """Functions for games Gwendolyn can play.""" -#__all__ = ["Money", "Games"] +__all__ = ["Money", "Games"] from .money import Money from .games import Games diff --git a/funcs/games/blackjack.py b/funcs/games/blackjack.py index 0f2eb6a..fb00e34 100644 --- a/funcs/games/blackjack.py +++ b/funcs/games/blackjack.py @@ -1,7 +1,6 @@ import random import math import datetime -import os import asyncio import discord @@ -48,8 +47,8 @@ class Blackjack(): values.append(values[x] + 11) values[x] += 1 else: - for x in range(len(values)): - values[x] += int(cardValue) + for value in values: + value += int(cardValue) values.sort() @@ -169,7 +168,7 @@ class Blackjack(): hand["third hand"], allStanding, preAllStanding = self.testIfStanding(hand["third hand"],allStanding,preAllStanding,False) if hand["split"] >= 3: hand["fourth hand"], allStanding, preAllStanding = self.testIfStanding(hand["fourth hand"],allStanding,preAllStanding,False) - + return hand, allStanding, preAllStanding diff --git a/funcs/games/money.py b/funcs/games/money.py index 92cdc07..ca5b030 100644 --- a/funcs/games/money.py +++ b/funcs/games/money.py @@ -1,5 +1,3 @@ -import pymongo - from funcs import logThis class Money(): diff --git a/funcs/swfuncs/swchar.py b/funcs/swfuncs/swchar.py index a5115e6..953e9b1 100644 --- a/funcs/swfuncs/swchar.py +++ b/funcs/swfuncs/swchar.py @@ -24,20 +24,20 @@ class SwChar(): keys = list(cmd) values = list(cmd.values()) result = "" - if type(values[0]) is dict: + if isinstance(values[0],dict): return ", ".join(values) else: - for x in range(len(keys)): - if type(keys[x]) is list: + for x, key in enumerate(keys): + if type(key) is list: if x%3 != 2: - result += "**" + keys[x] + "**" + ": " + ", ".join(values[x]) + " " + result += "**" + key + "**" + ": " + ", ".join(values[x]) + " " else: - result += "**" + keys[x] + "**" + ": " + ", ".join(values[x]) + "\n" + result += "**" + key + "**" + ": " + ", ".join(values[x]) + "\n" else: if x%3 != 2: - result += "**" + keys[x] + "**" + ": " + str(values[x]) + " " + result += "**" + key + "**" + ": " + str(values[x]) + " " else: - result += "**" + keys[x] + "**" + ": " + str(values[x]) + "\n" + result += "**" + key + "**" + ": " + str(values[x]) + "\n" logThis("Returning a dictionary, but well formatted") return result else: @@ -458,8 +458,8 @@ class SwChar(): withSpaces = ["Specialization Trees","Wound Threshold","Strain Threshold","Defense - Ranged","Defense - Melee","Force Rating","Core Worlds","Outer Rim","Piloting - Planetary","Piloting - Space","Ranged - Heavy","Ranged - Light","Lightsaber Characteristic","Critical Injuries","Force Powers"] withoutSpaces = ["Specialization-trees","Wound-threshold","Strain-threshold","Defense-ranged","Defense-melee","Force-rating","Core-worlds","Outer-rim","Piloting-planetary","Piloting-space","Ranged-heavy","Ranged-light","Lightsaber-characteristic","Critical-injuries","Force-powers"] - for x in range(len(withoutSpaces)): - cmd = cmd.replace(withSpaces[x],withoutSpaces[x]) + for x, value in enumerate(withoutSpaces): + cmd = cmd.replace(withSpaces[x],value) return cmd @@ -467,8 +467,8 @@ class SwChar(): withSpaces = ["Specialization Trees","Wound Threshold","Strain Threshold","Defense - Ranged","Defense - Melee","Force Rating","Core Worlds","Outer Rim","Piloting - Planetary","Piloting - Space","Ranged - Heavy","Ranged - light","Lightsaber Characteristic","Critical Injuries","Force Powers"] withoutSpaces = ["Specialization-trees","Wound-threshold","Strain-threshold","Defense-ranged","Defense-melee","Force-rating","Core-worlds","Outer-rim","Piloting-planetary","Piloting-space","Ranged-heavy","Ranged-light","Lightsaber-characteristic","Critical-injuries","Force-powers"] - for x in range(len(withoutSpaces)): - cmd = cmd.replace(withoutSpaces[x],withSpaces[x]) + for x, value in enumerate(withoutSpaces): + cmd = cmd.replace(value,withSpaces[x]) return cmd diff --git a/funcs/swfuncs/swroll.py b/funcs/swfuncs/swroll.py index ac61c2e..d6be06b 100644 --- a/funcs/swfuncs/swroll.py +++ b/funcs/swfuncs/swroll.py @@ -16,37 +16,37 @@ class SwRoll(): def roll(self, abi : int = 1, prof : int = 0, dif : int = 3, cha : int = 0, boo : int = 0, setb : int = 0, force : int = 0): result = "" diceResult = [] - for x in range(abi): + for _ in range(abi): choice = random.choice(["","S","S","SS","A","A","SA","AA"]) result += choice diceResult.append("abi"+choice) - for x in range(prof): + for _ in range(prof): choice = random.choice(["","S","S","SS","SS","A","SA","SA","SA","AA","AA","R"]) result += choice diceResult.append("prof"+choice) - for x in range(dif): + for _ in range(dif): choice = random.choice(["","F","FF","H","H","H","HH","FH"]) result += choice diceResult.append("dif"+choice) - for x in range(cha): + for _ in range(cha): choice = random.choice(["","F","F","FF","FF","H","H","FH","FH","HH","HH","D"]) result += choice diceResult.append("cha"+choice) - for x in range(boo): + for _ in range(boo): choice = random.choice(["","","S","SA","AA","A"]) result += choice diceResult.append("boo"+choice) - for x in range(setb): + for _ in range(setb): choice = random.choice(["","","F","F","H","H"]) result += choice diceResult.append("setb"+choice) - for x in range (force): + for _ in range (force): choice = random.choice(["B","B","B","B","B","B","BB","L","L","LL","LL","LL"]) result += choice diceResult.append("force"+choice) @@ -62,17 +62,17 @@ class SwRoll(): result = re.sub("S|A|F|H","",result) if success > 0: - for x in range(success): + for _ in range(success): simp += "S" elif success < 0: - for x in range(abs(success)): + for _ in range(abs(success)): simp += "F" if advantage > 0: - for x in range(advantage): + for _ in range(advantage): simp += "A" elif advantage < 0: - for x in range(abs(advantage)): + for _ in range(abs(advantage)): simp += "H" simp += result @@ -206,19 +206,19 @@ class SwRoll(): def diceToEmoji(self, dice : list): emoji = "" - for x in range(dice[0]): + for _ in range(dice[0]): emoji += "<:ability:690974213397282826> " - for x in range(dice[1]): + for _ in range(dice[1]): emoji += "<:proficiency:690973435354153071> " - for x in range(dice[2]): + for _ in range(dice[2]): emoji += "<:difficulty:690973992470708296> " - for x in range(dice[3]): + for _ in range(dice[3]): emoji += "<:challenge:690973419906400306> " - for x in range(dice[4]): + for _ in range(dice[4]): emoji += "<:boost:690972178216386561> " - for x in range(dice[5]): + for _ in range(dice[5]): emoji += "<:setback:690972157890658415> " - for x in range(dice[6]): + for _ in range(dice[6]): emoji += "<:force:690973451883774013> " return emoji @@ -232,7 +232,7 @@ class SwRoll(): for character in data: for obligation in data[character]["Obligations"]: - for x in range(data[character]["Obligations"][obligation]): + for _ in range(data[character]["Obligations"][obligation]): table.append(data[character]["Name"]+", "+obligation) while len(table) < 100: @@ -306,7 +306,7 @@ class SwRoll(): if string.capwords(commands[0]) == "Obligations": try: - return obligationRoll() + return self.obligationRoll() except: logThis("Obligation fucked up (error code 911)") return "An error occured (error code 911)" @@ -341,25 +341,25 @@ class SwRoll(): try: logThis("Converting commands to dice") - for x in range(len(commands)): - if commands[x] != "": - commands[x] = commands[x].upper() - if commands[x][0] == "A": - rollParameters[0] = int(commands[x].replace("A","")) - elif commands[x][0] == "P": - rollParameters[1] = int(commands[x].replace("P","")) - elif commands[x][0] == "D": - rollParameters[2] = int(commands[x].replace("D","")) - elif commands[x][0] == "C": - rollParameters[3] = int(commands[x].replace("C","")) - elif commands[x][0] == "B": - rollParameters[4] = int(commands[x].replace("B","")) - elif commands[x][0] == "S": - rollParameters[5] = int(commands[x].replace("S","")) - elif commands[x][0] == "F": - rollParameters[6] = int(commands[x].replace("F","")) + for x, command in enumerate(commands): + if command != "": + command = command.upper() + if command[0] == "A": + rollParameters[0] = int(command.replace("A","")) + elif command[0] == "P": + rollParameters[1] = int(command.replace("P","")) + elif command[0] == "D": + rollParameters[2] = int(command.replace("D","")) + elif command[0] == "C": + rollParameters[3] = int(command.replace("C","")) + elif command[0] == "B": + rollParameters[4] = int(command.replace("B","")) + elif command[0] == "S": + rollParameters[5] = int(command.replace("S","")) + elif command[0] == "F": + rollParameters[6] = int(command.replace("F","")) else: - rollParameters[x] = int(commands[x]) + rollParameters[x] = int(command) except: logThis("Someone fucked u-up! (it was them) (error code 914)") return "Invalid input! (error code 914)"