def test_SavedDiceTable_equality_test_false_by_tuple_list(self): table_1 = dt.DiceTable() table_1.add_die(1, dt.WeightedDie({1: 5, 2: 1})) data_obj = create_saved_dice_table(table_1) table_2 = dt.DiceTable() table_2.add_die(1, dt.WeightedDie({1: 1, 2: 5})) other_data_obj = create_saved_dice_table(table_2) self.assertEqual(data_obj.title, other_data_obj.title) self.assertFalse(data_obj == other_data_obj)
def test_InfoBox_make_pages_with_weights_info(self): self.DTM.request_add(1, dt.Die(3)) self.DTM.request_add(1, dt.WeightedDie({1: 2})) self.IB.make_pages('weights_info', 2) self.assertEqual(self.IB._pages['weights_info'], ['1D1 W:2\n 1 has weight: 2', '\n1D3', ' No weights\n '])
def test_check_data_all_die_types_pass(self): table = dt.DiceTable() table.add_die(1, dt.Die(4)) table.add_die(1, dt.ModDie(4, 2)) table.add_die(1, dt.WeightedDie({1: 2})) table.add_die(1, dt.ModWeightedDie({1: 2}, 3)) table.add_die(1, dt.StrongDie(dt.Die(3), 3)) obj = create_plot_object(table) self.assertEqual(fh.check_data(obj), 'ok')
def test_StatBox_display_formatting(self): self.DTM.request_add(1, dt.WeightedDie({1: 1000, 10000: 1000})) stat_text = ('\n 1,000-10,000 occurred 1,000 times\n' + ' out of 2,000 total combinations\n\n' + ' that\'s a one in 2.000 chance\n' + ' or 50.00 percent') info_text = ( 'the range of numbers is 1-10,000\n' + 'the mean is 5,000.5\nthe stddev is 4999.5' ) self.assertEqual(self.SB.display(1000, 10000), [info_text, stat_text, (1000, 10000), (1, 10000)])
def make_die(size, modifier, multiplier, dictionary): '''makes the die into a new die. IMPORTANT!! dictionary supercedes size so if size is 6 and dictionary is {1:1, 2:4}, then die is made according to dictionary. size-int>0, modifier-int, multiplier-int>=0.''' dice = {'die':dt.Die(size), 'moddie': dt.ModDie(size, modifier)} die_key = 'die' if dictionary: if sum(dictionary.values()) != 0: for value in dictionary.values(): if value != 1: die_key = 'weighteddie' dice['weighteddie'] = dt.WeightedDie(dictionary) dice['modweighteddie'] = dt.ModWeightedDie(dictionary, modifier) break if modifier: die_key = 'mod' + die_key if multiplier > 1: return dt.StrongDie(dice[die_key], multiplier) else: return dice[die_key]
def make_die(size, modifier, multiplier, dictionary): """ if is_dictionary_for_weigted_die, then dictionary supercedes size :return: Die, ModDie, WeightedDie, ModWeightedDie or StrongDie """ if not dictionary: dictionary = {1: 0} dice = { 'Die': dt.Die(size), 'ModDie': dt.ModDie(size, modifier), 'WeightedDie': dt.WeightedDie(dictionary), 'ModWeightedDie': dt.ModWeightedDie(dictionary, modifier) } die_key = 'Die' if is_dictionary_for_weighted_die(dictionary): die_key = 'WeightedDie' if modifier: die_key = 'Mod' + die_key if multiplier > 1: return dt.StrongDie(dice[die_key], multiplier) else: return dice[die_key]
def test_DiceTableManager_get_stats_tiny_tiny_chance(self): self.DTM.request_add(1, dt.WeightedDie({1: 1, 2: 10 ** 1000})) self.assertEqual(self.DTM.get_stats([1]), ('1', '1', '1.000e+1000', '1.000e+1000', '1.000e-998'))
def test_DiceTableManager_get_description_range_mean_stddev_formatting(self): self.DTM.request_add(1, dt.WeightedDie({1000: 1, 3000: 2})) self.assertEqual(self.DTM.get_description_range_mean_stddev(), ('the range of numbers is 1,000-3,000\n' + 'the mean is 2,333.3333\nthe stddev is 942.809'))
def test_InfoBox__get_formatted_text_with_weights_info(self): self.DTM.request_add(1, dt.WeightedDie({1: 2})) self.assertEqual(self.IB._get_formatted_text('weights_info'), '1D1 W:2\n 1 has weight: 2')
def test_AddBox_record_weights_works_as_expected(self): self.AB.record_weights_text([('weight for 1', 3), ('weight for 2', 1)]) self.assertEqual(self.AB._die, dt.WeightedDie({1: 3, 2: 1}))
def test_make_die_input_die__weighteddie(self): self.assertEqual(mvm.make_die(6, 0, 0, {1: 1, 2: 0, 3: 1}), dt.WeightedDie({1: 1, 2: 0, 3: 1}))
def test_get_add_choices_size6(self): self.assertEqual(mvm.get_add_choices(dt.WeightedDie({6: 2})), [1, 5, 10, 50, 100, 500])
def test_get_die_roll_details_with_pos_number_as_longest(self): expected_text = ('D100 W:11 rolls:\n' + ' 1 with frequency: 1\n' + ' 100 with frequency: 10') self.assertEqual(expected_text, mvm.get_die_roll_details(dt.WeightedDie({1: 1, 100: 10})))