----------------------------------------------------------------------------- this is the output :) == 3 ENEMIES HAS SPAWNED! == == NAME: PLAGUE SPITTER HP: 33 == == NAME: BLOOD REAVER HP: 30 == == NAME: FROST WRAITH HP: 30 == == STARTING ROUND == == WHO DO YOU WANT TO ATTACK == == 4 ENEMIES HAS SPAWNED! == == NAME: FROST WRAITH HP: 32 == == NAME: BLOOD REAVER HP: 24 == == NAME: VOID STALKER HP: 25 == == NAME: PLAGUE SPITTER HP: 26 == == STARTING ROUND == == WHO DO YOU WANT TO ATTACK == DEBUG: Entered EnemyMenu == NAME: FROST WRAITH HEALTH: 32 == == NAME: BLOOD REAVER HEALTH: 24 == == NAME: VOID STALKER HEALTH: 25 == == NAME: PLAGUE SPITTER HEALTH: 26 == Choose Enemy > ----------------------------------------------------------------------------- this is the EnemyMenu() that is causing spawer to print twice: def EnemyMenu(): from GameClasses import GameVariables for i, p in zip(GameVariables.chosen_names, GameVariables.chosen_hp): print (f"== NAME: {i} HEALTH: {p} ==") ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- This is the main bit of the code that i am working on right now :D i am only calling the spawner and enemy attack to run but whenever i do run the code spawner runs twiec but only when i put EnemyMenu() into the enemy attack function. def Spawner(self): import random, time global GameVariables print (f"== {GameVariables.enemy_count} ENEMIES HAS SPAWNED! ==") for _ in range(GameVariables.enemy_count): self.name = random.choice(GameVariables.name_list) GameVariables.name_list.remove(self.name) GameVariables.chosen_names.append(self.name) self.health = random.randint(20, 40) creationtext = f"== NAME: {self.name} HP: {self.health} ==" GameVariables.chosen_hp.append(self.health) print(creationtext) GameVariables.enemycreation.append(creationtext) def EnemyAttack(self): from Gamelists import shield_bash_response ,raging_strike_response, whirlwind_slash_response import random from GameFunctions import kill_section3, show_charcter_Death, EnemyMenu while True: print("== STARTING ROUND ==") print("== WHO DO YOU WANT TO ATTACK ==") EnemyMenu() answer = input("Choose Enemy > ").lower() if answer == "1": print(f"== YOU CHOSE TO ATTACK {GameVariables.chosen_names[0]} ==") print(f"== HOW WILL YOU ATTACK ==n Name: {GameVariables.chosen_names[0]} HP: {GameVariables.chosen_hp[0]} ==") print(f"== Choose Shield Bash - {GameVariables.shield_bash}Dmg - Raging Strike {GameVariables.shield_bash}Dmg - Whirlwind Strike {GameVariables.whirlwind_slash}Dmg ==") attack_answer = input("Choose Atack > ") if attack_answer == "shield bash": GameVariables.chosen_hp[0] -= 10 shield_bash_print = random.shuffle(shield_bash_response) print(shield_bash_print) print("== WHO DO YOU CHOOSE TO ATTACK NEXT! ==") elif attack_answer == "raging strike": GameVariables.chosen_hp[0] -= 15 raging_strike_print = random.shuffle(raging_strike_response) print(raging_strike_print) print("== WHO DO YOU CHOOSE TO ATTACK NEXT! ==") elif attack_answer == "whirlwind strike": GameVariables.chosen_hp[0] -= 5 whirlwind_strike_print = random.shuffle(whirlwind_slash_response) print(whirlwind_strike_print) print("== WHO DO YOU CHOOSE TO ATTACK NEXT! ==") else: print("== PLEASE ENTER A VALID INPUT ==") elif answer == "2": print(f"== YOU CHOSE TO ATTACK {GameVariables.chosen_names[1]} ==") print(f"== HOW WILL YOU ATTACK ==n Name: {GameVariables.chosen_names[1]} HP: {GameVariables.chosen_hp[1]} ==") print(f"== Choose Shield Bash - {GameVariables.shield_bash}Dmg - Raging Strike {GameVariables.shield_bash}Dmg - Whirlwind Strike {GameVariables.whirlwind_slash}Dmg ==") attack_answer = input("Choose Atack > ") if attack_answer == "shield bash": GameVariables.chosen_hp[1] -= 10 shield_bash_print = random.shuffle(shield_bash_response) print(shield_bash_print) print("== WHO DO YOU CHOOSE TO ATTACK NEXT! ==") elif attack_answer == "raging strike": GameVariables.chosen_hp[1] -= 15 raging_strike_print = random.shuffle(raging_strike_response) print(raging_strike_print) print("== WHO DO YOU CHOOSE TO ATTACK NEXT! ==") elif attack_answer == "whirlwind strike": GameVariables.chosen_hp[1] -= 5 whirlwind_strike_print = random.shuffle(whirlwind_slash_response) print(whirlwind_strike_print) print("== WHO DO YOU CHOOSE TO ATTACK NEXT! ==") else: print("== PLEASE ENTER A VALID INPUT ==") elif answer == "3": print(f"== YOU CHOSE TO ATTACK {GameVariables.chosen_names[2]} ==") print(f"== HOW WILL YOU ATTACK ==n Name: {GameVariables.chosen_names[2]} HP: {GameVariables.chosen_hp[2]} ==") print(f"== Choose Shield Bash - {GameVariables.shield_bash}Dmg - Raging Strike {GameVariables.shield_bash}Dmg - Whirlwind Strike {GameVariables.whirlwind_slash}Dmg ==") attack_answer = input("Choose Atack > ") if attack_answer == "shield bash": GameVariables.chosen_hp[2] -= 10 shield_bash_print = random.shuffle(shield_bash_response) print(shield_bash_print) print("== WHO DO YOU CHOOSE TO ATTACK NEXT! ==") elif attack_answer == "raging strike": GameVariables.chosen_hp[2] -= 15 raging_strike_print = random.shuffle(raging_strike_response) print(raging_strike_print) print("== WHO DO YOU CHOOSE TO ATTACK NEXT! ==") elif attack_answer == "whirlwind strike": GameVariables.chosen_hp[2] -= 5 whirlwind_strike_print = random.shuffle(whirlwind_slash_response) print(whirlwind_strike_print) print("== WHO DO YOU CHOOSE TO ATTACK NEXT! ==") else: print("== PLEASE ENTER A VALID INPUT ==") elif answer == "4": print(f"== YOU CHOSE TO ATTACK {GameVariables.chosen_names[3]} ==") print(f"== HOW WILL YOU ATTACK ==n Name: {GameVariables.chosen_names[3]} HP: {GameVariables.chosen_hp[3]} ==") print(f"== Choose Shield Bash - {GameVariables.shield_bash}Dmg - Raging Strike {GameVariables.shield_bash}Dmg - Whirlwind Strike {GameVariables.whirlwind_slash}Dmg ==") attack_answer = input("Choose Atack > ") if attack_answer == "shield bash": GameVariables.chosen_hp[3] -= 10 shield_bash_print = random.shuffle(shield_bash_response) print(shield_bash_print) print("== WHO DO YOU CHOOSE TO ATTACK NEXT! ==") elif attack_answer == "raging strike": GameVariables.chosen_hp[3] -= 15 raging_strike_print = random.shuffle(raging_strike_response) print(raging_strike_print) print("== WHO DO YOU CHOOSE TO ATTACK NEXT! ==") elif attack_answer == "whirlwind strike": GameVariables.chosen_hp[3] -= 5 whirlwind_strike_print = random.shuffle(whirlwind_slash_response) print(whirlwind_strike_print) print("== WHO DO YOU CHOOSE TO ATTACK NEXT! ==") else: print("== PLEASE ENTER A VALID INPUT ==") else: print("== PLEASE TYPE A VALID INPUT :) ==") if not all(x == 0 for x in GameVariables.chosen_hp): kill_section3() elif GameVariables.Warrior <= 0: show_charcter_Death() -----------------------------------------------------------------------------
submitted by /u/Amazing_Pattern_3382
[link] [comments]
r/learnpython —————————————————————————– this is the output 🙂 == 3 ENEMIES HAS SPAWNED! == == NAME: PLAGUE SPITTER HP: 33 == == NAME: BLOOD REAVER HP: 30 == == NAME: FROST WRAITH HP: 30 == == STARTING ROUND == == WHO DO YOU WANT TO ATTACK == == 4 ENEMIES HAS SPAWNED! == == NAME: FROST WRAITH HP: 32 == == NAME: BLOOD REAVER HP: 24 == == NAME: VOID STALKER HP: 25 == == NAME: PLAGUE SPITTER HP: 26 == == STARTING ROUND == == WHO DO YOU WANT TO ATTACK == DEBUG: Entered EnemyMenu == NAME: FROST WRAITH HEALTH: 32 == == NAME: BLOOD REAVER HEALTH: 24 == == NAME: VOID STALKER HEALTH: 25 == == NAME: PLAGUE SPITTER HEALTH: 26 == Choose Enemy > —————————————————————————– this is the EnemyMenu() that is causing spawer to print twice: def EnemyMenu(): from GameClasses import GameVariables for i, p in zip(GameVariables.chosen_names, GameVariables.chosen_hp): print (f”== NAME: {i} HEALTH: {p} ==”) —————————————————————————– —————————————————————————– This is the main bit of the code that i am working on right now 😀 i am only calling the spawner and enemy attack to run but whenever i do run the code spawner runs twiec but only when i put EnemyMenu() into the enemy attack function. def Spawner(self): import random, time global GameVariables print (f”== {GameVariables.enemy_count} ENEMIES HAS SPAWNED! ==”) for _ in range(GameVariables.enemy_count): self.name = random.choice(GameVariables.name_list) GameVariables.name_list.remove(self.name) GameVariables.chosen_names.append(self.name) self.health = random.randint(20, 40) creationtext = f”== NAME: {self.name} HP: {self.health} ==” GameVariables.chosen_hp.append(self.health) print(creationtext) GameVariables.enemycreation.append(creationtext) def EnemyAttack(self): from Gamelists import shield_bash_response ,raging_strike_response, whirlwind_slash_response import random from GameFunctions import kill_section3, show_charcter_Death, EnemyMenu while True: print(“== STARTING ROUND ==”) print(“== WHO DO YOU WANT TO ATTACK ==”) EnemyMenu() answer = input(“Choose Enemy > “).lower() if answer == “1”: print(f”== YOU CHOSE TO ATTACK {GameVariables.chosen_names[0]} ==”) print(f”== HOW WILL YOU ATTACK ==n Name: {GameVariables.chosen_names[0]} HP: {GameVariables.chosen_hp[0]} ==”) print(f”== Choose Shield Bash – {GameVariables.shield_bash}Dmg – Raging Strike {GameVariables.shield_bash}Dmg – Whirlwind Strike {GameVariables.whirlwind_slash}Dmg ==”) attack_answer = input(“Choose Atack > “) if attack_answer == “shield bash”: GameVariables.chosen_hp[0] -= 10 shield_bash_print = random.shuffle(shield_bash_response) print(shield_bash_print) print(“== WHO DO YOU CHOOSE TO ATTACK NEXT! ==”) elif attack_answer == “raging strike”: GameVariables.chosen_hp[0] -= 15 raging_strike_print = random.shuffle(raging_strike_response) print(raging_strike_print) print(“== WHO DO YOU CHOOSE TO ATTACK NEXT! ==”) elif attack_answer == “whirlwind strike”: GameVariables.chosen_hp[0] -= 5 whirlwind_strike_print = random.shuffle(whirlwind_slash_response) print(whirlwind_strike_print) print(“== WHO DO YOU CHOOSE TO ATTACK NEXT! ==”) else: print(“== PLEASE ENTER A VALID INPUT ==”) elif answer == “2”: print(f”== YOU CHOSE TO ATTACK {GameVariables.chosen_names[1]} ==”) print(f”== HOW WILL YOU ATTACK ==n Name: {GameVariables.chosen_names[1]} HP: {GameVariables.chosen_hp[1]} ==”) print(f”== Choose Shield Bash – {GameVariables.shield_bash}Dmg – Raging Strike {GameVariables.shield_bash}Dmg – Whirlwind Strike {GameVariables.whirlwind_slash}Dmg ==”) attack_answer = input(“Choose Atack > “) if attack_answer == “shield bash”: GameVariables.chosen_hp[1] -= 10 shield_bash_print = random.shuffle(shield_bash_response) print(shield_bash_print) print(“== WHO DO YOU CHOOSE TO ATTACK NEXT! ==”) elif attack_answer == “raging strike”: GameVariables.chosen_hp[1] -= 15 raging_strike_print = random.shuffle(raging_strike_response) print(raging_strike_print) print(“== WHO DO YOU CHOOSE TO ATTACK NEXT! ==”) elif attack_answer == “whirlwind strike”: GameVariables.chosen_hp[1] -= 5 whirlwind_strike_print = random.shuffle(whirlwind_slash_response) print(whirlwind_strike_print) print(“== WHO DO YOU CHOOSE TO ATTACK NEXT! ==”) else: print(“== PLEASE ENTER A VALID INPUT ==”) elif answer == “3”: print(f”== YOU CHOSE TO ATTACK {GameVariables.chosen_names[2]} ==”) print(f”== HOW WILL YOU ATTACK ==n Name: {GameVariables.chosen_names[2]} HP: {GameVariables.chosen_hp[2]} ==”) print(f”== Choose Shield Bash – {GameVariables.shield_bash}Dmg – Raging Strike {GameVariables.shield_bash}Dmg – Whirlwind Strike {GameVariables.whirlwind_slash}Dmg ==”) attack_answer = input(“Choose Atack > “) if attack_answer == “shield bash”: GameVariables.chosen_hp[2] -= 10 shield_bash_print = random.shuffle(shield_bash_response) print(shield_bash_print) print(“== WHO DO YOU CHOOSE TO ATTACK NEXT! ==”) elif attack_answer == “raging strike”: GameVariables.chosen_hp[2] -= 15 raging_strike_print = random.shuffle(raging_strike_response) print(raging_strike_print) print(“== WHO DO YOU CHOOSE TO ATTACK NEXT! ==”) elif attack_answer == “whirlwind strike”: GameVariables.chosen_hp[2] -= 5 whirlwind_strike_print = random.shuffle(whirlwind_slash_response) print(whirlwind_strike_print) print(“== WHO DO YOU CHOOSE TO ATTACK NEXT! ==”) else: print(“== PLEASE ENTER A VALID INPUT ==”) elif answer == “4”: print(f”== YOU CHOSE TO ATTACK {GameVariables.chosen_names[3]} ==”) print(f”== HOW WILL YOU ATTACK ==n Name: {GameVariables.chosen_names[3]} HP: {GameVariables.chosen_hp[3]} ==”) print(f”== Choose Shield Bash – {GameVariables.shield_bash}Dmg – Raging Strike {GameVariables.shield_bash}Dmg – Whirlwind Strike {GameVariables.whirlwind_slash}Dmg ==”) attack_answer = input(“Choose Atack > “) if attack_answer == “shield bash”: GameVariables.chosen_hp[3] -= 10 shield_bash_print = random.shuffle(shield_bash_response) print(shield_bash_print) print(“== WHO DO YOU CHOOSE TO ATTACK NEXT! ==”) elif attack_answer == “raging strike”: GameVariables.chosen_hp[3] -= 15 raging_strike_print = random.shuffle(raging_strike_response) print(raging_strike_print) print(“== WHO DO YOU CHOOSE TO ATTACK NEXT! ==”) elif attack_answer == “whirlwind strike”: GameVariables.chosen_hp[3] -= 5 whirlwind_strike_print = random.shuffle(whirlwind_slash_response) print(whirlwind_strike_print) print(“== WHO DO YOU CHOOSE TO ATTACK NEXT! ==”) else: print(“== PLEASE ENTER A VALID INPUT ==”) else: print(“== PLEASE TYPE A VALID INPUT 🙂 ==”) if not all(x == 0 for x in GameVariables.chosen_hp): kill_section3() elif GameVariables.Warrior <= 0: show_charcter_Death() —————————————————————————– submitted by /u/Amazing_Pattern_3382 [link] [comments]
----------------------------------------------------------------------------- this is the output :) == 3 ENEMIES HAS SPAWNED! == == NAME: PLAGUE SPITTER HP: 33 == == NAME: BLOOD REAVER HP: 30 == == NAME: FROST WRAITH HP: 30 == == STARTING ROUND == == WHO DO YOU WANT TO ATTACK == == 4 ENEMIES HAS SPAWNED! == == NAME: FROST WRAITH HP: 32 == == NAME: BLOOD REAVER HP: 24 == == NAME: VOID STALKER HP: 25 == == NAME: PLAGUE SPITTER HP: 26 == == STARTING ROUND == == WHO DO YOU WANT TO ATTACK == DEBUG: Entered EnemyMenu == NAME: FROST WRAITH HEALTH: 32 == == NAME: BLOOD REAVER HEALTH: 24 == == NAME: VOID STALKER HEALTH: 25 == == NAME: PLAGUE SPITTER HEALTH: 26 == Choose Enemy > ----------------------------------------------------------------------------- this is the EnemyMenu() that is causing spawer to print twice: def EnemyMenu(): from GameClasses import GameVariables for i, p in zip(GameVariables.chosen_names, GameVariables.chosen_hp): print (f"== NAME: {i} HEALTH: {p} ==") ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- This is the main bit of the code that i am working on right now :D i am only calling the spawner and enemy attack to run but whenever i do run the code spawner runs twiec but only when i put EnemyMenu() into the enemy attack function. def Spawner(self): import random, time global GameVariables print (f"== {GameVariables.enemy_count} ENEMIES HAS SPAWNED! ==") for _ in range(GameVariables.enemy_count): self.name = random.choice(GameVariables.name_list) GameVariables.name_list.remove(self.name) GameVariables.chosen_names.append(self.name) self.health = random.randint(20, 40) creationtext = f"== NAME: {self.name} HP: {self.health} ==" GameVariables.chosen_hp.append(self.health) print(creationtext) GameVariables.enemycreation.append(creationtext) def EnemyAttack(self): from Gamelists import shield_bash_response ,raging_strike_response, whirlwind_slash_response import random from GameFunctions import kill_section3, show_charcter_Death, EnemyMenu while True: print("== STARTING ROUND ==") print("== WHO DO YOU WANT TO ATTACK ==") EnemyMenu() answer = input("Choose Enemy > ").lower() if answer == "1": print(f"== YOU CHOSE TO ATTACK {GameVariables.chosen_names[0]} ==") print(f"== HOW WILL YOU ATTACK ==n Name: {GameVariables.chosen_names[0]} HP: {GameVariables.chosen_hp[0]} ==") print(f"== Choose Shield Bash - {GameVariables.shield_bash}Dmg - Raging Strike {GameVariables.shield_bash}Dmg - Whirlwind Strike {GameVariables.whirlwind_slash}Dmg ==") attack_answer = input("Choose Atack > ") if attack_answer == "shield bash": GameVariables.chosen_hp[0] -= 10 shield_bash_print = random.shuffle(shield_bash_response) print(shield_bash_print) print("== WHO DO YOU CHOOSE TO ATTACK NEXT! ==") elif attack_answer == "raging strike": GameVariables.chosen_hp[0] -= 15 raging_strike_print = random.shuffle(raging_strike_response) print(raging_strike_print) print("== WHO DO YOU CHOOSE TO ATTACK NEXT! ==") elif attack_answer == "whirlwind strike": GameVariables.chosen_hp[0] -= 5 whirlwind_strike_print = random.shuffle(whirlwind_slash_response) print(whirlwind_strike_print) print("== WHO DO YOU CHOOSE TO ATTACK NEXT! ==") else: print("== PLEASE ENTER A VALID INPUT ==") elif answer == "2": print(f"== YOU CHOSE TO ATTACK {GameVariables.chosen_names[1]} ==") print(f"== HOW WILL YOU ATTACK ==n Name: {GameVariables.chosen_names[1]} HP: {GameVariables.chosen_hp[1]} ==") print(f"== Choose Shield Bash - {GameVariables.shield_bash}Dmg - Raging Strike {GameVariables.shield_bash}Dmg - Whirlwind Strike {GameVariables.whirlwind_slash}Dmg ==") attack_answer = input("Choose Atack > ") if attack_answer == "shield bash": GameVariables.chosen_hp[1] -= 10 shield_bash_print = random.shuffle(shield_bash_response) print(shield_bash_print) print("== WHO DO YOU CHOOSE TO ATTACK NEXT! ==") elif attack_answer == "raging strike": GameVariables.chosen_hp[1] -= 15 raging_strike_print = random.shuffle(raging_strike_response) print(raging_strike_print) print("== WHO DO YOU CHOOSE TO ATTACK NEXT! ==") elif attack_answer == "whirlwind strike": GameVariables.chosen_hp[1] -= 5 whirlwind_strike_print = random.shuffle(whirlwind_slash_response) print(whirlwind_strike_print) print("== WHO DO YOU CHOOSE TO ATTACK NEXT! ==") else: print("== PLEASE ENTER A VALID INPUT ==") elif answer == "3": print(f"== YOU CHOSE TO ATTACK {GameVariables.chosen_names[2]} ==") print(f"== HOW WILL YOU ATTACK ==n Name: {GameVariables.chosen_names[2]} HP: {GameVariables.chosen_hp[2]} ==") print(f"== Choose Shield Bash - {GameVariables.shield_bash}Dmg - Raging Strike {GameVariables.shield_bash}Dmg - Whirlwind Strike {GameVariables.whirlwind_slash}Dmg ==") attack_answer = input("Choose Atack > ") if attack_answer == "shield bash": GameVariables.chosen_hp[2] -= 10 shield_bash_print = random.shuffle(shield_bash_response) print(shield_bash_print) print("== WHO DO YOU CHOOSE TO ATTACK NEXT! ==") elif attack_answer == "raging strike": GameVariables.chosen_hp[2] -= 15 raging_strike_print = random.shuffle(raging_strike_response) print(raging_strike_print) print("== WHO DO YOU CHOOSE TO ATTACK NEXT! ==") elif attack_answer == "whirlwind strike": GameVariables.chosen_hp[2] -= 5 whirlwind_strike_print = random.shuffle(whirlwind_slash_response) print(whirlwind_strike_print) print("== WHO DO YOU CHOOSE TO ATTACK NEXT! ==") else: print("== PLEASE ENTER A VALID INPUT ==") elif answer == "4": print(f"== YOU CHOSE TO ATTACK {GameVariables.chosen_names[3]} ==") print(f"== HOW WILL YOU ATTACK ==n Name: {GameVariables.chosen_names[3]} HP: {GameVariables.chosen_hp[3]} ==") print(f"== Choose Shield Bash - {GameVariables.shield_bash}Dmg - Raging Strike {GameVariables.shield_bash}Dmg - Whirlwind Strike {GameVariables.whirlwind_slash}Dmg ==") attack_answer = input("Choose Atack > ") if attack_answer == "shield bash": GameVariables.chosen_hp[3] -= 10 shield_bash_print = random.shuffle(shield_bash_response) print(shield_bash_print) print("== WHO DO YOU CHOOSE TO ATTACK NEXT! ==") elif attack_answer == "raging strike": GameVariables.chosen_hp[3] -= 15 raging_strike_print = random.shuffle(raging_strike_response) print(raging_strike_print) print("== WHO DO YOU CHOOSE TO ATTACK NEXT! ==") elif attack_answer == "whirlwind strike": GameVariables.chosen_hp[3] -= 5 whirlwind_strike_print = random.shuffle(whirlwind_slash_response) print(whirlwind_strike_print) print("== WHO DO YOU CHOOSE TO ATTACK NEXT! ==") else: print("== PLEASE ENTER A VALID INPUT ==") else: print("== PLEASE TYPE A VALID INPUT :) ==") if not all(x == 0 for x in GameVariables.chosen_hp): kill_section3() elif GameVariables.Warrior <= 0: show_charcter_Death() -----------------------------------------------------------------------------
submitted by /u/Amazing_Pattern_3382
[link] [comments]