예제 #1
0
 def __init__(self, level, martial=False, random_state=None):
     if random_state is None:
         self.random_state = Random()
     else:
         self.random_state = random_state
     if martial:
         self.item_list = unique_items
     else:
         self.item_list = magic_items
     self.level = level
     self.item = self.get_item()
     self.properties = self.get_properties()
     self.name_generator = NameGenerator(random_state=self.random_state)
     self.name = self.get_name()
예제 #2
0
 def __init__(self, random_state=None):
     if random_state is None:
         self.random_state = Random()
     else:
         self.random_state = random_state
     self.role = self.random_state.choice(list(roles.keys()))
     self.sex = self.random_state.choice(['male', 'male', 'female', 'female', 'male', 'female', 'other'])
     self.traits = {}
     for trait in roles[self.role].keys():
         self.traits[trait] = self.random_state.choice(roles[self.role][trait])
     self.traits['personality'] = []
     for trait in self.random_state.sample(traits.keys(), 3):
         self.traits['personality'].append({'type': trait, 'text': self.random_state.choice(traits[trait])})
     self.name = NameGenerator(random_state=self.random_state).simple_person_name(sex=self.sex)
     if self.random_state.randint(1, 6) >= 5:
         self.traits['item'] = NPC_item(level=5, random_state=self.random_state).item
예제 #3
0
 def __init__(self, level, layout, terrain=None, random_state=None):
     if random_state is None:
         self.random_state = Random()
     else:
         self.random_state = random_state
     self.level = level
     self.layout = layout
     self.encounter_sources = {}
     self.encounters = {}
     self.signs = {}
     treasure = RawHoardSource(
         level, random_state=self.random_state).get_treasure()
     self.treasure_manager = TreasureManager(treasure,
                                             random_state=self.random_state)
     self.terrain = terrain
     self.monster_manual = MonsterManual(terrain=terrain)
     self.events = []
     self.name_generator = NameGenerator(random_state=self.random_state)
     self.wandering_monsters = {}
 def get_description(self):
     base = ' This room contains'
     motif, other_motif = self.random_state.sample(
         special_furnishings_data['statue']['motif'], 2)
     fancy_name = NameGenerator().fancy_name()
     template = self.random_state.choice(
         special_furnishings_data['statue']['templates'])
     enticement = self.random_state.choice(
         special_furnishings_data['statue']['enticements'])
     effect = self.random_state.choice(
         special_furnishings_data['statue']['effects'])
     d = {
         'motif': motif,
         'other_motif': other_motif,
         'fancy_name': fancy_name
     }
     for word in [
             'single_activity', 'material', 'pair_activity', 'penalty'
     ]:
         d[word] = self.random_state.choice(
             special_furnishings_data['statue'][word])
     return Template(' '.join([base, template, enticement,
                               effect])).substitute(d)
 def add_books(self, room, dungeon_purpose):
     namer = NameGenerator(random_state=self.random_state)
     if purpose == 'stronghold':
         topics = self.random_state.sample(['history', 'nature', 'arcana'],
                                           2)
     elif purpose == 'temple':
         topics = ['religion', 'arcana']
     else:
         topics = self.random_state.sample(
             ['history', 'nature', 'arcana', 'religion'], 2)
     if 'study' in room['tags']:
         n_books = 1
     else:
         n_books = self.random_state.randint(1, 6)
     library = []
     for _ in range(n_books):
         book = namer.book(self.random_state.choice(topics))
         library.append({
             'title':
             book['title'],
             'contents':
             book['contents'] + ' ' + book.get('extra', '')
         })
     room['library'] = library
예제 #6
0
def test_names():
    namer = NameGenerator()