def test_explode(self, random_call): results = [1, 12, 5, 4, 7, 6] random_call.side_effect = results target = dice.DiceRoll(6, 12, None, 12, None) target.roll_dice() self.assertEqual(12, target.explode_value) self.assertEqual(len(results)+1, len(target.results))
def test_total(self, random_call): results = [1, 10, 5, 4, 10] random_call.side_effect = results examples = [0, 5, -10, 22, -50] for example in examples: target = dice.DiceRoll(5, 10, example, None, None) target.roll_dice() self.assertEqual(example, target.roll_modifier) self.assertEqual(sum(results) + example, target.total)
def test_roll_dice(self, random_call): results = [1, 4, 6, 6, 2, 3, 5] random_call.side_effect = results target = dice.DiceRoll(7, 6, None, None, None) target.roll_dice() self.assertEqual(7, target.number_of_dice) self.assertEqual(7, len(target.results)) for i, result in enumerate(results): self.assertEqual(result, target.results[i]) self.assertEqual(str(result), target.formated_results[i])
def __init__(self, container, new_monster: gui.Action, new_character: gui.Action, close: gui.Action, **kwargs): super().__init__(container, **kwargs) self.roller = dice.DiceRoll(self.f) self.roller.grid(0, 0, columnspan=3) self.newMonster = tk.Button(self.f, text='New Monster', command=new_monster) self.newMonster.grid(row=1, column=0) self.newCharacter = tk.Button(self.f, text='New Character', command=new_character) self.newCharacter.grid(row=1, column=1) self.QUIT = tk.Button(self.f, text='Quit', command=close) self.QUIT.grid(row=1, column=2)
async def on_message(message): ''' this function represents a 'message event' in any of the channels... it should not be called anywhere and it is defined in the discord module ''' channel = message.channel if message.author == client.user: print('{:%d/%m/%y %H:%M} @{} {}: {}'.format( dt.datetime.now(), message.channel, message.author.name, message.content)) if message.content.startswith('!r'): print('{:%d/%m/%y %H:%M} @{} user: {}'.format( dt.datetime.now(), message.channel, message.content)) try: will_roll = True number_of_dice, dice_type, modifier, explode, success, glitch, dcfg.mode, cmd_msg\ = dice.dice_input_verification(message.content, dcfg.mode) if cmd_msg != None: await channel.send(cmd_msg) will_roll = False except (dexc.SuccessConditionError, dexc.ExplodingDiceError, dexc.DiceTypeError, dexc.ExplodingDiceTooSmallError, dexc.GlitchValueError, dexc.RollInputError, dexc.NoSuccessForGlitchError, dexc.InitiativeError, dexc.EmptyInitiativeListError) as ex: await channel.send(dexc.dice_exception_msg(ex, ex.msg)) will_roll = False if will_roll == True: my_roll = dice.DiceRoll(number_of_dice, dice_type, modifier, explode, success, glitch) my_roll.roll_dice() my_roll.glitch_counter() my_roll.explode_dice() my_roll.success_counter() await channel.send(my_roll.output())
def __init__(self, window): gui.Section.__init__(self, window) self.charactername = {} self.excessblock = tk.Frame(self.f) # self.effects = gui.EffectPane(self.f, '', '') self.effects = LongEffectDisplay(self.excessblock, '') self.roll = dice.DiceRoll(self.excessblock) self.prepare = tk.Button(self.excessblock, text='Prepare a spell', command=self.prepare_start) np = str(len(self.detail.handler.prepared_today)) self.numprepared = tk.Label(self.excessblock, text='Spells prepared today: ' + np) self.unprepare = tk.Button(self.excessblock, text='Unprepare a spell', command=self.unprepare_start) self.QUIT = tk.Button(self.f, text='QUIT', command=self.writequit, fg='red') self.begin_start()