def get_encounter(self):
     encounter_source = EncounterSource(encounter_level=self.level+1,
                                         monster_sets=['villains'],
                                         random_state=self.random_state)
     encounter_source.monster_set = self.villain_name()
     self.dungeon_manager.add_special_encounter_source(self.name, encounter_source)
     encounter = self.dungeon_manager.get_encounter(self.name, style='leader', difficulty='medium')
     if encounter['difficulty'] in ['easy', 'medium'] and self.random_state.randint(1, 6) >= 3:
         item = NPC_item(self.level, random_state=self.random_state)
         encounter['treasure']['magic_items'] = item.item
     encounter['difficulty'] = 'Special'
     return encounter
 def __init__(self,
              terrain=None,
              all_tags=None,
              none_tags=None,
              any_tags=None,
              level=None,
              monster_set=None):
     self.mm = MonsterManual(terrain=terrain)
     if monster_set is None:
         sets = self.mm.get_monster_sets(all_tags=all_tags,
                                         none_tags=none_tags,
                                         any_tags=any_tags,
                                         level=level)
         monster_set = random.choice(sets)
     self.monster_set = monster_set
     self.source = EncounterSource(encounter_level=level,
                                   monster_sets=[self.monster_set])
 def get_encounter(self):
     encounter_source = EncounterSource(encounter_level=self.level+1,
                                         monster_sets=None,
                                         random_state=self.random_state)
     encounter_source.monster_set += ' - Here due to a strange alliance, a curse, or magic item.'
     self.encounter_name = encounter_source.monster_set
     self.dungeon_manager.add_special_encounter_source(self.name, encounter_source)
     encounter = self.dungeon_manager.get_encounter(self.name, style='elite', difficulty='hard')
     return encounter
Exemple #4
0
 def get(self):
     """Returns a random encounter meeting the supplied specifications."""
     args = parser.parse_args()
     character_level_dict = Counter(args["character_levels"])
     monster_sets = args["monster_sets"]
     difficulty = args["difficulty"]
     if not args["difficulty"] is None and args["difficulty"] not in [
             "medium",
             "easy",
             "hard",
     ]:
         raise BadRequest("Invalid difficulty value")
     if not all([
             monster_set in monster_manual.monster_sets
             for monster_set in monster_sets
     ]):
         raise BadRequest("One or more invalid monster sets in request")
     if not all([level <= 20 for level in character_level_dict.keys()]):
         raise BadRequest("Maximum character level is 20")
     source = EncounterSource(character_level_dict=character_level_dict,
                              monster_sets=monster_sets)
     encounter = source.get_encounter(difficulty=difficulty)
     return encounter
class PlacePopulator:
    def __init__(self,
                 terrain=None,
                 all_tags=None,
                 none_tags=None,
                 any_tags=None,
                 level=None,
                 monster_set=None):
        self.mm = MonsterManual(terrain=terrain)
        if monster_set is None:
            sets = self.mm.get_monster_sets(all_tags=all_tags,
                                            none_tags=none_tags,
                                            any_tags=any_tags,
                                            level=level)
            monster_set = random.choice(sets)
        self.monster_set = monster_set
        self.source = EncounterSource(encounter_level=level,
                                      monster_sets=[self.monster_set])

    def apply(self, graph):
        for node, data in graph.nodes(data=True):
            if random.randint(1, 6) >= 5:
                data["signs"] = self.source.get_sign()
                data["encounter"] = self.source.get_encounter()
Exemple #6
0
 def add_encounter_source(self,
                          source_name,
                          monster_set,
                          event_description,
                          wandering=False):
     logger.debug('Adding encounter source %s (%s)' %
                  (source_name, monster_set))
     encounter_source = EncounterSource(monster_set=monster_set,
                                        random_state=self.random_state)
     self.encounter_sources[source_name] = encounter_source
     self.encounters[source_name] = 0
     self.signs[source_name] = []
     self.add_event(source_name,
                    event_description,
                    monster_set,
                    wandering=wandering)
Exemple #7
0
 def summon_monsters(self):
     if self.challenge == 'setback':
         difficulty = 'easy'
     elif self.challenge == 'dangerous':
         difficulty = 'medium'
     else:
         difficulty = 'hard'
     sets = library.monster_manual.get_monster_sets(
         any_tags=['fiend', 'celestial', 'elemental'], level=self.level)
     if len(sets) == 0:
         sets = library.monster_manual.get_monster_sets(
             any_tags=['elemental'], level=None)
     encounter = EncounterSource(encounter_level=self.level,
                                 monster_sets=sets).get_encounter(
                                     style='basic', difficulty=difficulty)
     monsters = ', '.join([
         '%s: %d' % (m['name'], m['number']) for m in encounter['monsters']
     ])
     return monsters
 def add_encounter_source(self,
                          source_name,
                          monster_set,
                          event_description,
                          wandering=False):
     logger.debug('Adding encounter source %s (%s)' %
                  (source_name, monster_set))
     encounter_source = EncounterSource(
         encounter_level=self.level,
         monster_sets=[monster_set],
         supplied_monster_manual=MonsterManual(terrain=self.terrain),
         random_state=self.random_state)
     self.encounter_sources[source_name] = encounter_source
     self.encounters[source_name] = 0
     self.signs[source_name] = []
     self.add_event(source_name,
                    event_description,
                    monster_set,
                    wandering=wandering)
Exemple #9
0
 def choose_dragon(self):
     dragons = special_events_data['dragon lair']['dragons']
     dragon_source = EncounterSource(encounter_level=self.level,
                                     monster_sets=dragons)
     return dragon_source.get_encounter(difficulty='hard')
Exemple #10
0
def test_encounter_source_summary():
    source = EncounterSource(monster_set="jailers")
    print(source.get_encounter())