cleaning up
This commit is contained in:
2
funcs/swfuncs/characters.json
Normal file
2
funcs/swfuncs/characters.json
Normal file
@ -0,0 +1,2 @@
|
||||
{
|
||||
}
|
34
funcs/swfuncs/skills.json
Normal file
34
funcs/swfuncs/skills.json
Normal file
@ -0,0 +1,34 @@
|
||||
{
|
||||
"Astrogation" : "Intellect",
|
||||
"Computers" : "Intellect",
|
||||
"Cool" : "Presence",
|
||||
"Vigilance" : "Willpower",
|
||||
"Mechanics" : "Intellect",
|
||||
"Melee" : "Brawn",
|
||||
"Perception" : "Cunning",
|
||||
"Piloting - Space" : "Agility",
|
||||
"Ranged - Heavy" : "Agility",
|
||||
"Ranged - Light" : "Agility",
|
||||
"Athletics" : "Brawn",
|
||||
"Coercion" : "Willpower",
|
||||
"Coordination" : "Agility",
|
||||
"Charm" : "Presence",
|
||||
"Medicine" : "Intellect",
|
||||
"Negotiation" : "Presence",
|
||||
"Piloting - Planetary" : "Agility",
|
||||
"Stealth" : "Agility",
|
||||
"Skullduggery" : "Cunning",
|
||||
"Brawl" : "Brawn",
|
||||
"Discipline" : "Willpower",
|
||||
"Gunnery" : "Agility",
|
||||
"Core Worlds" : "Intellect",
|
||||
"Outer Rim" : "Intellect",
|
||||
"Underworld" : "Intellect",
|
||||
"Leadership" : "Presence",
|
||||
"Lore" : "Intellect",
|
||||
"Resilience" : "Brawn",
|
||||
"Streetwise" : "Cunning",
|
||||
"Survival" : "Cunning",
|
||||
"Xenology" : "Intellect",
|
||||
"Lightsaber" : "Brawn"
|
||||
}
|
31
funcs/swfuncs/skills.txt
Normal file
31
funcs/swfuncs/skills.txt
Normal file
@ -0,0 +1,31 @@
|
||||
Astrogation
|
||||
Computers
|
||||
Cool
|
||||
Vigilance
|
||||
Mechanics
|
||||
Melee
|
||||
Perception
|
||||
Piloting - Space
|
||||
Ranged - Heavy
|
||||
Ranged - Light
|
||||
Athletics
|
||||
Coercion
|
||||
Coordination
|
||||
Charm
|
||||
Medicine
|
||||
Negotiation
|
||||
Piloting - Planetary
|
||||
Stealth
|
||||
Skullduggery
|
||||
Brawl
|
||||
Discipline
|
||||
Gunnery
|
||||
Core Worlds
|
||||
Outer Rim
|
||||
Underworld
|
||||
Leadership
|
||||
Lore
|
||||
Resilience
|
||||
Streetwise
|
||||
Survival
|
||||
Xenology
|
182
funcs/swfuncs/swchar.py
Normal file
182
funcs/swfuncs/swchar.py
Normal file
@ -0,0 +1,182 @@
|
||||
import json
|
||||
import string
|
||||
|
||||
def getName(user : str):
|
||||
with open("characters.json", "r") as f:
|
||||
data = json.load(f)
|
||||
|
||||
if user in data:
|
||||
return data[user]["Name"]
|
||||
else:
|
||||
return user
|
||||
|
||||
def setUpDict(cmd : dict):
|
||||
if bool(dict):
|
||||
keys = list(cmd)
|
||||
values = list(cmd.values())
|
||||
result = ""
|
||||
if type(values[0]) is dict:
|
||||
return ", ".join(values)
|
||||
else:
|
||||
for x in range(len(keys)):
|
||||
if x%3 != 2:
|
||||
result += "**" + keys[x] + "**" + ": " + str(values[x]) + " "
|
||||
else:
|
||||
result += "**" + keys[x] + "**" + ": " + str(values[x]) + "\n"
|
||||
return result
|
||||
else:
|
||||
return "There doesn't seem to be anything here..."
|
||||
|
||||
def lookUp(data : dict, key : str, cmd : str = ""):
|
||||
if cmd == " ":
|
||||
cmd = ""
|
||||
elif cmd != "":
|
||||
while cmd[0] == " ":
|
||||
cmd = cmd[1:]
|
||||
if cmd == "":
|
||||
break
|
||||
|
||||
if key in data:
|
||||
if cmd == "":
|
||||
if type(data[key]) is dict:
|
||||
return setUpDict(data[key])
|
||||
else:
|
||||
return data[key]
|
||||
elif cmd[0] == '+':
|
||||
try:
|
||||
cmd = cmd[1:]
|
||||
while cmd[0] == ' ':
|
||||
cmd = cmd[1:]
|
||||
except:
|
||||
return "Can't do that"
|
||||
|
||||
if type(data[key]) is int:
|
||||
try:
|
||||
newValue = data[key] + int(cmd)
|
||||
data[key] = newValue
|
||||
return data
|
||||
except:
|
||||
return "Can't add that"
|
||||
else:
|
||||
return "Can't add that"
|
||||
else:
|
||||
while cmd[0] == ' ':
|
||||
cmd = cmd[1:]
|
||||
try:
|
||||
cmd = type(data[key])(cmd)
|
||||
data[key] = cmd
|
||||
return data
|
||||
except:
|
||||
return "Wrong data type"
|
||||
else:
|
||||
return key + " doesn't exist"
|
||||
|
||||
def characterSheet(character : dict):
|
||||
divider = "\n----------\n"
|
||||
name = character["Name"]
|
||||
text1 = "Species: "+character["Species"]+"\nCareer: "+character["Career"]
|
||||
text2 = setUpDict(character["Characteristics"])
|
||||
text3 = setUpDict(character["Skills"])
|
||||
|
||||
return name, text1+"\n\n"+text2+divider+text3
|
||||
|
||||
def charData(user : str,cmd : str):
|
||||
with open("characters.json", "r") as f:
|
||||
data = json.load(f)
|
||||
|
||||
key = string.capwords(cmd.split(" ")[0])
|
||||
cmd = cmd[len(key):]
|
||||
if cmd == " ":
|
||||
cmd = ""
|
||||
elif cmd != "":
|
||||
while cmd[0] == " ":
|
||||
cmd = cmd[1:]
|
||||
if cmd == "":
|
||||
break
|
||||
|
||||
if user in data:
|
||||
if key in data[user]:
|
||||
if type(data[user][key]) is dict:
|
||||
if cmd == "":
|
||||
return setUpDict(data[user][key])
|
||||
else:
|
||||
newKey = string.capwords(cmd.split(" ")[0])
|
||||
newcmd = cmd[len(newKey):]
|
||||
|
||||
lookUpResult = lookUp(data[user][key],newKey,newcmd)
|
||||
|
||||
if type(lookUpResult) is dict:
|
||||
data[user][key] = lookUpResult
|
||||
with open("characters.json", "w") as f:
|
||||
json.dump(data,f,indent = 4)
|
||||
return "Changed " + data[user]["Name"] + "'s " + key
|
||||
else:
|
||||
return lookUpResult
|
||||
else:
|
||||
if cmd == "":
|
||||
return data[user][key]
|
||||
elif cmd[0] == '+':
|
||||
try:
|
||||
cmd = cmd[1:]
|
||||
while cmd[0] == ' ':
|
||||
cmd = cmd[1:]
|
||||
except:
|
||||
return "Can't do that"
|
||||
|
||||
if type(data[user][key]) is int:
|
||||
try:
|
||||
data[user][key] += int(cmd)
|
||||
return "Added " + cmd + " to " + user + "'s " + key
|
||||
except:
|
||||
return "Can't add that"
|
||||
else:
|
||||
return "Can't add that"
|
||||
else:
|
||||
data[user][key] = cmd
|
||||
with open("characters.json", "w") as f:
|
||||
json.dump(data,f,indent = 4)
|
||||
return "Changed " + data[user]["Name"] + "'s " + key +" to " + cmd
|
||||
else:
|
||||
return "Couldn't find that data. Are you sure you spelled it correctly?"
|
||||
else:
|
||||
return "You don't have a character. You can make one with !swchar"
|
||||
|
||||
def parseChar(user : str, cmd : str):
|
||||
with open("characters.json", "r") as f:
|
||||
data = json.load(f)
|
||||
|
||||
if cmd == " ":
|
||||
cmd = ""
|
||||
elif cmd != "":
|
||||
while cmd[0] == " ":
|
||||
cmd = cmd[1:]
|
||||
if cmd == "":
|
||||
break
|
||||
|
||||
if cmd == "":
|
||||
if user in data:
|
||||
return characterSheet(data[user])
|
||||
else:
|
||||
with open("templates.json", "r") as f:
|
||||
templates = json.load(f)
|
||||
newChar = templates["Character"]
|
||||
data[user] = newChar
|
||||
with open("characters.json", "w") as f:
|
||||
json.dump(data,f,indent = 4)
|
||||
return "", "Character for " + user + " created"
|
||||
else:
|
||||
return "", charData(user,cmd)
|
||||
|
||||
def lightsaberChar(user : str):
|
||||
with open("characters.json", "r") as f:
|
||||
data = json.load(f)
|
||||
|
||||
if user in data:
|
||||
return data[user]["Lightsaber Characteristic"]
|
||||
|
||||
def userHasChar(user : str):
|
||||
with open("characters.json", "r") as f:
|
||||
data = json.load(f)
|
||||
|
||||
return user in data
|
||||
|
169
funcs/swfuncs/swroll.py
Normal file
169
funcs/swfuncs/swroll.py
Normal file
@ -0,0 +1,169 @@
|
||||
import random
|
||||
import re
|
||||
import string
|
||||
import json
|
||||
|
||||
import swchar
|
||||
|
||||
with open("skills.json", "r") as f:
|
||||
skillData = json.load(f)
|
||||
|
||||
def roll(abi : int = 1, prof : int = 0, dif : int = 3, cha : int = 0, boo : int = 0, setb : int = 0, force : int = 0):
|
||||
result = ""
|
||||
for x in range(abi):
|
||||
result += random.choice(["","S","S","SS","A","A","SA","AA"])
|
||||
|
||||
for x in range(prof):
|
||||
result += random.choice(["","S","S","SS","SS","A","SA","SA","SA","AA","AA","R"])
|
||||
|
||||
for x in range(dif):
|
||||
result += random.choice(["","F","FF","H","H","H","HH","FH"])
|
||||
|
||||
for x in range(cha):
|
||||
result += random.choice(["","F","F","FF","FF","H","H","FH","FH","HH","HH","D"])
|
||||
|
||||
for x in range(boo):
|
||||
result += random.choice(["","","S","SA","AA","A"])
|
||||
|
||||
for x in range(setb):
|
||||
result += random.choice(["","","F","F","H","H"])
|
||||
|
||||
for x in range (force):
|
||||
result += random.choice(["B","B","B","B","B","B","BB","L","L","Ll","LL","LL"])
|
||||
|
||||
return result
|
||||
|
||||
def simplify(result : str):
|
||||
simp = ""
|
||||
success = (result.count('S') + result.count('R')) - (result.count('F') + result.count('D'))
|
||||
advantage = result.count('A') - result.count('H')
|
||||
result = re.sub("S|A|F|H","",result)
|
||||
|
||||
if success > 0:
|
||||
for x in range(success):
|
||||
simp += "S"
|
||||
elif success < 0:
|
||||
for x in range(abs(success)):
|
||||
simp += "F"
|
||||
|
||||
if advantage > 0:
|
||||
for x in range(advantage):
|
||||
simp += "A"
|
||||
elif advantage < 0:
|
||||
for x in range(abs(advantage)):
|
||||
simp += "H"
|
||||
|
||||
simp += result
|
||||
|
||||
return simp
|
||||
|
||||
def resultToEmoji(result : str):
|
||||
emoji = ""
|
||||
for char in result:
|
||||
if char == 'S':
|
||||
emoji += "<:success:690971244971163718> "
|
||||
if char == 'A':
|
||||
emoji += "<:advantage:690970761611051079> "
|
||||
if char == 'R':
|
||||
emoji += "<:swtriumph:690971267486187643> "
|
||||
if char == 'F':
|
||||
emoji += "<:failure:690970957786906664> "
|
||||
if char == 'H':
|
||||
emoji += "<:threat:690971009469382656> "
|
||||
if char == 'D':
|
||||
emoji += "<:despair:690971200163414238> "
|
||||
if char == 'L':
|
||||
emoji += "<:light:691010089905029171>"
|
||||
if char == 'B':
|
||||
emoji += "<:dark:691010101901000852>"
|
||||
|
||||
return emoji
|
||||
|
||||
def diceToEmoji(dice : list):
|
||||
emoji = ""
|
||||
|
||||
for x in range(dice[0]):
|
||||
emoji += "<:ability:690974213397282826> "
|
||||
for x in range(dice[1]):
|
||||
emoji += "<:proficiency:690973435354153071> "
|
||||
for x in range(dice[2]):
|
||||
emoji += "<:difficulty:690973992470708296> "
|
||||
for x in range(dice[3]):
|
||||
emoji += "<:challenge:690973419906400306> "
|
||||
for x in range(dice[4]):
|
||||
emoji += "<:boost:690972178216386561> "
|
||||
for x in range(dice[5]):
|
||||
emoji += "<:setback:690972157890658415> "
|
||||
for x in range(dice[6]):
|
||||
emoji += "<:force:690973451883774013> "
|
||||
|
||||
return emoji
|
||||
|
||||
def getDice(user : str, skill : str):
|
||||
return "yes"
|
||||
|
||||
def parseRoll(user : str,cmd : str = ""):
|
||||
cmd = re.sub(' +',' ',cmd.upper()) + " "
|
||||
if cmd[0] == " ":
|
||||
cmd = cmd[1:]
|
||||
commands = cmd.split(" ")
|
||||
if commands[0] == "":
|
||||
rollParameters = [1,0,3,0,0,0,0]
|
||||
else:
|
||||
rollParameters = [0,0,0,0,0,0,0]
|
||||
|
||||
if string.capwords(commands[0]) in skillData:
|
||||
if swchar.userHasChar:
|
||||
skillLevel = swchar.charData(user,"Skills " + string.capwords(commands[0]))
|
||||
|
||||
if string.capwords(commands[0]) == "Lightsaber":
|
||||
charLevel = swchar.charData(user,"Characteristics " + swchar.lightsaberChar(user))
|
||||
else:
|
||||
charLevel = swchar.charData(user,"Characteristics " + skillData[string.capwords(commands[0])])
|
||||
|
||||
abilityDice = abs(charLevel-skillLevel)
|
||||
proficiencyDice = min(skillLevel,charLevel)
|
||||
|
||||
commands = [str(abilityDice)] + [str(proficiencyDice)] + commands[1:]
|
||||
else:
|
||||
return "You don't have a user. You can make one with !swchar"
|
||||
|
||||
elif string.capwords(commands[0]) in ["Ranged","Piloting"]:
|
||||
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:
|
||||
for x in range(len(commands)):
|
||||
if commands[x-1] != "":
|
||||
if commands[x-1][0] == "A":
|
||||
rollParameters[0] = int(commands[x-1].replace("A",""))
|
||||
elif commands[x-1][0] == "P":
|
||||
rollParameters[1] = int(commands[x-1].replace("P",""))
|
||||
elif commands[x-1][0] == "D":
|
||||
rollParameters[2] = int(commands[x-1].replace("D",""))
|
||||
elif commands[x-1][0] == "C":
|
||||
rollParameters[3] = int(commands[x-1].replace("C",""))
|
||||
elif commands[x-1][0] == "B":
|
||||
rollParameters[4] = int(commands[x-1].replace("B",""))
|
||||
elif commands[x-1][0] == "S":
|
||||
rollParameters[5] = int(commands[x-1].replace("S",""))
|
||||
elif commands[x-1][0] == "F":
|
||||
rollParameters[6] = int(commands[x-1].replace("F",""))
|
||||
else:
|
||||
rollParameters[x-1] = int(commands[x-1])
|
||||
except:
|
||||
return "Invalid input!"
|
||||
|
||||
rollResults = roll(rollParameters[0],rollParameters[1],rollParameters[2],rollParameters[3],rollParameters[4],rollParameters[5],rollParameters[6])
|
||||
|
||||
simplified = simplify(rollResults)
|
||||
|
||||
name = swchar.getName(user)
|
||||
|
||||
if simplified != rollResults:
|
||||
return name + " rolls " + diceToEmoji(rollParameters) + "\nResult: " + resultToEmoji(rollResults) + "\nSimplified: " + resultToEmoji(simplify(rollResults))
|
||||
else:
|
||||
return name + " rolls " + diceToEmoji(rollParameters) + "\nResult: " + resultToEmoji(rollResults)
|
||||
|
73
funcs/swfuncs/templates.json
Normal file
73
funcs/swfuncs/templates.json
Normal file
@ -0,0 +1,73 @@
|
||||
{
|
||||
"Character": {
|
||||
"Name": "New Character",
|
||||
"Species": "",
|
||||
"Career": "",
|
||||
"Specialization Trees": [],
|
||||
"Soak": 0,
|
||||
"Wound Threshold": 0,
|
||||
"Wounds": 0,
|
||||
"Strain Threshold": 0,
|
||||
"Strain": 0,
|
||||
"Defense, Ranged": 0,
|
||||
"Defense, Melee": 0,
|
||||
"Force Rating": 0,
|
||||
"Characteristics": {
|
||||
"Brawn": 0,
|
||||
"Agility": 0,
|
||||
"Intellect": 0,
|
||||
"Cunning": 0,
|
||||
"Willpower": 0,
|
||||
"Presence": 0
|
||||
},
|
||||
"Skills": {
|
||||
"Astrogation": 0,
|
||||
"Athletics": 0,
|
||||
"Brawl": 0,
|
||||
"Charm": 0,
|
||||
"Coercion": 0,
|
||||
"Computers": 0,
|
||||
"Cool": 0,
|
||||
"Coordination": 0,
|
||||
"Core Worlds": 0,
|
||||
"Discipline": 0,
|
||||
"Gunnery": 0,
|
||||
"Leadership": 0,
|
||||
"Lightsaber": 0,
|
||||
"Lore": 0,
|
||||
"Mechanics": 0,
|
||||
"Medicine": 0,
|
||||
"Melee": 0,
|
||||
"Negotiation": 0,
|
||||
"Outer Rim": 0,
|
||||
"Perception": 0,
|
||||
"Piloting - Planetary": 0,
|
||||
"Piloting - Space": 0,
|
||||
"Ranged - Heavy": 0,
|
||||
"Ranged - Light": 0,
|
||||
"Resilience": 0,
|
||||
"Skullduggery": 0,
|
||||
"Stealth": 0,
|
||||
"Streetwise": 0,
|
||||
"Survival": 0,
|
||||
"Underworld": 0,
|
||||
"Vigilance": 0,
|
||||
"Xenology": 0
|
||||
},
|
||||
"Lightsaber Characteristic": "Brawn",
|
||||
"Obligations": {},
|
||||
"Morality": {
|
||||
"Emotional Weakness": "",
|
||||
"Emotional Strength": "",
|
||||
"Conflict": "",
|
||||
"Morality": ""
|
||||
},
|
||||
"Credits": 0,
|
||||
"Equipment": [],
|
||||
"Armor": "",
|
||||
"Critical Injuries": {},
|
||||
"Weapons": {},
|
||||
"Talents": {},
|
||||
"Force Powers": {}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user