Esempio n. 1
0
def play():
    START_MONEY = 100
    MIN_MONEY_TO_WIN = 200
    FACTOR_WIN = 2
    money = START_MONEY
    print "At any time, bet 0 to quit. Quit above %d to win 1/%d of your coins in money" % (MIN_MONEY_TO_WIN, FACTOR_WIN)
    
    while True:
        print "You have %d." % money
        
        bet = input_number_between("  Your bet ?", 0, money)
        
        draw = randrange(1, 7) + randrange(1, 7)

        if draw in [7, 11]:
            money += bet
            print "  %d: Natural... You win!" % draw
            
        elif draw in [2, 3, 12]:
            money -= bet
            print "  %d: Snake eye... You lose!" % draw
        
        elif money == 0: 
            print "You have 0, you lose!"
            return 0
        elif bet == 0:
            if money > FACTOR_WIN * START_MONEY:
                print "You win %d money." % money / FACTOR_WIN
                return money /FACTOR_WIN
            else:
                print "You have under %d coins, sorry." % MIN_MONEY_TO_WIN
                return 0
        else: 
            print "  %d: Try to draw it again... The real fun begins!" % draw
            money += repeat(draw) * bet
Esempio n. 2
0
def play():
    MIN_MONEY_TO_WIN = 200
    FACTOR_WIN = 3
    money = 100
    print "At any time, bet 0 to quit. Quit above %d coins to earn 1/%d money." % (MIN_MONEY_TO_WIN, FACTOR_WIN)
    
    
    while money != 0:
        print "You have %d." % money
        draw1 = randrange(1, 7)
        draw2 = randrange(1, 7)
        
        aux = draw1
        draw1 = min(draw1, draw2)
        draw2 = max(aux, draw2)
        
      
  
        bet = input_number_between("Your bet that the next draw is between %d %d ?" % (draw1, draw2), 0, money)
        if bet == 0: 
            if money >= MIN_MONEY_TO_WIN:
                print "You quit and win %d." % (money / FACTOR_WIN)
                return money / FACTOR_WIN
            else: 
                print "You quit without money!"
                return 0
        
        draw = randrange(1, 7)
        print "I draw %d." % draw
        
        if draw1 <= draw <= draw2:
            money += bet    
        else:
            money -= bet
Esempio n. 3
0
def family():

    choice = raw_input("Our family?")
    if choice.lower() == "all":
        for i in range(len(FAMILY)):
            print "%s is %d years old." % (FAMILY[i][0], FAMILY[i][1])
    if choice.lower().startswith("add"):
        FAMILY.append((raw_input("Do you have a name for your person?"),
                       input_number_between(
                           "Since how many years is this person on earth ?", 0,
                           150)))
        print "Oh a new family member! "
Esempio n. 4
0
def family():

    choice = raw_input("Our family?")
    if choice.lower() == "all":
        for i in range(len(FAMILY)):
            print "%s is %d years old." % (FAMILY[i][0], FAMILY[i][1])
    if choice.lower().startswith("add"):
        FAMILY.append(
            (
                raw_input("Do you have a name for your person?"),
                input_number_between("Since how many years is this person on earth ?", 0, 150),
            )
        )
        print "Oh a new family member! "
Esempio n. 5
0
def play():
    START_MONEY = 100
    MIN_MONEY_TO_WIN = 200
    FACTOR_WIN = 2
    money = START_MONEY
    print "At any time, bet 0 to quit. Quit above %d to win 1/%d of your coins in money" % (
        MIN_MONEY_TO_WIN, FACTOR_WIN)

    while True:
        print "You have %d." % money

        bet = input_number_between("  Your bet ?", 0, money)

        draw = randrange(1, 7) + randrange(1, 7)

        if draw in [7, 11]:
            money += bet
            print "  %d: Natural... You win!" % draw

        elif draw in [2, 3, 12]:
            money -= bet
            print "  %d: Snake eye... You lose!" % draw

        elif money == 0:
            print "You have 0, you lose!"
            return 0
        elif bet == 0:
            if money > FACTOR_WIN * START_MONEY:
                print "You win %d money." % money / FACTOR_WIN
                return money / FACTOR_WIN
            else:
                print "You have under %d coins, sorry." % MIN_MONEY_TO_WIN
                return 0
        else:
            print "  %d: Try to draw it again... The real fun begins!" % draw
            money += repeat(draw) * bet