def test_AddBox_set_size_doesnot_affect_mod_or_multiplier(self): self.AB._mod = 100 self.AB._multiplier = 50 self.AB.set_size(2) self.assertEqual(self.AB._mod, 100) self.assertEqual(self.AB._multiplier, 50) self.assertEqual(self.AB._die, dt.StrongDie(dt.ModDie(2, 100), 50))
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 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_AddBox_multiplier_sets_new_multiplier_and_gets_new_die(self): self.AB.set_multiplier(10) self.assertEqual(self.AB._die, dt.StrongDie(dt.Die(6), 10))
def test_make_die_input_die__strong_d6(self): self.assertEqual(mvm.make_die(7, 0, 5, {1: 0, 2: 0, 3: 0}), dt.StrongDie(dt.Die(7), 5))
def test_make_die_input_die__strong_modweighteddie(self): self.assertEqual(mvm.make_die(6, 1, 5, {1: 1, 2: 0, 3: 1}), dt.StrongDie(dt.ModWeightedDie({1: 1, 2: 0, 3: 1}, 1), 5))
def test_get_die_roll_details_with_negative_number_as_longest(self): expected_text = ('(D3-2)X10 rolls:\n' + ' -10 with frequency: 1\n' + ' 0 with frequency: 1\n' + ' 10 with frequency: 1') self.assertEqual(expected_text, mvm.get_die_roll_details(dt.StrongDie(dt.ModDie(3, -2), 10)))