def main(): """where it all gets done """ from optparse import OptionParser parser = OptionParser() parser.add_option("-q", "--quiet", help="quiet mode. Just display APL", action="store_false", dest="verbose", default=True) parser.add_option("-v", "--verbose", help="verbose mode. Display how APL was calculated", action="store_true", dest="verbose", default=False) parser.add_option("-f", "--file", help="path to file in configparser INI format", dest="input_file", default="") parser.add_option("-d", "--directory", help="path to directory containing files ending in .pcg", dest="input_directory", default="") parser.add_option("-r", "--range", help="display range of challenges from Easy to Epic", action="store_true", dest="range", default=False) parser.add_option("-c", "--challenge-rating", help="display CR of party (not same as APL, varies by count)", action="store_true", dest="cr", default=False) (options, args) = parser.parse_args() result = 0 cr = "" if options.input_file: (apl, count) = nots.calculate_apl_from_file(options.input_file, options.verbose) if options.input_directory: (apl, count) = nots.calculate_apl_from_dir(options.input_directory, options.verbose) if options.cr: cr = nots.calculate_cr(apl, count) cr = nots.cr_int_to_cr_display(cr) if cr: result = cr else: result = apl if options.range: nots.print_range(result, options.verbose) else: if options.cr: type="Challenge Rating" else: type="Average Party Level" nots.print_result(result, options.verbose, type)
def test_adjust_cr_up_for_6_characters(self): """A party of six characters at level 4 is APL 5""" expect= 5 result = 0 result = nots.calculate_cr(4, 6) self.assertEqual(expect, result)
def test_adjust_cr_down_for_3_characters(self): """A party of three characters at level 7 is APL 6""" expect= 6 result = 0 result = nots.calculate_cr(7, 3) self.assertEqual(expect, result)