Exemple #1
0
def get_menu_number(validchoices):
    while True:
        choice = prompt()
        if choice is None:
            pass
        elif numtools.is_integer(choice) is False:
            print('Please enter a number for your selection!')
        elif int(choice) in validchoices:
            return int(choice)
        else:
            print('Selection not available, try again.')
Exemple #2
0
def get_buyin(game, hero):
    minbuyin = blinds.stakes[game.level] * 10
    if hero.bank < minbuyin:
        print('Sorry, you don\'t have enough chips to buyin to this game!')
        return None
    print('The minimum buy-in for {} is {} bits.'.format(
        blinds.get_stakes(game.level), minbuyin))

    while True:
        print('How much do you want to buyin for? (Minimum={})'.format(minbuyin))

        choice = prompt()
        if numtools.is_integer(choice):
            if int(choice) < minbuyin:
                print('Not enough!\n')
            elif int(choice) > hero.bank:
                print('This is more chips than you can afford!\n')
            else:
                return int(choice)
        else:
            print('Invalid input!\n')
Exemple #3
0
 def test_isinteger_10_returnsTrue(self):
     expected = True
     result = numtools.is_integer(10)
     self.assertEqual(expected, result)
Exemple #4
0
 def test_isinteger_str10pt3_returnsTrue(self):
     expected = False
     result = numtools.is_integer('10.3')
     self.assertEqual(expected, result)
Exemple #5
0
 def test_isinteger_float_returnsFalse(self):
     expected = False
     result = numtools.is_integer(10.5)
     self.assertEqual(expected, result)
Exemple #6
0
 def test_isinteger_string_returnsFalse(self):
     expected = False
     result = numtools.is_integer('string')
     self.assertEqual(expected, result)