From a3dd2255b62bea6a2a97a99ea7bac495be88a0d2 Mon Sep 17 00:00:00 2001 From: NikolajDanger Date: Sun, 22 Mar 2020 17:26:57 +0100 Subject: [PATCH] Characters implemented sorta --- __pycache__/swchar.cpython-36.pyc | Bin 3188 -> 3940 bytes characters.json | 71 ----------------------------- swchar.py | 27 +++++++++++ templates.json | 73 ++++++++++++++++++++++++++++++ testing.py | 4 +- 5 files changed, 102 insertions(+), 73 deletions(-) create mode 100644 templates.json diff --git a/__pycache__/swchar.cpython-36.pyc b/__pycache__/swchar.cpython-36.pyc index ac9b0c12011b02b1a8b76bfc0d55452842fdc94f..20e451bb7d0f9cd38df48eda2dbb734f030f3e5e 100644 GIT binary patch delta 950 zcmYjPO-~b16us}w_jEcGD3mH{1F_huP;^5GMiX`>8Wkg^F@&b?DIW@WTZ3t)VF7MT z)R5V@=*q-}OT&L~;m(zY7&p3g=MV7SX>FY3ojK>-ci!BO`7`$G^yKAq+JAPqyYh7e z;3xd|Sj4Z$2tklP}sil_6>ln&csROHOYf}Xsq0%ZmFsn`y9q34vQG=x2z8+G; zq&@OVI-OM`r2L*5RXI{AC6=I+|M>QjwI`0f`dSTZ^`^$U=%vGNgVrLabB;iX2$al2 z4wR7t;%36Fgxd*sazK~5H(S=~>T0=+CfQm+x$H0P==!>D%onOokG4F2v4&dXd||X| zcWKKY8~S7_2`t86Qp4k6Ke44Xt((_58A$*Fr;a{ZKcqN5dhf0aaU&k^AB|5_q@Kiy z*tAa2N-Fpc@o#HlFA~bwlsK)-w%DqWGB*ued0r%D<*6`=Js@r?ctNGMMRG#o+%0%I zw+ub?ErQ6{w6WDRA|rx4>{BnBpd2Ol<(o`fHpPaF)$4z^>TKyI~adE*!Wdm2?RF+hxRHhWpIm{_sDcmir zQEXs7&m5){-W0wTmMC_hEYlpu6#f(eAddse6HE~T@;Fl%gBdhMHf}Rw-MoSA787IC z=5EeRMnn0QA3Ff&{4k;b diff --git a/characters.json b/characters.json index 060ddd1..7a73a41 100644 --- a/characters.json +++ b/characters.json @@ -1,73 +1,2 @@ { - "Template": { - "Name": "", - "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, - "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": {} - } } \ No newline at end of file diff --git a/swchar.py b/swchar.py index 37b1928..1140288 100644 --- a/swchar.py +++ b/swchar.py @@ -71,6 +71,9 @@ def lookUp(data : dict, key : str, cmd : str = ""): else: return key + " doesn't exist" +def characterSheet(character : dict): + return "```**"+character["Name"]+"**\nSpecies: "+character["Species"]+"\nCareer: "+character["Career"]+"```" + def charData(user : str,cmd : str): with open("characters.json", "r") as f: data = json.load(f) @@ -132,6 +135,30 @@ def charData(user : str,cmd : str): 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" + def lightsaberChar(user : str): with open("characters.json", "r") as f: data = json.load(f) diff --git a/templates.json b/templates.json new file mode 100644 index 0000000..efde848 --- /dev/null +++ b/templates.json @@ -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, + "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": {} + } +} \ No newline at end of file diff --git a/testing.py b/testing.py index fc1c33c..2673e33 100644 --- a/testing.py +++ b/testing.py @@ -1,4 +1,4 @@ -from swchar import charData +from swchar import charData, parseChar from swroll import parseRoll -print(charData("Template","characteristics ")) \ No newline at end of file +print(parseChar("Yeet","")) \ No newline at end of file