Logging
This commit is contained in:
@@ -5,6 +5,7 @@ import json
|
||||
import os
|
||||
|
||||
from . import swchar
|
||||
from funcs import logThis
|
||||
|
||||
with open("resources/swskills.json", "r") as f:
|
||||
skillData = json.load(f)
|
||||
@@ -35,6 +36,7 @@ def roll(abi : int = 1, prof : int = 0, dif : int = 3, cha : int = 0, boo : int
|
||||
return result
|
||||
|
||||
def simplify(result : str):
|
||||
logThis("Simplifying "+result)
|
||||
simp = ""
|
||||
success = (result.count('S') + result.count('R')) - (result.count('F') + result.count('D'))
|
||||
advantage = result.count('A') - result.count('H')
|
||||
@@ -110,10 +112,8 @@ def diceToEmoji(dice : list):
|
||||
|
||||
return emoji
|
||||
|
||||
def getDice(user : str, skill : str):
|
||||
return "yes"
|
||||
|
||||
def obligationRoll():
|
||||
logThis("Rolling for obligation")
|
||||
with open("resources/swcharacters.json", "r") as f:
|
||||
data = json.load(f)
|
||||
|
||||
@@ -144,10 +144,13 @@ def parseRoll(user : str,cmd : str = ""):
|
||||
return obligationRoll()
|
||||
|
||||
elif string.capwords(commands[0]) in skillData:
|
||||
logThis("Oh look! This guy has skills!")
|
||||
if swchar.userHasChar:
|
||||
logThis("They have a character. That much we know")
|
||||
skillLevel = swchar.charData(user,"Skills " + string.capwords(commands[0]))
|
||||
|
||||
if string.capwords(commands[0]) == "Lightsaber":
|
||||
logThis("The skill is lightsaber")
|
||||
charLevel = swchar.charData(user,"Characteristics " + swchar.lightsaberChar(user))
|
||||
else:
|
||||
charLevel = swchar.charData(user,"Characteristics " + skillData[string.capwords(commands[0])])
|
||||
@@ -156,16 +159,20 @@ def parseRoll(user : str,cmd : str = ""):
|
||||
proficiencyDice = min(skillLevel,charLevel)
|
||||
|
||||
commands = [str(abilityDice)] + [str(proficiencyDice)] + commands[1:]
|
||||
logThis("Converted skill to dice")
|
||||
else:
|
||||
logThis("Okay, no they don't i guess")
|
||||
return "You don't have a user. You can make one with !swchar"
|
||||
|
||||
elif string.capwords(commands[0]) in ["Ranged","Piloting"]:
|
||||
logThis("They fucked up writing the name of a ranged or piloting skill")
|
||||
if string.capwords(commands[0]) == "Ranged":
|
||||
return "Did you mean \"Ranged - Heavy\" or \"Ranged - Light\""
|
||||
else:
|
||||
return "Did you mean \"Piloting - Planetary\" or \"Piloting - Space\""
|
||||
|
||||
try:
|
||||
logThis("Converting commands to dice")
|
||||
for x in range(len(commands)):
|
||||
if commands[x-1] != "":
|
||||
if commands[x-1][0] == "A":
|
||||
@@ -185,8 +192,10 @@ def parseRoll(user : str,cmd : str = ""):
|
||||
else:
|
||||
rollParameters[x-1] = int(commands[x-1])
|
||||
except:
|
||||
logThis("Someone fucked u-up! (it was them)")
|
||||
return "Invalid input!"
|
||||
|
||||
logThis("Rolling "+str(rollParameters))
|
||||
rollResults = roll(rollParameters[0],rollParameters[1],rollParameters[2],rollParameters[3],rollParameters[4],rollParameters[5],rollParameters[6])
|
||||
|
||||
simplified = simplify(rollResults)
|
||||
@@ -194,7 +203,9 @@ def parseRoll(user : str,cmd : str = ""):
|
||||
name = swchar.getName(user)
|
||||
|
||||
if simplified != rollResults:
|
||||
return name + " rolls " + diceToEmoji(rollParameters) + "\nResult: " + resultToEmoji(rollResults) + "\nSimplified: " + resultToEmoji(simplify(rollResults))
|
||||
logThis("Returns results and simplified results")
|
||||
return name + " rolls " + diceToEmoji(rollParameters) + "\nResult: " + resultToEmoji(rollResults) + "\nSimplified: " + resultToEmoji(simplify(rollResults))
|
||||
else:
|
||||
logThis("Returns results")
|
||||
return name + " rolls " + diceToEmoji(rollParameters) + "\nResult: " + resultToEmoji(rollResults)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user