From 6c42b32cd409e2e2c3e9ecf1feac5a7d333d6d65 Mon Sep 17 00:00:00 2001 From: nullifierwastaken Date: Tue, 20 Jan 2026 01:10:24 +1100 Subject: [PATCH] Added HP, Armor classes, weapons, armor, and a save file other than the database. Updated gitignore --- .gitignore | 2 ++ main.py | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e216b27 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +data.db +save.txt diff --git a/main.py b/main.py index 00b35ce..82fd26e 100644 --- a/main.py +++ b/main.py @@ -4,11 +4,31 @@ 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, main INTEGER)") + 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: @@ -38,7 +58,8 @@ if os.path.exists("data.db") == False: else: print("Not a valid input") - cursor.execute("INSERT INTO party (name, gender, race, class, level, exp, gold, strength, dexterity, constitution, intelligence, wisdom, charisma, main) VALUES (?, ?, ?, ?, 1, 0, 50, ?, ?, ?, ?, ?, ?, 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("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)") @@ -117,3 +138,27 @@ if os.path.exists("data.db") == False: 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") +