File size: 3,591 Bytes
1f1a749
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import gradio as gr
import random

def generate_characters():
    class_list = ["Barbarian","Bard","Cleric","Druid","Fighter","Monk","Paladin","Ranger","Rogue","Sorcerer","Warlock","Wizard"]
    sub_class_list = ["Barbarian - Beserker","Barbarian - Wildheart","Barbarian - Wild Magic","Bard - College of Lore","Bard - College of Valour","Bard - College of Swords","Cleric - Life Domain","Cleric -  Light Domain","Cleric - Trickery Domain","Cleric - Knowledge Domain","Cleric - Nature Domain","Cleric - Tempest Domain","Cleric - War Domain","Druid - Circle of the moon","Druid - Circle of the Land","Druid - Circle of the Spores","Fighter - Battle Master","Fighter - Eldritch Knight","Fighter - Champion","Monk - Way of the open hand","Monk - Way of shadow","Monk - Way of the four elements","Paladin - Oath of Devotion","Paladin - Oath of the ancients","Paladin - Oath of Vengence","Paladin - Oathbreaker","Ranger - Beat Master","Ranger - Hunter","Ranger - Gloom Stalker","Rogue - Thief","Rogue - Arcane Trickster","Rogue - Assassin","Sorcerer - Draconic Bloodline","Sorcerer - Wild Magic","Sorcerer - Storm Sorcery","Warlock - The Fiend","Warlock - the great old one","Warlock - Archfey","Wizard - Abjuration","Wizard - Conjuration","Wizard - Divination","Wizard - Enchantment","Wizard - Evocation","Wizard - Necromancer","Wizard - Illusion","Wizard - Transmutation"]
    race_list = ["Dragonborn","Drow","Dwarf","Elf","Githyanki","Gnome","Half-Elf","Half-Orc","Halfling","Human","Tiefling"]
    sub_race_list = ["Black Dragonborn","Blue Dragonborn","Brass Dragonborn","Bronze Dragonborn","Copper Dragonborn","Gold Dragonborn","Green Dragonborn","Red Dragonborn","Silver Dragonborn","White Dragonborn","Lolth-Sworn Drow","Seldarine Drow","Gold Dwarf","Shield Dwarf","Duegar (Dwarf)","High Elf - Elf","Wood Elf - Elf","Githyanki","Deep Gnome","Forest Gnome","Rock Gnome","High Half-Elf","Wood Half-Elf","Drow Half-Elf","Half-Orc","Lightfoot Halfling","Strongheart Halfling","Human","Asmodeus Tiefling","Mephistopheles Tiefling","Zariel Tiefling"]
    alignment_list = ["Chaotic Good","Lawful Good","Neutral Good","Chaotic Evil","Lawful Evil","Neutral Evil","True Chaotic","True Neutral"]
    background_list = ["Acolyte","Charlatan","Criminal","Entertainer","Folk Hero","Guild Artisan","Noble","Hermit","Outlander","Sage","Soldier"]
    
    def generate_character():
        character = {
            'Class': random.choice(class_list),
            'Sub Class': random.choice(sub_class_list),
            'Race': random.choice(race_list),
            'Sub Race': random.choice(sub_race_list),
            'Alignment': random.choice(alignment_list),
            'Background': random.choice(background_list),
        }
        return character

    def generate_multiclass_character():
        character = generate_character()
        second_class = random.choice([cls for cls in class_list if cls != character['Class']])
        levels_class1 = random.randint(1, 11)
        levels_class2 = 12 - levels_class1
        character['Class'] += f' ({levels_class1} levels), {second_class} ({levels_class2} levels)'
        return character

    characters = [generate_character() for _ in range(2)]
    characters.append(generate_multiclass_character())
    
    output = ""
    for idx, char in enumerate(characters, 1):
        output += f"### Character {idx}:\n"
        for key, value in char.items():
            output += f"- **{key}:** {value}\n"
        output += "\n"
        
    return output

iface = gr.Interface(fn=generate_characters, inputs=[], outputs="markdown")
iface.launch()