Obligation
This commit is contained in:
@ -208,7 +208,7 @@ def charData(user : str,cmd : str):
|
|||||||
except:
|
except:
|
||||||
return "Can't do that"
|
return "Can't do that"
|
||||||
|
|
||||||
if (key == "Talents" or key == "Force-powers" or key == "Obligation") and "," in cmd:
|
if (key == "Talents" or key == "Force-powers") and "," in cmd:
|
||||||
cmd = cmd.split(",")
|
cmd = cmd.split(",")
|
||||||
while cmd[1][0] == " ":
|
while cmd[1][0] == " ":
|
||||||
cmd[1] = cmd[1][1:]
|
cmd[1] = cmd[1][1:]
|
||||||
@ -217,6 +217,18 @@ def charData(user : str,cmd : str):
|
|||||||
json.dump(data,f,indent = 4)
|
json.dump(data,f,indent = 4)
|
||||||
return cmd[0]+" added to "+key+" for " + data[user]["Name"]
|
return cmd[0]+" added to "+key+" for " + data[user]["Name"]
|
||||||
|
|
||||||
|
elif key == "Obligations" and "," in cmd:
|
||||||
|
cmd = cmd.split(",")
|
||||||
|
while cmd[1][0] == " ":
|
||||||
|
cmd[1] = cmd[1][1:]
|
||||||
|
try:
|
||||||
|
data[user][key][cmd[0]] = int(cmd[1])
|
||||||
|
except:
|
||||||
|
return "Wrong data type"
|
||||||
|
with open("resources/swcharacters.json", "w") as f:
|
||||||
|
json.dump(data,f,indent = 4)
|
||||||
|
return cmd[0]+" added to "+key+" for " + data[user]["Name"]
|
||||||
|
|
||||||
elif key == "Weapons":
|
elif key == "Weapons":
|
||||||
with open("resources/swtemplates.json", "r") as f:
|
with open("resources/swtemplates.json", "r") as f:
|
||||||
templates = json.load(f)
|
templates = json.load(f)
|
||||||
|
@ -103,6 +103,22 @@ def diceToEmoji(dice : list):
|
|||||||
def getDice(user : str, skill : str):
|
def getDice(user : str, skill : str):
|
||||||
return "yes"
|
return "yes"
|
||||||
|
|
||||||
|
def obligationRoll():
|
||||||
|
with open("resources/swcharacters.json", "r") as f:
|
||||||
|
data = json.load(f)
|
||||||
|
|
||||||
|
table = []
|
||||||
|
|
||||||
|
for character in data:
|
||||||
|
for obligation in data[character]["Obligations"]:
|
||||||
|
for x in range(data[character]["Obligations"][obligation]):
|
||||||
|
table.append(obligation)
|
||||||
|
|
||||||
|
while len(table) < 100:
|
||||||
|
table.append("Nothing")
|
||||||
|
|
||||||
|
return random.choice(table)
|
||||||
|
|
||||||
def parseRoll(user : str,cmd : str = ""):
|
def parseRoll(user : str,cmd : str = ""):
|
||||||
cmd = re.sub(' +',' ',cmd.upper()) + " "
|
cmd = re.sub(' +',' ',cmd.upper()) + " "
|
||||||
if cmd[0] == " ":
|
if cmd[0] == " ":
|
||||||
@ -115,7 +131,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(commands[0]) in skillData:
|
if string.capwords(commands[0]) == "Obligations":
|
||||||
|
return obligationRoll()
|
||||||
|
|
||||||
|
elif string.capwords(commands[0]) in skillData:
|
||||||
if swchar.userHasChar:
|
if swchar.userHasChar:
|
||||||
skillLevel = swchar.charData(user,"Skills " + string.capwords(commands[0]))
|
skillLevel = swchar.charData(user,"Skills " + string.capwords(commands[0]))
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user