from pygame import *
import random
import time
import sys


def print2(text):
    for char in text:
        sys.stdout.write(char)
        sys.stdout.flush()
        time.sleep(0.04)  # Slightly slower for maximum drama
    print()

def printquick(text):
    for char in text:
        sys.stdout.write(char)
        sys.stdout.flush()
        time.sleep(0.01)
    print()

def print3(text):
    for char in text:
        sys.stdout.write(char)
        sys.stdout.flush()
        time.sleep(0.1)  # Slightly slower for maximum drama
    print()


print2("hello player!")
name = input("what's yo name bludky? | your response: hi my name is ")
name = name.lower()
if name != "bob":
    print("hello %s... \n" % name)
    real_name = 5*name.upper()
    print3("or should I say %s? if that's even your real name... \n" % real_name)
    for i in range(0, len(name)-1):
        if name[i] == "j":
            print("yo theres a jay in yo name crazy am i right here it is: %s" %
                  name[i])
            break
    ease = 0
    for i in range(0, len(name)-1):
        if name[i] == "e":
            ease += 1
            print("yo i found an e in your name and its e number %i" % ease)
            time.sleep(0.1)
else:
    print("nice try bludky, but im the real bob.")

time.sleep(1)

print("\nthats the end of the show hope you enjoyed and make sure to like and subscribe")

time.sleep(5)

print2("\nactually its not the end that was bob but im evil bob\nand today we're going to play a game")


time.sleep(1)

funny = random.randint(0, 100)
num = random.randint(0, 100)

print3("[evil bob has chosen a number between 0 and 100...]\nguess if it is higher (h) or lower (l) than %i " % funny)

result = 0
while result == 0:
    guess = input("your guess: ")
    guess = guess[0].lower()
    if guess == "h" or guess == "l":
        if guess == "h" and num > funny:
            print("you won because %i > %i good job" % (num, funny))
        elif guess == "l" and num < funny:
            print("you won because %i < %i good job" % (num, funny))
        elif num == funny:
            print3(
                "okay well that was kinda rigged because my number was %i but ill give you the point" % num)
        else:
            print("nice try but you lost, my number was %i" % num)
        result = 1
    else:
        print("vro youre supposed to guess h or l not %s you silly billy" % guess)


time.sleep(1)

print2("but wait the show is not over as yet")

time.sleep(1)

print("we're going to do the collatz conjecture now")
result = 0
while result == 0:
    num = input("choose a number bludky. | your number: ")
    if num.lower() != num.upper():
        print("ts is NOT a number")
    else:
        result = 1
        num = int(num)

calc_count = 0

if num % 2 == 0:
    print("%i is even" % num)
else:
    print("%i is odd" % num)

while num != 1:
    time.sleep(0.2)
    if num % 2 == 0:
        num /= 2
        calc_count += 1
        print("...and we now have %i" % int(num))
    else:
        num *= 3
        num += 1
        calc_count += 1
        print("...and we now have %i" % int(num))

    if random.randint(0, 10) == 0 and num <= 0:
        print2("ayo wait... you entered an illegal number >:/ not very sigma of you")
        break

print("welp, that took %i calculations \n" % calc_count)
time.sleep(2)
print("but guess what, we're not done yet, because I'm going to draw a square.")

RED = (200, 0, 0)

init()
SIZE = (1000, 700)
screen = display.set_mode(SIZE)
draw.rect(screen, RED, (400, 300, 100, 100))
display.flip()
ans = input("isn't this such a beautiful square? | your response: ").lower()
quit()
if ans != "no" and ans != "nah":
    print("see I thought so, it's a beauty innit")
else:
    print2("see this is why i always need a second opinion.")

time.sleep(2)
print3("okay this is the end of the show bye bye")

time.sleep(2)
print2("hello guys its me bob and evil bob has left to take a nap so now we will commence the next part of the show")
time.sleep(1)

print("so yeah fibonacci time. uhhh lets begin")

result = 0
while result == 0:
    limit = input("but at which point do we want to stop? | your answer: ")
    if limit.lower() == limit.upper():
        limit = int(limit)
        result = 1
    else:
        print2("vro youre supposed to choose a number not %s you silly billy" % limit)

a = 0
b = 1
c = 0
while c <= limit:
    c = a + b
    if c >= limit:
        break
    print("we do %i + %i which gives %i..." % (a, b, c))
    a = b
    b = c
    time.sleep(0.2)
print("and c is %i which is more than or equal to our predefined limit of %i\nso that's enough for today" % (c, limit))

print("now of course we need to review our multiplication tables, am i right?")

result = 0
while result == 0:
    limit = input("choose a number? | your answer: ")
    if limit.lower() == limit.upper():
        limit = int(limit)
        result = 1
    else:
        print("vro youre supposed to choose a number not %s you silly billy" % limit)
print("wait im thinking...")
time.sleep(1)
for i in range(1, limit+1):
    if name != "bob":
        print("uhhhh %i by %i is %i" % (limit, i, limit*i))
    else:
        print("uhhhh %i by %i is %i" % (limit, i, random.randint(-1000, 1000)))
    time.sleep(0.1)
print("and thats it i think")
time.sleep(1)
print("but wait there's more, time to draw a text square (crazy am i right)")

result = 0
while result == 0:
    b = input("choose your base length: | b = ")
    if b.lower() == b.upper():
        b = int(b)
        result = 1
    else:
        print("vro youre supposed to choose a number not %s you silly billy" % b)


for i in range(b):
    print("*"*b)
ans = input("isn't this such a beautiful square? | your response: ").lower()
if ans != "no" and ans != "nah":
    print("see I thought so, it's a beauty innit")
else:
    print2("see this is why i always need a second opinion.")

time.sleep(1)
print2("but of course we cannot forget the game of vingt-et-un aka jacquesnoir or whatever")

time.sleep(1)
print3("prepare your mind...")

deck = []
for j in range(4):
    for i in range(1, 14):
        deck.append(i)

result = 0
bob_deck = []
yo_deck = []
while result == 0:

    card = random.randint(0, len(deck))
    bob_deck.append(deck[card])
    deck.pop(deck[card])

    summation = 0
    for i in range(0, len(bob_deck)):
        summation += bob_deck[i]

    print("my cards are %s, summation being %i" % (bob_deck, summation))

    if summation >= 21:
        result = 1
        break

    hit = input("say a non-blank character to be hit, otherwise you stand. | ")

    if hit != "":
        card = random.randint(0, len(deck))
        yo_deck.append(deck[card])
        deck.pop(deck[card])

    summation = 0
    for i in range(0, len(yo_deck)):
        summation += yo_deck[i]

    print("your cards are %s, summation being %i" % (yo_deck, summation))

    if summation >= 21:
        result = 2
        break

if result == 1:
    print("looks like you won the game, nice one.")
elif result == 0:
    print2("looks like you lost the game, nice try.")
else:
    print("okay this game is a little broken I guess...")

print("okay wait that's not even how you play blackjack now is it...?")
time.sleep(1)
print("okay we're done now i hope you enjoyed the show")
time.sleep(1)
print("...hi its me evil bob")
time.sleep(1)
print("...you thought ts was over...?")
time.sleep(1)
print("...ahh,"+name+"...")
time.sleep(1)

print3("...YOU FOOL...")

while True:
    print("█*10")

def bob():
    try:
        game()
    except Exception as crash:
        # Catch-all for everything else that goes bump in the runtime
        print2(sys.stderr, f"[ALERT] i think it crashed... {crash}")
    finally:
        print3("and that's the end")
