示例#1
0
def initiate_choices(choice_array, data_list):
    if len(choice_array) == 0:
        choices.append(data.pop(random.randint(0, len(data) - 1)))
        choices.append(data.pop(random.randint(0, len(data) - 1)))
    else:
        choices.pop(0)
        choices.append(data.pop(random.randint(0, len(data) - 1)))
示例#2
0
def game():
    """Run the game."""
    # Declaring score and conditional variable
    score = 0
    continue_game = True

    # Start the game loop
    while continue_game:
        # The clear() function below works at replit.com
        clear()
        print(logo)
        # Print the score it the person had already guessed right
        if score >= 1:
            print(f"You're right! Current score is {score}.")

        # Compare A
        if score == 0:
            celebrity_a = pick_celebrity()
            celebrity_a_index = celebrity_index(celebrity_a)
            data.pop(celebrity_a_index)
        letter = 'A'
        print_celebrity(letter, celebrity_a)

        # Print the vs
        print(vs)

        # Against B
        celebrity_b = pick_celebrity()
        while (celebrity_a == celebrity_b):
            celebrity_b = pick_celebrity()
        celebrity_b_index = celebrity_index(celebrity_b)
        data.pop(celebrity_b_index)
        letter = 'B'
        print_celebrity(letter, celebrity_b)

        # User choice
        user_choice = input(
            "Who has more followers? Type 'A' or 'B': ").upper()

        # Get the correct answer for each situation
        right_answer = answer(user_choice, celebrity_a, celebrity_b)

        # Compare the answers and remove the celebrities to avoid repetition
        if user_choice == right_answer:
            score += 1
            if not data:
                print("You have won! You have reached the maximum score: 49!")
                continue_game = False
            else:
                if right_answer == 'B':
                    celebrity_a = celebrity_b
        else:
            clear()
            print(logo)
            print(f"Sorry, that's wrong. Final score: {score}")
            continue_game = False
示例#3
0
 def play(self):
     keep_going = True
     print(logo)
     while keep_going:
         self.print_choices()
         is_correct = self.check_answer()
         self.clear()
         print(logo)
         if len(data) == 0:
             keep_going = False
             print("This is it for now. You guessed everything right!")
         elif not is_correct:
             keep_going = False
             print("Sorry, that's wrong. Final score: {}".format(
                 self.player["score"]))
         else:
             self.player["score"] += 1
             self.a = self.b
             self.b = data.pop()
             print("You're right! Current score: {}".format(
                 self.player["score"]))
示例#4
0
  if score == 0:
    print(logo)
    print(f"Compare A: {a['name']}, {a['description']}, from {a['country']}.")
    print(vs)
    print(f"Against b: {b['name']}, {b['description']}, from {b['country']}.")
  else:
    print(logo)
    print(f"You're right! Current score: {score}")
    print(f"Compare A: {a['name']}, {a['description']}, from {a['country']}.")
    print(vs)
    print(f"Against b: {b['name']}, {b['description']}, from {b['country']}.")


while True:
  if score == 0:
    choice_a = data.pop(random.randint(0,length))
    choice_b = data.pop(random.randint(0,length))
  else:
    choice_a = choice_b
    choice_b = data.pop(random.randint(0,length))

  display_text(choice_a,choice_b, score)

  answer = input("Who has more followers? Type 'A' or 'B': ").title()
  correct = more_followers(choice_a, choice_b)

  clear()

  if answer == correct:
    score +=1
  else:
示例#5
0
    data_a_followers = data_a["follower_count"]
    data_b_followers = data_b["follower_count"]

    if data_a_followers > data_b_followers:
        return answer == "A"
    else:
        return answer == "B"


should_continue = True
counter = 0

while should_continue:
    compare_a_number = random.randint(0, len(data) - 1)
    compare_a_data = data[compare_a_number]
    data.pop(compare_a_number)

    print_info(compare_a_data)
    print(vs)

    compare_b_number = random.randint(0, len(data) - 1)
    data.pop(compare_b_number)
    compare_b_data = data[compare_b_number]

    print_info(compare_b_data)
    answer = input("Who has more followers? Type A or B :")
    should_continue = judge(compare_a_data, compare_b_data, answer)

    if should_continue is True:
        counter += 1
    else:
示例#6
0
def random_character(data):
    character = {}
    random_index = random.randint(0, len(data) - 1)
    character = data[random_index]
    data.pop(random_index)
    return character
示例#7
0
 def __init__(self):
     random.shuffle(data)
     self.data = data
     self.player = {"score": 0}
     self.a = data.pop()
     self.b = data.pop()