Changes to stuff
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
from .gwendolynFuncs import helloFunc, roll_dice, cap, imageFunc
|
||||
|
||||
from .swfuncs import parseChar, parseRoll
|
||||
from .swfuncs import parseChar, parseRoll, parseDestiny
|
||||
|
||||
from .lookup import spellFunc, monsterFunc
|
||||
|
||||
|
@ -106,3 +106,5 @@ def imageFunc():
|
||||
# Returns the image
|
||||
print("Successfully returned an image\n")
|
||||
return(image)
|
||||
|
||||
|
||||
|
@ -1,2 +1,3 @@
|
||||
from .swchar import parseChar
|
||||
from .swroll import parseRoll
|
||||
from .swroll import parseRoll
|
||||
from .swdestiny import parseDestiny
|
@ -99,7 +99,17 @@ def lookUp(data : dict, key : str, cmd : str = ""):
|
||||
else:
|
||||
while cmd[0] == ' ':
|
||||
cmd = cmd[1:]
|
||||
if type(data[key]) != list:
|
||||
|
||||
if type(data[key]) is dict:
|
||||
newKey = cmd.split(" ")[0]
|
||||
cmd = cmd[len(newKey):]
|
||||
while cmd[0] == " ":
|
||||
cmd = cmd[1:]
|
||||
if cmd == "":
|
||||
break
|
||||
data[key] = lookUp(data[key],newKey,cmd)
|
||||
return data
|
||||
elif type(data[key]) != list:
|
||||
try:
|
||||
cmd = type(data[key])(cmd)
|
||||
data[key] = cmd
|
||||
@ -162,13 +172,12 @@ def characterSheet(character : dict):
|
||||
text8 = ""
|
||||
|
||||
if bool(character["Talents"]):
|
||||
text5 = "**Talents**: "+",".join(list(character["Talents"]))+"\n\n"
|
||||
text5 = "**Talents**: "+", ".join(list(character["Talents"]))+"\n\n"
|
||||
|
||||
if bool(character["Force-powers"]):
|
||||
text6 = "**Force Powers**: "+",".join(list(character["Force-powers"]))+"\n\n"
|
||||
text6 = "**Force Powers**: "+", ".join(list(character["Force-powers"]))+"\n\n"
|
||||
|
||||
if bool(character["Weapons"]):
|
||||
text7 = "**Weapons**: "+",".join(list(character["Weapons"]))+"\n"+divider
|
||||
text7 = "**Equipment**: "+", ".join(character["Equipment"])+"\n**Credits**: "+str(character["Credits"])+"\n**Weapons**: "+", ".join(list(character["Weapons"]))+"\n"+divider
|
||||
|
||||
if bool(character["Obligations"]):
|
||||
text8 = "**Obligations**: "+",".join(list(character["Obligations"]))
|
||||
@ -250,7 +259,7 @@ def charData(user : str,cmd : str):
|
||||
except:
|
||||
return "Can't do that"
|
||||
|
||||
if key == "Talents" or key == "Force-powers" or key == "Weapons":
|
||||
if key == "Talents" or key == "Force-powers" or key == "Weapons" or key == "Obligations":
|
||||
if cmd in data[user][key]:
|
||||
del data[user][key][cmd]
|
||||
with open("resources/swcharacters.json", "w") as f:
|
||||
@ -298,7 +307,7 @@ def charData(user : str,cmd : str):
|
||||
data[user][key] = beforeData+ int(cmd)
|
||||
with open("resources/swcharacters.json", "w") as f:
|
||||
json.dump(data,f,indent = 4)
|
||||
return "Added " + cmd + " to " + user + "'s " + key
|
||||
return "Added " + cmd + " to " + data[user]["Name"] + "'s " + key
|
||||
except:
|
||||
return "Can't add that"
|
||||
elif type(data[user][key]) is list:
|
||||
@ -306,7 +315,7 @@ def charData(user : str,cmd : str):
|
||||
data[user][key].append(cmd)
|
||||
with open("resources/swcharacters.json", "w") as f:
|
||||
json.dump(data,f,indent = 4)
|
||||
return "Added " + cmd + " to " + user + "'s " + key
|
||||
return "Added " + cmd + " to " + data[user]["Name"] + "'s " + key
|
||||
except:
|
||||
return "Can't add that"
|
||||
else:
|
||||
@ -325,7 +334,7 @@ def charData(user : str,cmd : str):
|
||||
data[user][key] = beforeData - int(cmd)
|
||||
with open("resources/swcharacters.json", "w") as f:
|
||||
json.dump(data,f,indent = 4)
|
||||
return "Subtracted " + cmd + " from " + user + "'s " + key
|
||||
return "Subtracted " + cmd + " from " + data[user]["Name"] + "'s " + key
|
||||
except:
|
||||
return "Can't remove that"
|
||||
elif type(data[user][key]) is list:
|
||||
@ -337,7 +346,7 @@ def charData(user : str,cmd : str):
|
||||
return "Not in list"
|
||||
with open("resources/swcharacters.json", "w") as f:
|
||||
json.dump(data,f,indent = 4)
|
||||
return "Removed " + cmd + " from " + user + "'s " + key
|
||||
return "Removed " + cmd + " from " + data[user]["Name"] + "'s " + key
|
||||
except:
|
||||
return "Can't remove that"
|
||||
else:
|
||||
@ -412,7 +421,7 @@ def parseChar(user : str, cmd : str):
|
||||
with open("resources/swcharacters.json", "w") as f:
|
||||
json.dump(data,f,indent = 4)
|
||||
return "", "Character for " + user + " deleted"
|
||||
return "", replaceWithSpaces(charData(user,cmd))
|
||||
return "", replaceWithSpaces(str(charData(user,cmd)))
|
||||
|
||||
def lightsaberChar(user : str):
|
||||
with open("resources/swcharacters.json", "r") as f:
|
||||
|
53
funcs/swfuncs/swdestiny.py
Normal file
53
funcs/swfuncs/swdestiny.py
Normal file
@ -0,0 +1,53 @@
|
||||
from . import swroll
|
||||
|
||||
def destinyNew(num : int):
|
||||
roll = swroll.roll(0,0,0,0,0,0,num)
|
||||
|
||||
with open("resources/destinyPoints.txt","wt") as f:
|
||||
f.write(roll)
|
||||
|
||||
return "Rolled for Destiny Points and got:\n"+swroll.resultToEmoji(roll)
|
||||
|
||||
def destinyUse(user : str):
|
||||
with open("resources/destinyPoints.txt","rt") as f:
|
||||
points = f.read()
|
||||
|
||||
if user == "Nikolaj":
|
||||
if 'B' in points:
|
||||
points = points.replace("B","L",1)
|
||||
with open("resources/destinyPoints.txt","wt") as f:
|
||||
f.write(points)
|
||||
return "Used a dark side destiny point. Destiny pool is now:\n"+swroll.resultToEmoji(points)
|
||||
else:
|
||||
return "No dark side destiny points"
|
||||
else:
|
||||
if 'L' in points:
|
||||
points = points.replace("L","B",1)
|
||||
with open("resources/destinyPoints.txt","wt") as f:
|
||||
f.write(points)
|
||||
return "Used a light side destiny point. Destiny pool is now:\n"+swroll.resultToEmoji(points)
|
||||
else:
|
||||
return "No light side destiny points"
|
||||
|
||||
def parseDestiny(user : str, cmd : str):
|
||||
if cmd != "":
|
||||
while cmd[0] == ' ':
|
||||
cmd = cmd[1:]
|
||||
if cmd == "":
|
||||
break
|
||||
|
||||
|
||||
if cmd == "":
|
||||
with open("resources/destinyPoints.txt","rt") as f:
|
||||
return swroll.resultToEmoji(f.read())
|
||||
else:
|
||||
commands = cmd.upper().split(" ")
|
||||
if commands[0] == "N":
|
||||
if len(commands) > 1:
|
||||
return destinyNew(int(commands[1]))
|
||||
else:
|
||||
return "You need to give an amount of players"
|
||||
elif commands[0] == "U":
|
||||
return destinyUse(user)
|
||||
else:
|
||||
return "I didn't quite understand that"
|
@ -80,6 +80,16 @@ def resultToEmoji(result : str):
|
||||
|
||||
return emoji
|
||||
|
||||
def emojiToResult(emoji : str):
|
||||
result = ""
|
||||
for char in emoji:
|
||||
if char == "<:light:691010089905029171>":
|
||||
emoji += 'L'
|
||||
if char == "<:dark:691010101901000852>":
|
||||
emoji += 'B'
|
||||
|
||||
return result
|
||||
|
||||
def diceToEmoji(dice : list):
|
||||
emoji = ""
|
||||
|
||||
@ -112,7 +122,7 @@ def obligationRoll():
|
||||
for character in data:
|
||||
for obligation in data[character]["Obligations"]:
|
||||
for x in range(data[character]["Obligations"][obligation]):
|
||||
table.append(obligation)
|
||||
table.append(data[character]["Name"]+", "+obligation)
|
||||
|
||||
while len(table) < 100:
|
||||
table.append("Nothing")
|
||||
@ -124,7 +134,6 @@ def parseRoll(user : str,cmd : str = ""):
|
||||
if cmd[0] == " ":
|
||||
cmd = cmd[1:]
|
||||
cmd = swchar.replaceSpaces(cmd.capitalize())
|
||||
print(cmd)
|
||||
commands = cmd.split(" ")
|
||||
if commands[0] == "":
|
||||
rollParameters = [1,0,3,0,0,0,0]
|
||||
|
Reference in New Issue
Block a user