def new_window(): """create a new GUI for the creature, monster or bandit""" MonsterType = randint(0, 2) #choose creature, monster, or bandit if MonsterType == 0: Monster1 = choice(MISCELL_CREATURES) master = Toplevel() background = Image.open('Maps/PathPictures/Monster_Manual.jpg') background = background.resize((600, 300)) background = ImageTk.PhotoImage(background) m = Canvas(master, width=640, height=340, background="black") m.create_image(20, 20, image=background, anchor=NW) text1 = "Miscellaneous Creature\n" for i in Monster1: text1 += str(i) + '\n' m.create_text(20, 20, text=(text1), anchor=NW, fill="white", font=("Arial", 14, "bold", "underline")) m.pack() elif MonsterType == 1: Monster1 = choice(MONSTERS) master = Toplevel() background = Image.open('Maps/PathPictures/Misc_Creature.png') background = background.resize((600, 300)) background = ImageTk.PhotoImage(background) m = Canvas(master, width=640, height=340, background="black") m.create_image(20, 20, image=background, anchor=NW) text1 = "Monster Creature\n" for i in Monster1: text1 += str(i) + '\n' m.create_text(20, 20, text=(text1), anchor=NW, fill="black", font=("Arial", 14, "bold", "underline")) m.pack() else: def rand_spell(): """Function used to lookup D&D spell descriptions""" spells = [] spellbook = create_spellbook() for spell_level in spell_levels: spells.extend(spellbook[spellbook["Level"] == spell_level].values.tolist()) spell = choice(spells) try: spell = [str(x).replace("nan", "") for x in spell] except IndexError: return spell_des = spell[0] + "\n" + spell[1] + "\n" + spell[2] + \ "\n" + spell[3] + "\n" + spell[4] + "\n" + spell[5] +\ "\n" + spell[6] + "\n\n" + spell[7] + "\n" + spell[8] \ + "\n" + spell[9] + "\n" + spell[10] + "\n" + spell[11] return spell[0], spell_des CharBackground = choice(NPC_BACKGROUND) cast_level = ceil(EnemyLevel / 2) spell_levels = [ str('Level: ' + str(x)) for x in range(1, cast_level) ] spell1, sct1 = rand_spell() spell2, sct2 = rand_spell() spell3, sct3 = rand_spell() Weapon = [["Club", 4], ["Dagger", 4], ["Greatclub", 8], ["Handaxe", 6], ["Javelin", 6], ["Light Hammer", 4], ["Mace", 6], ["Quarterstaff", 6], ["Sickle", 4], ["Spear", 6], ["Crossbow, light", 8], ["Dart", 4], ["Shortbow", 6], ["Sling", 4], ["Battleaxe", 8], ["Flail", 8], ["Glaive", 10], ["Greataxe", 12], ["Greatsword", 6], ["Halberd", 10], ["Lance", 12], ["Longsword", 8], ["Maul", 6], ["Morningstar", 8], ["Pike", 10], ["Rapier", 8], ["Scimitar", 6], ["Shortsword", 6], ["Trident", 6]] humanoids = [Barbarian, Bard, Cleric, Druid, Fighter, \ Paladin, Rogue, Ranger, Wizard, Warlock, \ Sorcerer] races = [Human, HillDwarf, MountainDwarf, HighElf, \ WoodElf, ForestGnome, RockGnome, \ LightfootHalfling, StoutHalfling, \ Dragonborn, HalfElf, HalfOrc, \ InfernalTiefling] humanoid = choice(humanoids) race = choice(races) armorclass = choice(range(10, 25)) char = humanoid(race=race, level=EnemyLevel) WeaponPick = choice(range(0, len(Weapon))) name = " ".join([ 'A', 'Random', CharBackground[0], race.__name__, humanoid.__name__ ]) master = Toplevel() background = Image.open('Maps/PathPictures/bandits.jpg') background = background.resize((125, 125)) background = ImageTk.PhotoImage(background) def close_windows(): """Bandit kill button""" master.destroy() def remove_hit_points(): """Built in hitpoint calculator""" damage = w.CurrentHits.get() if damage == "": damage = 0 ct = int(w.Hits.get()) - int(damage) w.Hits.delete(0, 'end') w.Hits.insert(0, str(ct)) def lookupspell(): """Lookup the bandits spells""" master = Tk() Spellcanvas1 = Canvas(master, width=500, height=400) master.wm_title(spell1) Spellcanvas1.create_text(20, 20, text=sct1, width=400, anchor=NW) Spellcanvas1.pack(fill=BOTH, expand=YES) master = Tk() Spellcanvas2 = Canvas(master, width=500, height=400) master.wm_title(spell2) Spellcanvas2.create_text(20, 20, text=sct2, width=400, anchor=NW) Spellcanvas2.pack(fill=BOTH, expand=YES) master = Tk() Spellcanvas3 = Canvas(master, width=500, height=400) master.wm_title(spell3) Spellcanvas3.create_text(20, 20, text=sct3, width=400, anchor=NW) Spellcanvas3.pack(fill=BOTH, expand=YES) w = Canvas(master, width=500, height=250) master.wm_title(name) w.pack() w.create_image(250, 125, image=background) w.create_text(20, 20, text=str(Weapon[WeaponPick][0]) + " Damage Die = d" + str(Weapon[WeaponPick][1]), anchor=W, font=(36), width=800) w.create_text(20, 40, text=str(armorclass) + ' = Armor Class', anchor=W, font=(36), width=800) w.create_text(20, 60, text=str(char.hit_points) + ' = Max Hit Points', anchor=W, font=(36), width=800) w.create_text(20, 80, text=str(char.strength) + ' = strength', anchor=W, font=(36), width=800) w.create_text(20, 100, text=str(char.dexterity) + ' = dexterity', anchor=W, font=(36), width=800) w.create_text(20, 120, text=str(char.constitution) + ' = constitution', anchor=W, font=(36), width=800) w.create_text(20, 140, text=str(char.intelligence) + ' = intelligence', anchor=W, font=(36), width=800) w.create_text(20, 160, text=str(char.wisdom) + ' = wisdom', anchor=W, font=(36), width=800) w.create_text(20, 180, text=str(char.charisma) + ' = charisma', anchor=W, font=(36), width=800) w.create_text(460, 20, text='Spells', anchor=E, font=(36), width=800) w.create_text(480, 40, text=spell1, anchor=E, font=(36), width=800) w.create_text(480, 60, text=spell2, anchor=E, font=(36), width=800) w.create_text(480, 80, text=spell3, anchor=E, font=(36), width=800) killbutton1 = Button(master, text="kill", command=close_windows) killbutton1.pack() removehitpointsbutton2 = Button(master, text="Remove Hit Points", command=remove_hit_points) removehitpointsbutton2.pack() spelllookupbutton = Button(master, text="Look up spells", command=lookupspell) spelllookupbutton.place(x=480, y=120, anchor=E) w.CurrentHits = Entry(master, width=25) w.CurrentHits.pack() w.Hits = Entry(master, width=25) w.Hits.insert(0, char.hit_points) w.Hits.pack() mainloop()