コード例 #1
0
    def __guild(self):
        # All possible guild quests
        r = randint(0, 11)
        if r == 0:
            self.Title = 'Adventurers Guild'
        elif r == 1:
            self.Title = 'Arcane Guild'
        elif r == 2:
            self.Title = 'Laborers Guild'
        elif r == 3:
            self.Title = 'Performers Guild'
        elif r == 4:
            self.Title = 'Scholastic Guild'
        elif r == 5:
            self.Title = 'Merchant Guild'
        elif r == 6:
            self.Title = 'Bardic Guild'
        elif r == 7:
            self.Title = 'Military Guild'
        elif r == 8:
            self.Title = 'Thieves Guild'
        elif r == 9:
            self.Title = 'Assassin Guild'
        elif r == 10:
            self.Title = 'Gladiator Guild'

        location = quest_location[randint(len(quest_location))].lower()
        self.Other = create_person(None)
        self.Hook = "We're a new chapter of the " + self.Title + ' and we are looking for some new talent and faces' + \
                    '. If you are interested in joining, please see ' + self.Reporter.Name + ' ' + location + \
                    '.\nFor more information, please see ' + self.Other.Name + '.'
コード例 #2
0
def generate_people(pc, npc, town_name, dump_json=False, to_file=True):
    global characters, positions
    full_town = {}
    if dump_json:
        full_town = json.load(open(town_name + '.town.json', 'r'))

    for k in range(len(characters)):
        write_npc(characters[k], positions[k])
        full_town[positions[k]] = characters[k]

    for p in pc:
        person = create_person(create_variance())
        write_people(person, p)
        full_town[p] = person

    for p in npc:
        person = PC.PC()
        write_npc(person, p)
        full_town[p] = person

    if dump_json:
        try:
            json.dump(full_town,
                      open(town_name + ".town.json", 'w'),
                      indent=4,
                      sort_keys=True,
                      default=lambda x: x.__dict__)
        except Exception as e:
            raise e

    print("Writing the town ", town_name)
    if to_file:
        write_html(town_name)
    return bs(townHTML, 'html5lib').prettify()
コード例 #3
0
ファイル: PC.py プロジェクト: Dude036/Cyneric
    def __init__(self, new_char=None):
        if new_char is None:
            new_char = create_person(None)

        self.Name = new_char.Name
        self.Level = choice(
            [x for x in range(1, 21)],
            p=[
                0.139372822, 0.125783972, 0.112891986, 0.100696864, 0.089198606, 0.078397213, 0.068292683, 0.058885017,
                0.050174216, 0.042160279, 0.034843206, 0.028222997, 0.022299652, 0.017073171, 0.012543554, 0.008710801,
                0.005574913, 0.003135889, 0.001393728, 0.000348432
            ])
        self.Level = int(self.Level)
        self.Race = new_char.Race
        self.Gender = new_char.Gender
        self.Age = new_char.Age
        self.Appearance = new_char.Appearance
        self.Traits = new_char.Traits
        self.Story = new_char.Story

        # First Roll
        self.roll()

        # Send the Rolls to determine the
        self.choose_class()

        self.Weapon = [
            Weapon(
                int(randint(0, 5)),
                iClass=choice([
                    'Heavy Axe', 'Light Axe', 'Heavy Blade', 'Light Blade', 'Close', 'Double', 'Flail', 'Hammer',
                    'Monk', 'Polearm', 'Spear'
                ])),
            Weapon(int(randint(0, 5)), iClass=choice(['Bows', 'Crossbow', 'Thrown']))
        ]

        # Spell enabled character - 1 in 3
        # if randint(3) == 0:
        # Spells for Classes that cast spells
        if self.Class in [
                'Artificer', 'Bard', 'Cleric', 'Druid', 'Magus', 'Paladin', 'Ranger', 'Sorcerer', 'Summoner', 'Warlock',
                'Warpriest', 'Wizard'
        ]:
            self.Spells = set()
            for x in range(4 + self.Level * 2):
                s = choice(list(MasterSpells.keys()))
                # Not picking a Pokemon Move
                if MasterSpells[s]['link'] not in MasterSpellBlacklist:
                    # Available to pick
                    if self.Class.lower() in MasterSpells[s]['level'].lower():
                        self.Spells.add(s)
            self.Spells = list(self.Spells)
コード例 #4
0
    def __init__(self, level):
        self.Level = int(level)
        # Create Person of interest and Reward
        self.Reporter = create_person(None)
        self.Reward = int(sum(treasure_samples(1, ['Coins'], Campaign_Speed[self.Level])))

        # Quest picker
        r = randint(0, 4)
        if r == 0:
            self.__fetch()
        elif r == 1:
            self.__bounty()
        elif r == 2:
            self.__escort()
        elif r == 3:
            self.__guild()
コード例 #5
0
 def __bounty(self):
     Beasts = {}
     BeastSource = 'D&D 5'
     if BeastSource == 'D&D 5':
         Beasts.update(json.load(open(os.path.join('generator', 'DMToolkit', 'resource', '5e_beasts.json'), 'r'), encoding='utf-8'))
     elif BeastSource == 'Pathfinder 1':
         Beasts.update(json.load(open(os.path.join('generator', 'DMToolkit', 'resource', 'beasts.json'), 'r'), encoding='utf-8'))
     # Kill a Monster or a Criminal
     r = randint(0, 6)
     if r == 0:
         self.Title = 'Bounty: '
     elif r == 1:
         self.Title = 'Wanted: '
     elif r == 2:
         self.Title = 'Wanted (Dead of Alive): '
     elif r == 3:
         self.Title = 'Wanted (Dead): '
     elif r == 4:
         self.Title = 'Wanted (Alive): '
     elif r == 5:
         self.Title = 'Beware: '
     # Assassination target
     if randint(2) == 0:
         # Beast
         badCR = True
         while badCR:
             name = choice(list(Beasts.keys()))
             if int(float(Beasts[name]['CR'])) == self.Level:
                 badCR = False
         self.Other = name
         place = choice(['North', 'South', 'North-East', 'South-East', 'North-West', 'South-West', 'East', 'West'])
         self.Hook = 'A "' + name + '" has taken refuge ' + place + ' of town. They have cause great harm to us ' + \
                     'and we are looking for able bodies to help defeat this foe. If you are able, report to ' + \
                     self.Reporter.Name + ' for more information.'
     else:
         # Criminal
         self.Other = create_person(None)
         self.Title += self.Other.Name
         self.Hook = 'Name: ' + self.Other.Name + '\nGender: ' + self.Other.Gender + '\nRace: ' + self.Other.Race + \
                     '\nAge: ' + str(self.Other.Age) + ' years old\nAppearance: ' + self.Other.Appearance + \
                     '\nIf you have any information, please see ' + self.Reporter.Name
コード例 #6
0
    def __fetch(self):
        # Retrieve stolen or rare item
        when = choice([
            'yesterday',
            'the other day',
            'a while ago',
            'today',
            'a fortnight ago',
            'this week',
            'this morning',
            'last evening',
            'last morning',
            'a week ago',
            'two days ago',
            'three days ago',
            'four days ago',
            'five days ago',
            'six days ago',
            'recently',
            'very recently',
        ])
        self.Other = create_person(None)
        location = quest_location[randint(len(quest_location))].lower()
        r = randint(0, 5)
        if r == 0:
            self.Title = 'Missing Item'
            item = choice(Trinkets)
            heritage = choice([
                'Brother',
                'Sister',
                'Mom',
                'Dad',
                'Parent',
                'Sibling',
                'Step-Brother',
                'Step-Sister',
                'Step-Mom',
                'Step-Dad',
                'Grandma',
                'Grandpa',
                'Uncle',
                'Aunt',
                'Great-Grandma',
                'Great-Grandpa',
                'Great-Uncle',
                'Great-Aunt',
            ])

            self.Hook = "I seem to have lost something very close to me. It's \"" + item + '". My ' + heritage + \
                        ' gave it to me forever ago, and seem to have lost it. If you find it, please bring it to ' + \
                        self.Reporter.Name + ' ' + location + '.'
        if r == 1:
            self.Title = 'Stolen Item! HELP!'
            item = choice(Trinkets)
            self.Hook = 'A trinket of mine was rudely taken from me ' + when + '. I reported it to the police, but ' + \
                        'no effort to capture them has been made! I believe the crook to be ' + self.Other.Name + ' (' + \
                        self.Other.Gender + ' / ' + self.Other.Race + ' / ' + str(self.Other.Age) + ' years old)\n' + \
                        'If you apprehend them, see ' + self.Reporter.Name + ' ' + location + '. The trinket is "' + \
                        item + '".'
        elif r == 2:
            self.Title = 'Missing Person: ' + self.Reporter.Name
            self.Hook = 'NOTICE: ' + self.Reporter.Name + ' has gone missing. They were last seen with ' + \
                        self.Other.Name + ' (' + self.Other.Gender + ' / ' + self.Other.Race + ' / ' + \
                        str(self.Other.Age) + ' years old)' + '. If you have any information, please contact the' + \
                        ' authorities.\nRace: ' + self.Reporter.Race + '\nAge: ' + str(self.Reporter.Age) + \
                        '\nAppearance: ' + self.Reporter.Appearance
        elif r == 3:
            self.Title = 'Kidnapped Person: ' + self.Reporter.Name
            self.Hook = 'NOTICE: ' + self.Reporter.Name + ' has been kidnapped. They were last seen with ' + \
                        self.Other.Name + ' ( ' + self.Other.Gender + ' / ' + self.Other.Race + ' / ' + \
                        str(self.Other.Age) + ' years old).' + ' If you have any information, please contact the' +\
                        ' authorities.\nRace: ' + self.Reporter.Race + '\nAge: ' + str(self.Reporter.Age) + \
                        '\nAppearance: ' + self.Reporter.Appearance
        elif r == 4:
            timing = str(randint(1, 13)) + ':' + str(choice(['00', 15, 30, 45]))
            self.Title = 'Search Party: ' + self.Other.Name
            self.Hook = 'NOTICE: ' + self.Reporter.Name + ' has gone missing. ' + self.Other.Name + ' has organized' + \
                        ' a searching party. If you have any information, report it to the authorities.\nIf you ' + \
                        'wish to join the search party, please see ' + self.Other.Name + ' ' + location + ' at ' + \
                        timing + '. \nRace: ' + self.Reporter.Race + '\nAge: ' + str(self.Reporter.Age) + \
                        '\nAppearance: ' + self.Reporter.Appearance
コード例 #7
0
def generate_shops(w,
                   a,
                   p,
                   e,
                   en,
                   b,
                   t,
                   j,
                   f,
                   g,
                   br,
                   gu,
                   v,
                   qu,
                   name='',
                   dump_json=False):
    """ [# of Stores, Rarity Low, Rarity High, Quan High, Quan Low] """
    global characters, positions, townHTML
    from generator.DMToolkit.resource.names import TownNamer
    town_name = str(TownNamer()) if name == '' else name
    townHTML = statHTML
    townHTML += "<h1>" + town_name.title() + "</h1><p>Description</p>"
    if sum([
            w[0], a[0], p[0], e[0], en[0], b[0], t[0], j[0], f[0], g[0], br[0],
            gu[0]
    ]) > 0:
        townHTML += """<h2 class="text-lg bold center">Shops</h2>"""
    full_town = {}
    i = 0
    for _ in range(w[0]):
        store = create_weapon_shop(create_person(create_variance()),
                                   [w[1], w[2]],
                                   randint(w[3], w[4]),
                                   inflate=w[6])
        write_store(store, additional=w[5])
        full_town[i] = store.to_dict()
        i += 1

    for _ in range(a[0]):
        store = create_armor_shop(create_person(create_variance()),
                                  [a[1], a[2]],
                                  randint(a[3], a[4]),
                                  inflate=a[6])
        write_store(store, additional=a[5])
        full_town[i] = store.to_dict()
        i += 1

    for _ in range(p[0]):
        store = create_potion_shop(create_person(create_variance()),
                                   [p[1], p[2]],
                                   randint(p[3], p[4]),
                                   inflate=p[5])
        write_store(store)
        full_town[i] = store.to_dict()
        i += 1

    for _ in range(e[0]):
        store = create_enchantment_shop(create_person(create_variance()),
                                        [e[1], e[2]],
                                        randint(e[3], e[4]),
                                        inflate=e[5])
        write_store(store)
        full_town[i] = store.to_dict()
        i += 1

    for _ in range(en[0]):
        store = create_enchanter_shop(create_person(create_variance()),
                                      [en[1], en[2]],
                                      randint(en[3], en[4]),
                                      inflate=en[5])
        write_store(store)
        full_town[i] = store.to_dict()
        i += 1

    for _ in range(b[0]):
        store = create_book_shop(create_person(create_variance()),
                                 choice(Books.Genres,
                                        randint(len(Books.Genres)),
                                        replace=False),
                                 randint(b[1], b[2]),
                                 inflate=b[3])
        write_store(store, False)
        full_town[i] = store.to_dict()
        i += 1

    for _ in range(t[0]):
        store = create_tavern(create_person(create_variance()),
                              t[1],
                              randint(t[2], t[3]),
                              inflate=t[4])
        write_store(store, False)
        full_town[i] = store.__dict__
        i += 1

    for _ in range(j[0]):
        store = create_jewel_shop(create_person(create_variance()),
                                  [j[1], j[2]],
                                  randint(j[3], j[4]),
                                  inflate=j[5])
        write_store(store)
        full_town[i] = store.to_dict()
        i += 1

    for _ in range(f[0]):
        store = create_restaurant(create_person(create_variance()),
                                  randint(f[1], f[2]),
                                  inflate=f[3])
        write_store(store)
        full_town[i] = store.__dict__
        i += 1

    for _ in range(g[0]):
        store = create_general_store(create_person(create_variance()),
                                     [g[1], g[2]],
                                     randint(g[3], g[4]),
                                     g[5],
                                     inflate=g[6])
        write_store(store)
        full_town[i] = store.to_dict()
        i += 1

    for _ in range(br[0]):
        store = create_brothel(create_person(create_variance()),
                               randint(br[1], br[2]),
                               inflate=br[3])
        write_store(store)
        full_town[i] = store.to_dict()
        i += 1

    for _ in range(gu[0]):
        store = create_gunsmith(create_person(create_variance()),
                                [gu[1], gu[2]],
                                randint(gu[3], gu[4]),
                                inflate=gu[6])
        write_store(store, additional=gu[5])
        full_town[i] = store.to_dict()
        i += 1

    for _ in range(v[0]):
        store = create_variety_shop(create_person(create_variance()),
                                    randint(v[1], v[2]),
                                    inflate=v[3])
        write_store(store)
        full_town[i] = store.to_dict()
        i += 1

    for _ in range(qu[0]):
        q = quests.QuestBoard(qu[1], qu[2], qu[3], town_name, False)
        characters = q.Members
        positions = q.Positions
        townHTML += str(q)
        full_town[i] = q.__dict__
        i += 1

    # Dump the class information into a json file
    if dump_json:
        json.dump(full_town,
                  open(town_name + ".town.json", 'w'),
                  indent=4,
                  sort_keys=True,
                  default=lambda x: x.__dict__)
    return town_name
コード例 #8
0
                      sort_keys=True,
                      default=lambda x: x.__dict__)
        except Exception as e:
            raise e

    print("Writing the town ", town_name)
    if to_file:
        write_html(town_name)
    return bs(townHTML, 'html5lib').prettify()


if __name__ == '__main__':
    townHTML += """<h2 class="text-lg bold center">Shops</h2>"""
    for _ in range(4):
        write_store(
            create_weapon_shop(create_person(create_variance()), [0, 2],
                               randint(5, 15),
                               inflate=4))

        write_store(
            create_armor_shop(create_person(create_variance()), [0, 2],
                              randint(5, 15),
                              inflate=4))

        write_store(
            create_potion_shop(create_person(create_variance()), [0, 9],
                               randint(5, 15),
                               inflate=4))

        write_store(
            create_enchantment_shop(create_person(create_variance()), [0, 9],