📝 Commenting and formatting

This commit is contained in:
NikolajDanger
2020-07-29 10:38:37 +02:00
parent 94c6289cc1
commit ef434ecee8
12 changed files with 260 additions and 220 deletions

View File

@ -10,6 +10,7 @@ from funcs import logThis
with open("resources/swskills.json", "r") as f:
skillData = json.load(f)
# Rolls the specified dice
def roll(abi : int = 1, prof : int = 0, dif : int = 3, cha : int = 0, boo : int = 0, setb : int = 0, force : int = 0):
result = ""
diceResult = []
@ -50,6 +51,7 @@ def roll(abi : int = 1, prof : int = 0, dif : int = 3, cha : int = 0, boo : int
return result, diceResult
# Lets dice cancel each other out
def simplify(result : str):
logThis("Simplifying "+result)
simp = ""
@ -75,116 +77,119 @@ def simplify(result : str):
return simp
# Returns emoji that symbolize the dice results
def diceResultToEmoji(diceResults : list):
emoji = ""
for result in diceResults:
if result == "abiA":
emoji += "<:abil1a:695267684476125264> "
if result == "abiSA":
elif result == "abiSA":
emoji += "<:abil1a1s:695267684484513842> "
if result == "abiS":
elif result == "abiS":
emoji += "<:abil1s:695267684514005013> "
if result == "abiAA":
elif result == "abiAA":
emoji += "<:abil2a:695267684547428352> "
if result == "abiSS":
elif result == "abiSS":
emoji += "<:abil2s:695267684761206914> "
if result == "abi":
elif result == "abi":
emoji += "<:abilbla:695267684660674602> "
if result == "profA":
elif result == "profA":
emoji += "<:prof1a:695267685361123338> "
if result == "profSA":
elif result == "profSA":
emoji += "<:prof1a1s:695267685067653140> "
if result == "profR":
elif result == "profR":
emoji += "<:prof1r:695267685067522088> "
if result == "profS":
elif result == "profS":
emoji += "<:prof1s:695267684899881012> "
if result == "profAA":
elif result == "profAA":
emoji += "<:prof2a:695267684996218982> "
if result == "profSS":
elif result == "profSS":
emoji += "<:prof2s:695267684878647327> "
if result == "prof":
elif result == "prof":
emoji += "<:profbla:695267684698292235> "
if result == "difF":
elif result == "difF":
emoji += "<:dif1f:695267684924915804> "
if result == "difH":
elif result == "difH":
emoji += "<:dif1h:695267684908138506> "
if result == "difFH":
elif result == "difFH":
emoji += "<:dif1h1f:695267684908269678> "
if result == "difFF":
elif result == "difFF":
emoji += "<:dif2f:695267684924784680> "
if result == "difHH":
elif result == "difHH":
emoji += "<:dif2h:695267685071585340> "
if result == "dif":
elif result == "dif":
emoji += "<:difbla:695267685000544276> "
if result == "chaD":
elif result == "chaD":
emoji += "<:cha1d:695267684962533447> "
if result == "chaF":
elif result == "chaF":
emoji += "<:cha1f:695267684601954346> "
if result == "chaH":
elif result == "chaH":
emoji += "<:cha1h:695267685046681620> "
if result == "chaFH":
elif result == "chaFH":
emoji += "<:cha1h1f:695267685063327784> "
if result == "chaFF":
elif result == "chaFF":
emoji += "<:cha2f:695267684832641097> "
if result == "chaHH":
elif result == "chaHH":
emoji += "<:cha2h:695267684631183381> "
if result == "cha":
elif result == "cha":
emoji += "<:chabla:695267684895686787> "
if result == "booA":
elif result == "booA":
emoji += "<:boo1a:695267684975116329> "
if result == "booSA":
elif result == "booSA":
emoji += "<:boo1a1s:695267684970922024> "
if result == "booS":
elif result == "booS":
emoji += "<:boo1s:695267684979441714> "
if result == "booAA":
elif result == "booAA":
emoji += "<:boo2a:695267685100945488> "
if result == "boo":
elif result == "boo":
emoji += "<:boobla:695267684757012550> "
if result == "setbF":
elif result == "setbF":
emoji += "<:set1f:695267685054939197> "
if result == "setbH":
elif result == "setbH":
emoji += "<:set1h:695267685147082802> "
if result == "setb":
elif result == "setb":
emoji += "<:setbla:695267685151408169> "
if result == "forceB":
elif result == "forceB":
emoji += "<:for1b:695267684593434677> "
if result == "forceL":
elif result == "forceL":
emoji += "<:for1l:695267684606148640> "
if result == "forceBB":
elif result == "forceBB":
emoji += "<:for2b:695267684903944303> "
if result == "forceLL":
elif result == "forceLL":
emoji += "<:for2l:695267684992024626> "
return emoji
# Returns emoji that symbolize the results of the dice rolls
def resultToEmoji(result : str):
emoji = ""
for char in result:
if char == 'S':
emoji += "<:success:690971244971163718> "
if char == 'A':
elif char == 'A':
emoji += "<:advantage:690970761611051079> "
if char == 'R':
elif char == 'R':
emoji += "<:swtriumph:690971267486187643> "
if char == 'F':
elif char == 'F':
emoji += "<:failure:690970957786906664> "
if char == 'H':
elif char == 'H':
emoji += "<:threat:690971009469382656> "
if char == 'D':
elif char == 'D':
emoji += "<:despair:690971200163414238> "
if char == 'L':
elif char == 'L':
emoji += "<:light:691010089905029171>"
if char == 'B':
elif char == 'B':
emoji += "<:dark:691010101901000852>"
return emoji
# Converts emoji into letters
def emojiToResult(emoji : str):
result = ""
for char in emoji:
@ -195,6 +200,7 @@ def emojiToResult(emoji : str):
return result
# Returns emoji that symbolize the dice
def diceToEmoji(dice : list):
emoji = ""
@ -215,6 +221,7 @@ def diceToEmoji(dice : list):
return emoji
# Rolls for obligation
def obligationRoll():
logThis("Rolling for obligation")
with open("resources/swcharacters.json", "r") as f:
@ -232,6 +239,7 @@ def obligationRoll():
return random.choice(table)
# Rolls for critical injury
def critRoll(addington : int):
dd = "<:difficulty:690973992470708296>"
sd = "<:setback:690972157890658415>"
@ -283,6 +291,7 @@ def critRoll(addington : int):
return "Roll: "+str(roll)+"\nInjury:\n"+results
# Parses the command into something the other functions understand
def parseRoll(user : str,cmd : str = ""):
cmd = re.sub(' +',' ',cmd.upper()) + " "
if cmd[0] == " ":
@ -296,7 +305,7 @@ def parseRoll(user : str,cmd : str = ""):
if string.capwords(commands[0]) == "Obligations":
return obligationRoll()
elif string.capwords(commands[0]) in skillData:
logThis("Oh look! This guy has skills!")
if swchar.userHasChar: