コード例 #1
0
ファイル: cards_eng.py プロジェクト: stinisson/Poke-mood
def quiz_card(player, poketer, is_cpu, available_poketers):

    if is_cpu:
        x = f"""{player.name} valde quiz och har nu chansen att vinna en till Poketer! """
        print_frame([x], poketer.color, 15)
    else:
        x = f"""
        Quiz-dags! Om du svarar rätt på alla quiz-frågor får du välja en till Poketer. Frågekategorierna som finns
är datorer, matematik och vetenskap/natur. Kategorierna väljs slumpmässigt. Lycka till!"""
        print_frame([x], 'white', 15)

    input("\nTryck enter för att fortsätta\n")

    won_a_poketer = quiz()

    input("\nTryck enter för att fortsätta\n")

    if won_a_poketer:
        x = f"""Bra jobbat! Du har vunnit en ny Poketer!"""
        print_frame([x], poketer.color, 15)
        quiz_poke = choose_poketer(available_poketers, is_cpu=False)
        if quiz_poke is not None:
            player.add_team(quiz_poke)
    else:
        x = f"""Tyvärr! Du hade inte alla rätt på quizet så du vann inte en till Poketer. Bättre lycka nästa gång!"""
        print_frame([x], poketer.color, 15)

    input("\nTryck enter för att fortsätta\n")
コード例 #2
0
def card_block(user, user_pokemon, cpu, cpu_pokemon, is_cpu):
    if is_cpu:
        x = f"{cpu.name} valde att blocka!"
        print_frame([x], cpu_pokemon.color, 15)
    else:
        x = "Du valde block! Nu är det dags för battle!"
        print_frame([x], user_pokemon.color, 15)

    input("\nPress Enter to continue\n")

    if is_cpu:
        cpu_pokemon.block(user, user_pokemon)
        if cpu_pokemon.get_health() <= 0:
            print(f'*** Din motståndares Poketer1 {cpu_pokemon.name} svimmade. {user_pokemon.name} vann! ***')
    else:
        user_pokemon.block(cpu, cpu_pokemon)
        if user_pokemon.get_health() <= 0:
            print(f'*** Din poketer {user_pokemon.name} svimmade. {cpu_pokemon.name} vann!')

    input("\nPress Enter to continue\n")
コード例 #3
0
def card_attack(user_pokemon, cpu, cpu_pokemon, is_cpu):
    if is_cpu:
        x = f"{cpu.name} chooses to Attack!"
        print_frame([x], cpu_pokemon.color, 15)
    else:
        x = "You chooses to attack! Time to battle!"
        print_frame([x], user_pokemon.color, 15)

    input("\nPress Enter to continue\n")

    if is_cpu:
        cpu_pokemon.attack_fnc(user_pokemon)
        if user_pokemon.get_health() <= 0:
            print(f'*** Your Poketer1 {user_pokemon.name} fainted. {cpu_pokemon.name} won! ***')
    else:
        user_pokemon.attack_fnc(cpu_pokemon)
        if cpu_pokemon.get_health() <= 0:
            print(f'*** Your opponents Poketer1 {cpu_pokemon.name} fainted. {user_pokemon.name} won! ***')

    input("\nPress Enter to continue\n")
コード例 #4
0
def card_attack(user_pokemon, cpu, cpu_pokemon, is_cpu):
    if is_cpu:
        x = f"{cpu.name} valde att attackera!"
        print_frame([x], cpu_pokemon.color, 15)
    else:
        x = "Du valde att attackera! Nu är det dags för battle!"
        print_frame([x], user_pokemon.color, 15)

    input("\nTryck enter för att fortsätta\n")

    if is_cpu:
        cpu_pokemon.attack_fnc(user_pokemon)
        if user_pokemon.get_health() <= 0:
            print(f'*** Din poketer {user_pokemon.name} svimmade. {cpu_pokemon.name} vann! ***')
    else:
        user_pokemon.attack_fnc(cpu_pokemon)
        if cpu_pokemon.get_health() <= 0:
            print(f'*** Din motståndares Poketer1 {cpu_pokemon.name} svimmade. {user_pokemon.name} vann! ***')

    input("\nTryck enter för att fortsätta\n")
コード例 #5
0
ファイル: cards_eng.py プロジェクト: stinisson/Poke-mood
def intro_card(poketer, is_cpu, live):
    if is_cpu:
        cities = get_cities()
        city = random.choice(cities)
    else:
        x = """
        
        Your Poketer has a certain mood. You now have the opportunity to increase your Poketer's health
        by searching for a city in Sweden where you think the inhabitants are in the same mood as your Poketer.
        The residents' mood is based on what they tweet. The more emotional they are, the more they increase
        your Poketer's health. Good luck!
        
        """
        print_frame([x], 'white', 15)
        city = choose_city()

    print("This may take a while. Hang on! :)")

    mood_score = calc_mood_score(poketer.mood, city, live=live)

    if mood_score is None:
        poketer.add_health(20)
        poketer.add_max_health(20)
    else:
        poketer.add_health(mood_score)
        poketer.add_max_health(mood_score)

    if is_cpu:
        w = f"{poketer.name} selected {city.capitalize()}. Tweet, tweet!"
    else:
        w = f"... Tweet, tweet! Calculates mood for the inhabitants of {city.capitalize()} ..."

    x = f"{poketer.name} increased its health by {mood_score} p! {poketer.catchword}"
    if mood_score is None:
        x = f"Something went wrong but {poketer.name} increased its health by 20 p! {poketer.catchword}"

    y = ""
    z = poketer.get_stats()
    print_frame([w, x, y, z], poketer.color, 15)

    input("\nPress Enter to continue")
コード例 #6
0
def intro_card(poketer, is_cpu, live):
    if is_cpu:
        cities = get_cities()
        city = random.choice(cities)
    else:
        x = """
        Din Poketer1 har ett visst humör. Du har nu möjligheten att öka din Poketers hälsa
        genom att söka efter en stad i Sverige där du tror att invånarna är på samma humör som din Poketer1.
        Invånarnas humör baseras på vad de twittrar. Ju mer känslosamma de är desto mer ökar
        din Poketers hälsa. Lycka till!"""
        print_frame([x], 'white', 15)
        city = choose_city()

    print("Det här kan ta en liten stund. Häng kvar! :)")

    mood_score = calc_mood_score(poketer.mood, city, live=live)

    if mood_score is None:
        poketer.add_health(20)
        poketer.add_max_health(20)
    else:
        poketer.add_health(mood_score)
        poketer.add_max_health(mood_score)

    if is_cpu:
        w = f"{poketer.name} valde {city.capitalize()}. Tweet, tweet!"
    else:
        w = f"... Tweet, tweet! Beräknar humör för invånarna i {city.capitalize()} ..."

    x = f"{poketer.name} fick {mood_score} p i ökad hälsa! {poketer.catchword}"
    if mood_score is None:
        x = f"Något gick fel men {poketer.name} får 20 p i ökad hälsa! {poketer.catchword}"
    y = ""
    z = poketer.get_stats()
    print_frame([w, x, y, z], poketer.color, 15)

    input("\nTryck enter för att fortsätta")
コード例 #7
0
ファイル: cards_eng.py プロジェクト: stinisson/Poke-mood
def chance_card_attack(player, poketer, is_cpu, live):
    attack_bonus = 20
    if is_cpu:
        cities = get_cities()
        city = random.choice(cities)
        emotions = get_emotions()
        emotion = random.choice(emotions)
        x = f"{player.name} chooses a chancecard - attack!"
        if emotion == 'sad':
            y = f"""{player.name} is guessing that people in {city.capitalize()} are sad."""
        else:
            y = f"""{player.name} is guessing that people in {city.capitalize()} are {emotion}."""
        print_frame([x, y], poketer.color, 15)
    else:
        x = f"""
        Chancecard - attack! Choose a city and guess which mood is the most common among its inhabitants. If your guess is
        correct, your Poketers attack-power is incressed by {attack_bonus} p. If your guess is incorrect, your Poketer 
        will loss attack-power by {attack_bonus} p. Good luck!

        """

        print_frame([x], 'white', 15)
        city = choose_city()
        emotion = choose_emotion(city)

    print("\nThis may take a while. Hang on! :)")
    most_frequent_emotions = mood_analysis(city=city, live=live)

    if emotion in most_frequent_emotions:
        poketer.add_attack(attack_bonus)
        w = f"""Correct! In {city.capitalize()} are people mostly {emotion}."""
        x = f"""{poketer.name} recives {attack_bonus} p incressed attack-power!"""
    else:
        poketer.add_attack(-attack_bonus)
        if poketer.get_attack() < 0:
            poketer.set_attack(0)
        w = f"Wrong! In {city.capitalize()} are people mostly {most_frequent_emotions[0]}, not {emotion}!"
        x = f"{poketer.name} loses {attack_bonus} p attack-power."
    y = ""
    z = poketer.get_stats()

    print_frame([w, x, y, z], poketer.color, 15)
    input("\nPress Enter to continue")
コード例 #8
0
def chance_card_attack(player, poketer, is_cpu, live):
    attack_bonus = 20
    if is_cpu:
        cities = get_cities()
        city = random.choice(cities)
        emotions = get_emotions()
        emotion = random.choice(emotions)
        x = f"{player.name} valde chanskort - attack!"
        if emotion == 'ledsen':
            y = f"""{player.name} gissar att invånarna i {city.capitalize()} är ledsna."""
        else:
            y = f"""{player.name} gissar att invånarna i {city.capitalize()} är {emotion}a."""
        print_frame([x, y], poketer.color, 15)
    else:
        x = f"""
        Chanskort - attack! Välj en stad och gissa vilket humör som är mest förekommande bland invånarna.
        Gissar du rätt belönas din Poketer1 med {attack_bonus} p i ökad attack-styrka. Gissar du fel bestraffas din Poketer1
        och förlorar {attack_bonus} p i attack-styrka. Lycka till!"""
        print_frame([x], 'white', 15)
        city = choose_city()
        emotion = choose_emotion(city)

    print("\nDet här kan ta en liten stund. Häng kvar! :)")
    most_frequent_emotions = mood_analysis(city=city, live=live)

    if emotion in most_frequent_emotions:
        poketer.add_attack(attack_bonus)
        w = f"""Det var rätt! I {city.capitalize()} är man {emotion}."""
        x = f"""{poketer.name} får {attack_bonus} p i ökad attack-styrka!"""
    else:
        poketer.add_attack(-attack_bonus)
        if poketer.get_attack() < 0:
            poketer.set_attack(0)
        w = f"Det var fel! I {city.capitalize()} är man {most_frequent_emotions[0]}, inte {emotion}!"
        x = f"{poketer.name} bestraffas med {attack_bonus} p i minskad attack-styrka."
    y = ""
    z = poketer.get_stats()

    print_frame([w, x, y, z], poketer.color, 15)
    input("\nTryck enter för att fortsätta")
コード例 #9
0
ファイル: cards_eng.py プロジェクト: stinisson/Poke-mood
def chance_card_health(player, poketer, is_cpu):
    health_bonus = 10
    if is_cpu:
        x = f"{player.name} valde chanskort - hälsa!"
        print_frame([x], poketer.color, 15)
    else:
        x = f"""
        Twitter-vadslagning! Har du koll på vad som trendar på sociala medier?
        Skriv in ett ord och vilket språk du vill använda i sökningen. Gissa om
        de senaste tweetsen som innehåller detta ord är mest positiva, mest negativa
        eller neutrala. Om du gissar rätt belönas du med {health_bonus} p i ökad hälsa.
        Om du gissar fel bestraffas du med {health_bonus} p minskad hälsa. Lycka till!"""
        print_frame([x], 'white', 15)

    user_select_from_fallback = False
    while True:
        keyword, language, attitude, file_name = input_to_chance_card_health(
            is_cpu, user_select_from_fallback)

        if is_cpu:
            x = f"""{player.name} gissar att {keyword} har mest {attitude} innehåll på engelskspråkiga Twitter."""
            print_frame([x], poketer.color, 15)
            print("Det här kan ta en liten stund. Häng kvar! :)")
            result = sentiment_analysis(keyword=keyword,
                                        language=language,
                                        file_name=file_name,
                                        live=False)
        else:
            print("Det här kan ta en liten stund. Häng kvar! :)")
            result = sentiment_analysis(keyword=keyword,
                                        language=language,
                                        file_name=file_name,
                                        live=True)

        if result == 'connection_error':
            x = """Det går tyvärr inte att söka på Twitter just nu. Du får istället testa dina kunskaper
             på ett förvalt sökord på engelskspråkiga Twitter."""
            print_frame([x], 'white', 15)
            user_select_from_fallback = True
            continue

        if result == 'too_few_results':
            if is_cpu:
                x = f"Tyvärr, hittade för få tweets innehållandes {keyword}."
                print_frame([x], 'white', 15)
                return
            else:
                x = f"""Hittade för få tweets innehållandes {keyword}. Ett tips är att söka efter något som är
mer aktuellt i samhällsdebatten."""
                print_frame([x], 'white', 15)
        else:
            break

    if result != 'connection_error':
        if attitude == result:
            poketer.add_health(health_bonus)
            poketer.add_max_health(health_bonus)
            w = f"Rätt! {keyword} har mest {result} innehåll på Twitter."
            x = f"{poketer.name} belönas med {health_bonus} p i ökad hälsa!"
        else:
            poketer.add_health(-health_bonus)
            poketer.add_max_health(-health_bonus)
            w = f"""Det var fel, {keyword} har mest {result} innehåll på Twitter!"""
            x = f"""{poketer.name} bestraffas med {health_bonus} p i minskad hälsa."""
        y = ""
        z = poketer.get_stats()

        print_frame([w, x, y, z], poketer.color, 15)

    input("\nTryck enter för att fortsätta")
コード例 #10
0
ファイル: main.py プロジェクト: KYHlings/Poke-Mood2.0
def start_game(live):
    draw_welcome_screen()
    username = input("Vänligen ange ditt namn: ")
    poketer_mood_explanation_text(username)
    input("\nTryck enter för att fortsätta\n")

    gunnar = Poketer(colored("Glada Gunnar", 'yellow'),
                     'happy',
                     'yellow',
                     50,
                     50,
                     45,
                     catchword="#YOLO")
    ada = Poketer(colored("Aggressiva Ada", 'red'),
                  'angry',
                  'red',
                  50,
                  50,
                  45,
                  catchword="#FTW")
    louise = Poketer(colored("Ledsna Louise", 'blue'),
                     'sad',
                     'blue',
                     50,
                     50,
                     45,
                     catchword="#TGIF")
    kalle = Poketer(colored("Kärleksfulla Kalle", 'magenta'),
                    'loving',
                    'magenta',
                    50,
                    50,
                    45,
                    catchword="#XOXO")
    available_poketers = [gunnar, ada, louise, kalle]

    user_pokemon = choose_poketer(available_poketers, is_cpu=False)
    cpu_pokemon = choose_poketer(available_poketers, is_cpu=True)

    user = User(colored(username, user_pokemon.color))
    user.add_team(user_pokemon)

    cpu = User(colored("Olof", cpu_pokemon.color))
    cpu.add_team(cpu_pokemon)

    x = f"\n{user.name}, din Poketer1 är {user_pokemon.name}."
    y = user_pokemon.get_stats()
    print_frame([x, y], user_pokemon.color, 15)

    x = f"Din motståndare är {cpu.name}. {cpu.name} valde poketer {cpu_pokemon.name}. {cpu_pokemon.get_stats()}"
    print_frame([x], cpu_pokemon.color, 15)

    input("\nTryck enter för att fortsätta")

    intro_card(poketer=user_pokemon, is_cpu=False, live=live)
    intro_card(poketer=cpu_pokemon, is_cpu=True, live=live)

    is_winner = game_loop(user=user,
                          user_pokemon=user_pokemon,
                          cpu=cpu,
                          cpu_pokemon=cpu_pokemon,
                          live=live,
                          available_poketers=available_poketers)

    if is_winner == "user":
        x = "Grattis! Du vann! Lejon jämför sig inte med människor - Ibrahimovic."
        draw_end_screen(x, user_pokemon.color, 15)
    else:
        x = "Du förlorade! Du kan inte vinna om du inte lär dig hur man förlorar - Abdul-Jabbar."
        draw_end_screen(x, user_pokemon.color, 15)