Made the whole thing work

This commit is contained in:
NikolajDanger
2020-03-24 00:07:17 +01:00
parent 7a5d462a68
commit 9bb95cfa40
12 changed files with 119 additions and 40 deletions

1
funcs/__init__.py Normal file
View File

@ -0,0 +1 @@
from .gwendolynFuncs import helloFunc, roll_dice, cap, imageFunc, movieFunc, parseChar, parseRoll, spellFunc, monsterFunc, nameGen, tavernGen

View File

@ -6,10 +6,10 @@ import random #used by imageFunc
import urllib #used by imageFunc
import imdb #used by movieFunc
from roll import dice
from lookup import lookupFuncs
from other import movie, generators
from swfuncs import swchar, swroll
from .roll import dice
from .lookup import lookupFuncs
from .other import movie, generators
from .swfuncs import swchar, swroll
def roll_dice(author, rollStr: str = "1d20"):
print("Rolling "+str(rollStr))
@ -107,7 +107,7 @@ def movieFunc():
ia = imdb.IMDb()
print("Picking a movie")
movs = open("movies.txt", "r")
movs = open("funcs/other/movies.txt", "r")
movlist = movs.read().split("\n")
mov = random.choice(movlist)
movs.close()
@ -140,10 +140,10 @@ def spellFunc(content):
return lookupFuncs.spellFunc(content)
def monsterFunc(content):
return lookupFuncs.spellFunc(content)
return lookupFuncs.monsterFunc(content)
def nameGen():
return generators.nameGen
return generators.nameGen()
def tavernGen():
return generators.tavernGen
return generators.tavernGen()

View File

@ -1,28 +0,0 @@
**!hello** - En venlig hilsen.
**!roll** - Rul terninger i xdy format. Kan udføre matematik udover rullende. Kan også gøre følgende:
kx: Beholder kun rul med værdien x.
rox: Genrul rul med værdien x første gang.
rrx: Genrul alle rul med værdien x
mix: Gør alle rul under x til x.
max: Gør alle rul over x til x.
rax: Genruller og tilføjer rul med værdien x.
l/h før x: For de laveste/højeste x rul.
**!spell** - Slå en besværgelse op.
**!monster** - Slå et monster op.
**!map** - Få et billede af Senkulpa kortet.
**!image** - Find et tilfældigt billede fra internettet.
**!movie** - Giver titlen på en tilfældig film fra Bedre Netflix
**!name** - Genererer et tilfældigt navn.
**!tavern** - Genererer en tilfældig tavern.
**!swchar** - Lader dig lave en Star Wars karakter. Du kan bruge kommandoer som "!swchar name Jared" eller "!swchar skills astrogation 3" til at ændre din karakters info.
**!swroll** - Lader dig rulle Star Wars terninger. Du kan skrive tal der repræsenterer antallet af hver terning i rækkefølgen: ability, proficiency, difficulty, challenge, boost, setback og force. Du behøver ikke skrive et tal til alle terningerne. Du kan også skrive forbogstavet for terningen du vil rulle før antallet, såsom "!swroll f2", der ruller 2 force terninger.

View File

@ -23,8 +23,9 @@ def monsterFunc(content):
print("")
return("I don't know that monster...","","","","","")
else:
data = json.load(open('monsters.json', encoding = "utf8"))
data = json.load(open('funcs/lookup/monsters.json', encoding = "utf8"))
for monster in data:
print("Found it!")
if str(command) == monster["name"]:
if monster["subtype"] != "":
typs = (monster["type"]+" ("+monster["subtype"]+")")
@ -112,7 +113,7 @@ def monsterFunc(content):
def spellFunc(content):
command = gf.cap(content.lower().replace("!spell ",""))
print("Looking up "+command)
data = json.load(open('spells.json', encoding = "utf8"))
data = json.load(open('funcs/lookup/spells.json', encoding = "utf8"))
if str(command) in data:
print("Returning spell information")
spell_output = ("***"+str(command)+"***\n*"+str(data[str(command)]["level"])+" level "+str(data[str(command)]["school"])+"\nCasting Time: "+str(data[str(command)]["casting_time"])+"\nRange: "+str(data[str(command)]["range"])+"\nComponents: "+str(data[str(command)]["components"])+"\nDuration: "+str(data[str(command)]["duration"])+"*\n \n"+str(data[str(command)]["description"]))

View File

@ -8,7 +8,7 @@ def make_pairs(corpus):
yield (corpus[i], corpus[i+1])
def nameGen():
names = open('names.txt', encoding='utf8').read()
names = open('funcs/other/names.txt', encoding='utf8').read()
corpus = list(names)
pairs = make_pairs(corpus)

View File

@ -8,7 +8,7 @@ from re import IGNORECASE
import numexpr
import errors
from . import errors
log = logging.getLogger(__name__)

View File

@ -1,2 +1,73 @@
{
"Nikolaj": {
"Name": "Jared",
"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": 5,
"Agility": 0,
"Intellect": 0,
"Cunning": 0,
"Willpower": 0,
"Presence": 0
},
"Skills": {
"Astrogation": 0,
"Athletics": 0,
"Brawl": 1,
"Charm": 0,
"Coercion": 0,
"Computers": 0,
"Cool": 0,
"Coordination": 0,
"Core Worlds": 0,
"Discipline": 0,
"Gunnery": 0,
"Leadership": 0,
"Lightsaber": 0,
"Lore": 0,
"Mechanics": 0,
"Medicine": 0,
"Melee": 0,
"Negotiation": 0,
"Outer Rim": 0,
"Perception": 0,
"Piloting - Planetary": 0,
"Piloting - Space": 0,
"Ranged - Heavy": 0,
"Ranged - Light": 0,
"Resilience": 0,
"Skullduggery": 0,
"Stealth": 0,
"Streetwise": 0,
"Survival": 0,
"Underworld": 0,
"Vigilance": 0,
"Xenology": 0
},
"Lightsaber Characteristic": "Brawn",
"Obligations": {},
"Morality": {
"Emotional Weakness": "",
"Emotional Strength": "",
"Conflict": "",
"Morality": ""
},
"Credits": 0,
"Equipment": [],
"Armor": "",
"Critical Injuries": {},
"Weapons": {},
"Talents": {},
"Force Powers": {}
}
}

View File

@ -2,7 +2,7 @@ import json
import string
def getName(user : str):
with open("characters.json", "r") as f:
with open("funcs/swfuncs/characters.json", "r") as f:
data = json.load(f)
if user in data:
@ -81,7 +81,7 @@ def characterSheet(character : dict):
return name, text1+"\n\n"+text2+divider+text3
def charData(user : str,cmd : str):
with open("characters.json", "r") as f:
with open("funcs/swfuncs/characters.json", "r") as f:
data = json.load(f)
key = string.capwords(cmd.split(" ")[0])
@ -107,7 +107,7 @@ def charData(user : str,cmd : str):
if type(lookUpResult) is dict:
data[user][key] = lookUpResult
with open("characters.json", "w") as f:
with open("funcs/swfuncs/characters.json", "w") as f:
json.dump(data,f,indent = 4)
return "Changed " + data[user]["Name"] + "'s " + key
else:
@ -133,7 +133,7 @@ def charData(user : str,cmd : str):
return "Can't add that"
else:
data[user][key] = cmd
with open("characters.json", "w") as f:
with open("funcs/swfuncs/characters.json", "w") as f:
json.dump(data,f,indent = 4)
return "Changed " + data[user]["Name"] + "'s " + key +" to " + cmd
else:
@ -142,7 +142,7 @@ def charData(user : str,cmd : str):
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:
with open("funcs/swfuncs/characters.json", "r") as f:
data = json.load(f)
if cmd == " ":
@ -157,25 +157,25 @@ def parseChar(user : str, cmd : str):
if user in data:
return characterSheet(data[user])
else:
with open("templates.json", "r") as f:
with open("funcs/swfuncs/templates.json", "r") as f:
templates = json.load(f)
newChar = templates["Character"]
data[user] = newChar
with open("characters.json", "w") as f:
with open("funcs/swfuncs/characters.json", "w") as f:
json.dump(data,f,indent = 4)
return "", "Character for " + user + " created"
else:
return "", charData(user,cmd)
def lightsaberChar(user : str):
with open("characters.json", "r") as f:
with open("funcs/swfuncs/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:
with open("funcs/swfuncs/characters.json", "r") as f:
data = json.load(f)
return user in data

View File

@ -3,9 +3,9 @@ import re
import string
import json
import swchar
from . import swchar
with open("skills.json", "r") as f:
with open("funcs/swfuncs/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):