This commit is contained in:
NikolajDanger
2020-08-13 16:59:31 +02:00
parent fcff2a0823
commit b82d233faf
6 changed files with 55 additions and 58 deletions

View File

@@ -1,8 +1,8 @@
"""A collection of all Gwendolyn functions.""" """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 from .funcs import Funcs

View File

@@ -1,6 +1,6 @@
"""Functions for games Gwendolyn can play.""" """Functions for games Gwendolyn can play."""
#__all__ = ["Money", "Games"] __all__ = ["Money", "Games"]
from .money import Money from .money import Money
from .games import Games from .games import Games

View File

@@ -1,7 +1,6 @@
import random import random
import math import math
import datetime import datetime
import os
import asyncio import asyncio
import discord import discord
@@ -48,8 +47,8 @@ class Blackjack():
values.append(values[x] + 11) values.append(values[x] + 11)
values[x] += 1 values[x] += 1
else: else:
for x in range(len(values)): for value in values:
values[x] += int(cardValue) value += int(cardValue)
values.sort() values.sort()

View File

@@ -1,5 +1,3 @@
import pymongo
from funcs import logThis from funcs import logThis
class Money(): class Money():

View File

@@ -24,20 +24,20 @@ class SwChar():
keys = list(cmd) keys = list(cmd)
values = list(cmd.values()) values = list(cmd.values())
result = "" result = ""
if type(values[0]) is dict: if isinstance(values[0],dict):
return ", ".join(values) return ", ".join(values)
else: else:
for x in range(len(keys)): for x, key in enumerate(keys):
if type(keys[x]) is list: if type(key) is list:
if x%3 != 2: if x%3 != 2:
result += "**" + keys[x] + "**" + ": " + ", ".join(values[x]) + " " result += "**" + key + "**" + ": " + ", ".join(values[x]) + " "
else: else:
result += "**" + keys[x] + "**" + ": " + ", ".join(values[x]) + "\n" result += "**" + key + "**" + ": " + ", ".join(values[x]) + "\n"
else: else:
if x%3 != 2: if x%3 != 2:
result += "**" + keys[x] + "**" + ": " + str(values[x]) + " " result += "**" + key + "**" + ": " + str(values[x]) + " "
else: else:
result += "**" + keys[x] + "**" + ": " + str(values[x]) + "\n" result += "**" + key + "**" + ": " + str(values[x]) + "\n"
logThis("Returning a dictionary, but well formatted") logThis("Returning a dictionary, but well formatted")
return result return result
else: 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"] 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"] 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)): for x, value in enumerate(withoutSpaces):
cmd = cmd.replace(withSpaces[x],withoutSpaces[x]) cmd = cmd.replace(withSpaces[x],value)
return cmd 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"] 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"] 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)): for x, value in enumerate(withoutSpaces):
cmd = cmd.replace(withoutSpaces[x],withSpaces[x]) cmd = cmd.replace(value,withSpaces[x])
return cmd return cmd

View File

@@ -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): 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 = "" result = ""
diceResult = [] diceResult = []
for x in range(abi): for _ in range(abi):
choice = random.choice(["","S","S","SS","A","A","SA","AA"]) choice = random.choice(["","S","S","SS","A","A","SA","AA"])
result += choice result += choice
diceResult.append("abi"+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"]) choice = random.choice(["","S","S","SS","SS","A","SA","SA","SA","AA","AA","R"])
result += choice result += choice
diceResult.append("prof"+choice) diceResult.append("prof"+choice)
for x in range(dif): for _ in range(dif):
choice = random.choice(["","F","FF","H","H","H","HH","FH"]) choice = random.choice(["","F","FF","H","H","H","HH","FH"])
result += choice result += choice
diceResult.append("dif"+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"]) choice = random.choice(["","F","F","FF","FF","H","H","FH","FH","HH","HH","D"])
result += choice result += choice
diceResult.append("cha"+choice) diceResult.append("cha"+choice)
for x in range(boo): for _ in range(boo):
choice = random.choice(["","","S","SA","AA","A"]) choice = random.choice(["","","S","SA","AA","A"])
result += choice result += choice
diceResult.append("boo"+choice) diceResult.append("boo"+choice)
for x in range(setb): for _ in range(setb):
choice = random.choice(["","","F","F","H","H"]) choice = random.choice(["","","F","F","H","H"])
result += choice result += choice
diceResult.append("setb"+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"]) choice = random.choice(["B","B","B","B","B","B","BB","L","L","LL","LL","LL"])
result += choice result += choice
diceResult.append("force"+choice) diceResult.append("force"+choice)
@@ -62,17 +62,17 @@ class SwRoll():
result = re.sub("S|A|F|H","",result) result = re.sub("S|A|F|H","",result)
if success > 0: if success > 0:
for x in range(success): for _ in range(success):
simp += "S" simp += "S"
elif success < 0: elif success < 0:
for x in range(abs(success)): for _ in range(abs(success)):
simp += "F" simp += "F"
if advantage > 0: if advantage > 0:
for x in range(advantage): for _ in range(advantage):
simp += "A" simp += "A"
elif advantage < 0: elif advantage < 0:
for x in range(abs(advantage)): for _ in range(abs(advantage)):
simp += "H" simp += "H"
simp += result simp += result
@@ -206,19 +206,19 @@ class SwRoll():
def diceToEmoji(self, dice : list): def diceToEmoji(self, dice : list):
emoji = "" emoji = ""
for x in range(dice[0]): for _ in range(dice[0]):
emoji += "<:ability:690974213397282826> " emoji += "<:ability:690974213397282826> "
for x in range(dice[1]): for _ in range(dice[1]):
emoji += "<:proficiency:690973435354153071> " emoji += "<:proficiency:690973435354153071> "
for x in range(dice[2]): for _ in range(dice[2]):
emoji += "<:difficulty:690973992470708296> " emoji += "<:difficulty:690973992470708296> "
for x in range(dice[3]): for _ in range(dice[3]):
emoji += "<:challenge:690973419906400306> " emoji += "<:challenge:690973419906400306> "
for x in range(dice[4]): for _ in range(dice[4]):
emoji += "<:boost:690972178216386561> " emoji += "<:boost:690972178216386561> "
for x in range(dice[5]): for _ in range(dice[5]):
emoji += "<:setback:690972157890658415> " emoji += "<:setback:690972157890658415> "
for x in range(dice[6]): for _ in range(dice[6]):
emoji += "<:force:690973451883774013> " emoji += "<:force:690973451883774013> "
return emoji return emoji
@@ -232,7 +232,7 @@ class SwRoll():
for character in data: for character in data:
for obligation in data[character]["Obligations"]: 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) table.append(data[character]["Name"]+", "+obligation)
while len(table) < 100: while len(table) < 100:
@@ -306,7 +306,7 @@ class SwRoll():
if string.capwords(commands[0]) == "Obligations": if string.capwords(commands[0]) == "Obligations":
try: try:
return obligationRoll() return self.obligationRoll()
except: except:
logThis("Obligation fucked up (error code 911)") logThis("Obligation fucked up (error code 911)")
return "An error occured (error code 911)" return "An error occured (error code 911)"
@@ -341,25 +341,25 @@ class SwRoll():
try: try:
logThis("Converting commands to dice") logThis("Converting commands to dice")
for x in range(len(commands)): for x, command in enumerate(commands):
if commands[x] != "": if command != "":
commands[x] = commands[x].upper() command = command.upper()
if commands[x][0] == "A": if command[0] == "A":
rollParameters[0] = int(commands[x].replace("A","")) rollParameters[0] = int(command.replace("A",""))
elif commands[x][0] == "P": elif command[0] == "P":
rollParameters[1] = int(commands[x].replace("P","")) rollParameters[1] = int(command.replace("P",""))
elif commands[x][0] == "D": elif command[0] == "D":
rollParameters[2] = int(commands[x].replace("D","")) rollParameters[2] = int(command.replace("D",""))
elif commands[x][0] == "C": elif command[0] == "C":
rollParameters[3] = int(commands[x].replace("C","")) rollParameters[3] = int(command.replace("C",""))
elif commands[x][0] == "B": elif command[0] == "B":
rollParameters[4] = int(commands[x].replace("B","")) rollParameters[4] = int(command.replace("B",""))
elif commands[x][0] == "S": elif command[0] == "S":
rollParameters[5] = int(commands[x].replace("S","")) rollParameters[5] = int(command.replace("S",""))
elif commands[x][0] == "F": elif command[0] == "F":
rollParameters[6] = int(commands[x].replace("F","")) rollParameters[6] = int(command.replace("F",""))
else: else:
rollParameters[x] = int(commands[x]) rollParameters[x] = int(command)
except: except:
logThis("Someone fucked u-up! (it was them) (error code 914)") logThis("Someone fucked u-up! (it was them) (error code 914)")
return "Invalid input! (error code 914)" return "Invalid input! (error code 914)"