Fun lil' commit
This commit is contained in:
BIN
__pycache__/swchar.cpython-36.pyc
Normal file
BIN
__pycache__/swchar.cpython-36.pyc
Normal file
Binary file not shown.
BIN
__pycache__/swroll.cpython-36.pyc
Normal file
BIN
__pycache__/swroll.cpython-36.pyc
Normal file
Binary file not shown.
@ -19,6 +19,9 @@
|
|||||||
"Cunning": 0,
|
"Cunning": 0,
|
||||||
"Willpower": 0,
|
"Willpower": 0,
|
||||||
"Presence": 0
|
"Presence": 0
|
||||||
|
},
|
||||||
|
"Skills" : {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
33
skills.json
Normal file
33
skills.json
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"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"
|
||||||
|
}
|
31
skills.txt
Normal file
31
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
|
66
swchar.py
66
swchar.py
@ -1,18 +1,72 @@
|
|||||||
import json
|
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):
|
||||||
|
keys = list(cmd)
|
||||||
|
values = list(cmd.values())
|
||||||
|
result = ""
|
||||||
|
for x in range(len(keys)):
|
||||||
|
if x%3 != 2:
|
||||||
|
result += keys[x] + ": " + str(values[x]) + "\t"
|
||||||
|
else:
|
||||||
|
result += keys[x] + ": " + str(values[x]) + "\n"
|
||||||
|
return result
|
||||||
|
|
||||||
|
def lookUp(data : dict, key : str, cmd : str = ""):
|
||||||
|
if key in data:
|
||||||
|
if cmd == "":
|
||||||
|
return data[key]
|
||||||
|
else:
|
||||||
|
while cmd[0] == ' ':
|
||||||
|
cmd = cmd[1:]
|
||||||
|
try:
|
||||||
|
cmd = type(data[key])(cmd)
|
||||||
|
data[key] = cmd
|
||||||
|
return data
|
||||||
|
except:
|
||||||
|
return "Wrong data type"
|
||||||
|
|
||||||
def charData(user : str, key : str,cmd : str = ""):
|
def charData(user : str, key : str,cmd : str = ""):
|
||||||
with open("characters.json", "r") as f:
|
with open("characters.json", "r") as f:
|
||||||
data = json.load(f)
|
data = json.load(f)
|
||||||
|
|
||||||
|
key = string.capwords(key)
|
||||||
|
|
||||||
if user in data:
|
if user in data:
|
||||||
if key in data[user]:
|
if key in data[user]:
|
||||||
if cmd == "":
|
if type(data[user][key]) is dict:
|
||||||
return data[user][key]
|
if cmd == "":
|
||||||
|
return setUpDict(data[user][key])
|
||||||
|
else:
|
||||||
|
newKey = 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:
|
else:
|
||||||
data[user]["Name"] = cmd
|
if cmd == "":
|
||||||
with open("characters.json", "w") as f:
|
return data[user][key]
|
||||||
json.dump(data,f,indent = 4)
|
else:
|
||||||
return "Changed " + user + "'s character's name to " + cmd
|
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:
|
else:
|
||||||
return "Couldn't find that data. Are you sure you spelled it correctly?"
|
return "Couldn't find that data. Are you sure you spelled it correctly?"
|
||||||
else:
|
else:
|
||||||
|
26
swroll.py
26
swroll.py
@ -1,5 +1,12 @@
|
|||||||
import random
|
import random
|
||||||
import re
|
import re
|
||||||
|
import string
|
||||||
|
import json
|
||||||
|
|
||||||
|
from swchar import getName, charData
|
||||||
|
|
||||||
|
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):
|
def roll(abi : int = 1, prof : int = 0, dif : int = 3, cha : int = 0, boo : int = 0, setb : int = 0, force : int = 0):
|
||||||
result = ""
|
result = ""
|
||||||
@ -92,7 +99,10 @@ def diceToEmoji(dice : list):
|
|||||||
|
|
||||||
return emoji
|
return emoji
|
||||||
|
|
||||||
def parseRoll(user : str,cmd : str):
|
def getDice(user : str, skill : str):
|
||||||
|
return "yes"
|
||||||
|
|
||||||
|
def parseRoll(user : str,cmd : str = ""):
|
||||||
cmd = re.sub(' +',' ',cmd.upper()) + " "
|
cmd = re.sub(' +',' ',cmd.upper()) + " "
|
||||||
if cmd[0] == " ":
|
if cmd[0] == " ":
|
||||||
cmd = cmd[1:]
|
cmd = cmd[1:]
|
||||||
@ -102,6 +112,10 @@ def parseRoll(user : str,cmd : str):
|
|||||||
else:
|
else:
|
||||||
rollParameters = [0,0,0,0,0,0,0]
|
rollParameters = [0,0,0,0,0,0,0]
|
||||||
|
|
||||||
|
if string.capwords(cmd[0]) in skillData:
|
||||||
|
skillLevel = charData(user,"Skills " + string.capwords(cmd[0]))
|
||||||
|
charLevel = charData(user,"Characteristics " + string.capwords(skillData[cmd[0]]))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
for x in range(len(commands)):
|
for x in range(len(commands)):
|
||||||
if commands[x-1] != "":
|
if commands[x-1] != "":
|
||||||
@ -128,8 +142,10 @@ def parseRoll(user : str,cmd : str):
|
|||||||
|
|
||||||
simplified = simplify(rollResults)
|
simplified = simplify(rollResults)
|
||||||
|
|
||||||
if simplified != rollResults:
|
name = getName(user)
|
||||||
return user + " rolls " + diceToEmoji(rollParameters) + "\nResult: " + resultToEmoji(rollResults) + "\nSimplified: " + resultToEmoji(simplify(rollResults))
|
|
||||||
else:
|
if simplified != rollResults:
|
||||||
return user + " rolls " + diceToEmoji(rollParameters) + "\nResult: " + resultToEmoji(rollResults)
|
return name + " rolls " + diceToEmoji(rollParameters) + "\nResult: " + resultToEmoji(rollResults) + "\nSimplified: " + resultToEmoji(simplify(rollResults))
|
||||||
|
else:
|
||||||
|
return name + " rolls " + diceToEmoji(rollParameters) + "\nResult: " + resultToEmoji(rollResults)
|
||||||
|
|
||||||
|
4
testing.py
Normal file
4
testing.py
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
from swchar import charData
|
||||||
|
from swroll import parseRoll
|
||||||
|
|
||||||
|
print(charData("Template","Name","Jo Jo"))
|
Reference in New Issue
Block a user