def test_encounter_builder_fail_nicely(): budget = 400000 encounter = EncounterBuilder(xp_budget=budget, monster_source=mock_monster_list) assert encounter.monster_lists == [] budget = 0 encounter = EncounterBuilder(xp_budget=budget, monster_source=mock_monster_list) assert encounter.monster_lists == []
def test_encounter_picker(): state = Random(0) budget = 450 monster_source = mock_monster_list builder = EncounterBuilder(budget, monster_source) monster_lists = builder.monster_lists picker = EncounterPicker(monster_lists, budget, random_state=state)
def test_encounter_does_not_exceed_xp_budget(): xp_values = [] budget = 450 maximum = budget * 1.5 minimum = budget * 0.5 source = EncounterBuilder(xp_budget=budget, monster_source=mock_monster_list) for monster_list in source.monster_lists: xp_values.append(source.xp_calculator.adjusted_xp_sum(monster_list)) assert all([xp <= maximum for xp in xp_values]) assert all([xp >= minimum for xp in xp_values])
def test_correct_lists_generated(): budget = 450 source = EncounterBuilder(xp_budget=budget, monster_source=mock_monster_list) correct = [ ['boss monster'], ['trooper', 'trooper', 'trooper'], ['doggo', 'doggo', 'trooper', 'trooper'], ['doggo', 'trooper', 'trooper'], ['trooper', 'trooper'], ['fancy man', 'trooper'], ['doggo', 'doggo', 'doggo', 'doggo', 'trooper'], ['doggo', 'doggo', 'doggo', 'trooper'], ['doggo', 'doggo', 'trooper'], ['fancy man', 'fancy man'], ['doggo', 'doggo', 'fancy man'], ['doggo', 'fancy man'], ['extra fancy man'], ['doggo', 'doggo', 'doggo', 'doggo', 'doggo', 'doggo'], ['doggo', 'doggo', 'doggo', 'doggo', 'doggo'], ['doggo', 'doggo', 'doggo', 'doggo'], ['doggo', 'doggo', 'doggo'] ] returned = sorted([[m['Name'] for m in l] for l in source.monster_lists]) assert returned == sorted(correct)
def test_encounter_gets_unique_combinations(): budget = 450 builder = EncounterBuilder(xp_budget=budget, monster_source=mock_monster_list, lower_bound=0.8, upper_bound=1.2) assert len(builder.monster_lists) == 9
def test_possible_monsters(): budget = 450 builder = EncounterBuilder(xp_budget=budget, monster_source=mock_monster_list) possible = [monster['Name'] for monster in builder.possible_monsters([])] assert possible == ['boss monster', 'trooper', 'fancy man', 'extra fancy man', 'doggo']
def test_right_idx(): budget = 450 builder = EncounterBuilder(xp_budget=budget, monster_source=mock_monster_list) right_idx = [m['Name'] for m in builder.right_index_monsters([])] assert right_idx == ['boss monster', 'trooper', 'fancy man', 'extra fancy man', 'doggo']
def test_encounter_builder(): budget = 450 monster_source = mock_monster_list builder = EncounterBuilder(budget, monster_source) assert len(builder.monster_lists) == 17