Character Template
This commit is contained in:
Binary file not shown.
Binary file not shown.
@ -20,8 +20,54 @@
|
||||
"Willpower": 0,
|
||||
"Presence": 0
|
||||
},
|
||||
"Skills" : {
|
||||
|
||||
}
|
||||
"Skills": {
|
||||
"Astrogation": 0,
|
||||
"Computers": 0,
|
||||
"Cool": 0,
|
||||
"Vigilance": 0,
|
||||
"Mechanics": 0,
|
||||
"Melee": 0,
|
||||
"Perception": 0,
|
||||
"Piloting - Space": 0,
|
||||
"Ranged - Heavy": 0,
|
||||
"Ranged - Light": 0,
|
||||
"Athletics": 0,
|
||||
"Coercion": 0,
|
||||
"Coordination": 0,
|
||||
"Charm": 0,
|
||||
"Medicine": 0,
|
||||
"Negotiation": 0,
|
||||
"Piloting - Planetary": 0,
|
||||
"Stealth": 0,
|
||||
"Skullduggery": 0,
|
||||
"Brawl": 0,
|
||||
"Discipline": 0,
|
||||
"Gunnery": 0,
|
||||
"Core Worlds": 0,
|
||||
"Outer Rim": 0,
|
||||
"Underworld": 0,
|
||||
"Leadership": 0,
|
||||
"Lore": 0,
|
||||
"Resilience": 0,
|
||||
"Streetwise": 0,
|
||||
"Survival": 0,
|
||||
"Xenology": 0,
|
||||
"Lightsaber": 0
|
||||
},
|
||||
"Lightsaber Characteristic": "Brawn",
|
||||
"Obligations": {},
|
||||
"Morality": {
|
||||
"Emotional Weakness": "",
|
||||
"Emotional Strength": "",
|
||||
"Conflict": "",
|
||||
"Morality": ""
|
||||
},
|
||||
"Credits": 0,
|
||||
"Equipment": [],
|
||||
"Armor": "",
|
||||
"Critical Injuries": {},
|
||||
"Weapons": {},
|
||||
"Talents": {},
|
||||
"Force Powers": {}
|
||||
}
|
||||
}
|
@ -29,5 +29,6 @@
|
||||
"Resilience" : "Brawn",
|
||||
"Streetwise" : "Cunning",
|
||||
"Survival" : "Cunning",
|
||||
"Xenology" : "Intellect"
|
||||
"Xenology" : "Intellect",
|
||||
"Lightsaber" : "Brawn"
|
||||
}
|
98
swchar.py
98
swchar.py
@ -11,20 +11,54 @@ def getName(user : str):
|
||||
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"
|
||||
if bool(dict):
|
||||
keys = list(cmd)
|
||||
values = list(cmd.values())
|
||||
result = ""
|
||||
if type(values[0]) is dict:
|
||||
return ", ".join(values)
|
||||
else:
|
||||
result += keys[x] + ": " + str(values[x]) + "\n"
|
||||
return 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
|
||||
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 == "":
|
||||
return data[key]
|
||||
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:]
|
||||
@ -34,12 +68,22 @@ def lookUp(data : dict, key : str, cmd : str = ""):
|
||||
return data
|
||||
except:
|
||||
return "Wrong data type"
|
||||
else:
|
||||
return key + " doesn't exist"
|
||||
|
||||
def charData(user : str, key : str,cmd : str = ""):
|
||||
def charData(user : str,cmd : str):
|
||||
with open("characters.json", "r") as f:
|
||||
data = json.load(f)
|
||||
|
||||
key = string.capwords(key)
|
||||
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]:
|
||||
@ -47,7 +91,7 @@ def charData(user : str, key : str,cmd : str = ""):
|
||||
if cmd == "":
|
||||
return setUpDict(data[user][key])
|
||||
else:
|
||||
newKey = cmd.split(" ")[0]
|
||||
newKey = string.capwords(cmd.split(" ")[0])
|
||||
newcmd = cmd[len(newKey):]
|
||||
|
||||
lookUpResult = lookUp(data[user][key],newKey,newcmd)
|
||||
@ -62,6 +106,22 @@ def charData(user : str, key : str,cmd : str = ""):
|
||||
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:
|
||||
@ -71,3 +131,17 @@ def charData(user : str, key : str,cmd : str = ""):
|
||||
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 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
|
||||
|
||||
|
26
swroll.py
26
swroll.py
@ -3,7 +3,7 @@ import re
|
||||
import string
|
||||
import json
|
||||
|
||||
from swchar import getName, charData
|
||||
from swchar import getName, charData, lightsaberChar, userHasChar
|
||||
|
||||
with open("skills.json", "r") as f:
|
||||
skillData = json.load(f)
|
||||
@ -112,9 +112,27 @@ def parseRoll(user : str,cmd : str = ""):
|
||||
else:
|
||||
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]]))
|
||||
if string.capwords(commands[0]) in skillData:
|
||||
if userHasChar:
|
||||
skillLevel = charData(user,"Skills " + string.capwords(commands[0]))
|
||||
|
||||
if string.capwords(commands[0]) == "Lightsaber":
|
||||
charLevel = charData(user,"Characteristics " + lightsaberChar(user))
|
||||
else:
|
||||
charLevel = 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)):
|
||||
|
@ -1,4 +1,4 @@
|
||||
from swchar import charData
|
||||
from swroll import parseRoll
|
||||
|
||||
print(charData("Template","Name","Jo Jo"))
|
||||
print(charData("Template","characteristics "))
|
Reference in New Issue
Block a user