import sqlite3 from random import randint import os races = ["Hill Dwarf", "Mountain Dwarf", "High Elf", "Wood Elf", "Drow", "Lightfoot Halfling", "Stout Halfling", "Human", "Dragonborn", "Forest Gnome", "Rock Gnome", "Half-Orc", "Tiefling", "Aasimar", "Eladrin Elf", "Aarakocra", "Deep Gnome", "Air Genasi", "Earth Genasi", "Fire Genasi", "Water Genasi", "Grey Duergar Dwarf", "Ghostwise Halfling", "Deep Svirfneblin Gnome", "Feral Tiefling", "Protector Aasimar", "Scourge Aasimar", "Fallen Aasimar", "Firbolg", "Goliath", "Kenku", "Lizardfolk", "Tabaxi", "Triton", "Bugbear", "Goblin", "Hobgoblin", "Kobold", "Orc", "Yuan-ti Pureblood", "Sea Elf", "Shadar-kai Elf", "Duergar Dwarf", "Githyanki", "Githzerai", "Tortle", "Verdan", "Kalashtar", "Beasthide Shifter", "Longtooth Shifter", "Swiftstride Shifter", "Wildhunt Swiftstride", "Centaur", "Loxodon", "Minotaur", "Vedalken", "Leonin", "Satyr"] classes = ["Barbarian", "Bard", "Cleric", "Druid", "Fighter", "Monk", "Paladin", "Ranger", "Rogue", "Sorcerer", "Warlock", "Wizard", "Artificer"] genders = ["male", "female", "non-binary"] weapons = [("Quarterstaff", "One Handed Melee", "1d6"), ("Longsword", "Two Handed Melee", "1d8"), ("Dagger", "One Handed Melee", "1d4"), ("Long Bow", "Physical Ranged", "1d8"), ("Shortbow", "Physical Ranged", "1d6"), ("Club", "One Handed Melee", "1d4"), ("Greatclub", "Two Handed Melee", "1d8"), ("Handaxe", "One Handed Melee", "1d6"), ("Javelin", "Physical Ranged", "1d6"), ("Light Hammer", "One Handed Melee", "1d4"), ("Mace", "One Handed Melee", "1d6"). ("Sickle", "One Handed Melee", "1d4"), ("Spear", "Two Handed Melee", "1d6"), ("Light Crossbow", "Physical Ranged", "1d8"), ("Dart", "Physical Ranged", "1d4"), ("Sling", "Physical Ranged", "1d4"), ("Battleaxe", "Two Handed Melee", "1d8"), ("Flail", "Two Handed Melee", "1d8"), ("Glaive", "Two Handed Melee", "1d10"), ("Greataxe", "Two Handed Melee", "1d12"), ("Greatsword", "Two Handed Melee", "2d6"), ("Halberd", "Two Handed Melee", "1d10"), ("Lance", "Two Handed Melee", "1d12"), ("Maul", "Two Handed Melee", "2d6"), ("Morningstar", "One Handed Melee", "1d8"), ("Pike", "Two Handed Melee", "1d10"), ("Rapier", "One Handed Melee", "1d8"), ("Scimitar", "One Handed Melee", "1d6"), ("Shortsword", "One Handed Melee", "1d6"), ("Trident", "One Handed Melee", "1d6"), ("War Pick", "One Handed Melee", "1d8"), ("Warhammer", "One Handed Melee", "1d8"), ("Whip", "One Handed Melee", "1d4"), ("Blowgun", "Physical Ranged", "1"), ("Hand Crossbow", "Physical Ranged", "1d10"), ("Heavy Crossbow", "Physical Ranged", "1d10")] armor = [("Padded", 11, "Light", 5), ("Leather", 11, "Light", 10), ("Studded Leather", 12, "Light", 45), ("Hide", 12, "Medium", 10), ("Chain Shirt", 13, "Medium", 10), ("Scale Mail", 14, "Medium", 50), ("Spiked Armor", 14, "Medium", 75), ("Halfplate", 15, "Medium", 750), ("Ring Mail", 14, "Heavy", 30), ("Chain Mail", 16, "Heavy", 75), ("Splint", 17, "Heavy", 200), ("Plate", 18, "Heavy", 1500), ("Shield", 2, "Shield", 10)] mods = { 1: -5, 2: -4, 4: -3, 6: -2, 8: -1, 10: 0, 12: 1, 14: 2, 16: 3, 18: 4, 20: 5, 22: 6, 24: 7, 26: 8, 28: 9, 30: 10 } if os.path.exists("data.db") == False: db = sqlite3.connect("data.db") cursor = db.cursor() cursor.execute("CREATE TABLE party (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, gender TEXT, race TEXT, class TEXT, level INTEGER, exp INTEGER, gold INTEGER, strength INTEGER, dexterity INTEGER, constitution INTEGER, intelligence INTEGER, wisdom INTEGER, charisma INTEGER, maxhp INTEGER, armorclass INTEGER, main INTEGER)") cursor.execute("CREATE TABLE races (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, strength INTEGER, dexterity INTEGER, constitution INTEGER, intelligence INTEGER, wisdom INTEGER, charisma INTEGER)") mainname = input("What do you wish to be called? ") while True: maingender = input("What gender are you? (Male, Female, Non-Binary) ") if maingender.lower() not in genders: print("Not a valid input") else: break while True: mainrace = input("Which race do you wish to be (type help for list of races) ") if mainrace.lower() == "help": for i in races: print(i) elif mainrace.title() in races: break else: print("Not a valid input") while True: mainclass = input("Which class do you wish to be (type help for list of classes) ") if mainclass.lower() == "help": for i in classes: print(i) elif mainclass.title() in classes: break else: print("Not a valid input") cursor.execute("INSERT INTO party (name, gender, race, class, level, exp, gold, strength, dexterity, constitution, intelligence, wisdom, charisma, maxhp, armorclass, main) VALUES (?, ?, ?, ?, 1, 0, 50, ?, ?, ?, ?, ?, ?, 1, 1, 1)", (mainname.title(), maingender.title(), mainrace.title(), mainclass.title(), (randint(1,6) + randint(1,6) + randint(1,6) + randint(1,6)), (randint(1,6) + randint(1,6) + randint(1,6) + randint(1,6)), (randint(1,6) + randint(1,6) + randint(1,6) + randint(1,6)), (randint(1,6) + randint(1,6) + randint(1,6) + randint(1,6)), (randint(1,6) + randint(1,6) + randint(1,6) + randint(1,6)), (randint(1,6) + randint(1,6) + randint(1,6) + randint(1,6)))) cursor.execute("CREATE TABLE maininventory (id INTEGER PRIMARY KEY AUTOINCREMENT, itemname TEXT, amount INTEGER, equipped INTEGER") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Hill Dwarf', 0, 0, 2, 0, 1, 0)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Mountain Dwarf', 2, 0, 2, 0, 0, 0)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('High Elf', 0, 2, 0, 1, 0, 0)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Wood Elf', 0, 2, 0, 0, 1, 0)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Drow', 0, 2, 0, 0, 0, 1)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Lightfoot Halfling', 0, 2, 1, 0, 0, 0)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Stout Halfling', 0, 2, 1, 0, 0, 0)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Human', 1, 1, 1, 1, 1, 1)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Dragonborn', 2, 0, 0, 0, 0, 1)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Forest Gnome', 0, 1, 0, 2, 0, 0)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Rock Gnome', 0, 1, 0, 2, 0, 0)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Half-Orc', 2, 0, 1, 0, 0, 0)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Tiefling', 0, 0, 0, 1, 0, 2)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Aasimar', 0, 0, 0, 0, 1, 2)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Eladrin Elf', 0, 2, 0, 1, 0, 0)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Aarkocra', 0, 2, 0, 0, 1, 0)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Deep Gnome', 0, 1, 0, 2, 0, 0)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Air Genasi', 0, 1, 2, 0, 0, 0)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Earth Genasi', 1, 0, 2, 0, 0, 0)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Fire Genasi', 0, 0, 2, 1, 0, 0)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Water Genasi', 0, 0, 2, 0, 1, 0)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Goliath', 2, 0, 1, 0, 0, 0)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Grey Duergar Dwarf', 1, 0, 2, 0, 0, 0)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Ghostwise Halfling', 1, 0, 2, 0, 0, 0)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Deep Svirfneblin Gnome', 0, 1, 0, 2, 0, 0)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Feral Tiefling', 0, 2, 0, 1, 0, 0)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Protector Aasimar', 0, 0, 0, 0, 1, 2)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Scourge Aasimar', 0, 0, 1, 0, 0, 2)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Fallen Aasimar', 1, 0, 0, 0, 0, 2)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Firbolg', 1, 0, 0, 0, 2, 0)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Kenku', 0, 2, 0, 0, 1, 0)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Lizardfolk', 0, 0, 2, 0, 1, 0)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Tabaxi', 0, 2, 0, 0, 0, 1)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Triton', 1, 0, 1, 0, 0, 1)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Bugbear', 2, 1, 0, 0, 0, 0)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Goblin', 0, 2, 1, 0, 0, 0)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Hobgoblin', 0, 0, 2, 1, 0, 0)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Kobold', 0, 2, 0, 0, 0, 0)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Orc', 2, 0, 1, 0, 0, 0)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Yuan-ti Pureblood', 0, 0, 0, 1, 0, 2)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Sea Elf', 0, 2, 1, 0, 0, 0)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Shadar-kai Elf', 0, 2, 1, 0, 0, 0)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Duergar Dwarf', 1, 0, 2, 0, 0, 0)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Githyanki', 2, 0, 0, 1, 0, 0)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Githzerai', 0, 0, 0, 1, 2, 0)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Tortle', 2, 0, 0, 0, 1, 0)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Verdan', 0, 0, 1, 0, 0, 2)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Kalashtar', 0, 0, 0, 0, 2, 1)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Beasthide Shifter', 1, 0, 2, 0, 0, 0)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Longtooth Shifter', 2, 1, 0, 0, 0, 0)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Swiftstride Shifter', 0, 2, 0, 0, 0, 1)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Wildhunt Swiftstride', 0, 1, 0, 0, 2, 0)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Centaur', 2, 0, 0, 0, 1, 0)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Loxodon', 0, 0, 2, 0, 1, 0)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Minotaur', 2, 0, 1, 0, 0, 0)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Vedalken', 0, 0, 0, 2, 1, 0)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Leonin', 1, 0, 2, 0, 0, 0)") cursor.execute("INSERT INTO races (name, strength, dexterity, constitution, intelligence, wisdom, charisma) VALUES ('Satyr', 0, 1, 0, 0, 0, 2)") db.commit() cursor.execute("SELECT races.strength, races.dexterity, races.constitution, races.intelligence, races.wisdom, races.charisma FROM races INNER JOIN party ON races.name = party.race WHERE party.main = 1") modifiers = cursor.fetchone() cursor.execute("UPDATE party SET strength = strength + ? WHERE main = 1", (modifiers[0],)) cursor.execute("UPDATE party SET dexterity = dexterity + ? WHERE main = 1", (modifiers[1],)) cursor.execute("UPDATE party SET constitution = constitution + ? WHERE main = 1", (modifiers[2],)) cursor.execute("UPDATE party SET intelligence = intelligence + ? WHERE main = 1", (modifiers[3],)) cursor.execute("UPDATE party SET wisdom = wisdom + ? WHERE main = 1", (modifiers[4],)) cursor.execute("UPDATE party SET charisma = charisma + ? WHERE main = 1", (modifiers[5],)) db.commit() cursor.execute("SELECT strength, dexterity, constitution, intelligence, wisdom, charisma FROM party WHERE main = 1") mainstats = cursor.fetchone() print("Your stats: ") print(f'Strength: {mainstats[0]}') print(f'Dexterity: {mainstats[1]}') print(f'Constitution: {mainstats[2]}') print(f'Intelligence: {mainstats[3]}') print(f'Wisdom: {mainstats[4]}') print(f'Charisma: {mainstats[5]}') cursor.execute("SELECT class FROM party WHERE main = 1") mainclass = cursor.fetchone() if mainclass[0] == "Barbarian": hp = randint(1,12) elif mainclass[0] == "Fighter" or mainclass[0] == "Paladin" or mainclass[0] == "Ranger": hp = randint(1,10) elif mainclass[0] == "Sorcerer" or mainclass[0] == "Wizard": hp = randint(1,6) else: hp = randint(1,8) print(f"Your max hp: {hp}") cursor.execute("UPDATE party SET maxhp = ? WHERE main = 1", (hp,)) for k in range(len(mods.keys())): if mods.keys()[k] <= mainstats[1] and mods.keys()[k+1] > mainstats[1]: dexmod = mods[mods.keys()[k]] armorclass = 10 + dexmod print(f"Your armor class: {armorclass}") cursor.execute("UPDATE party SET armorclass = ? WHERE main = 1", (armorclass,)) with open("save.txt", "w") as file: file.write("Location: Beginner Tavern\nTurn: 0")