So I made a VERY basic text based adventure rpg game. It works fine enough but one issue i found was that the random number is rolled once and then it is the same forever. How do i make it re roll in each new instance. I also thought about adding a turn counter. This was also done before i learned about creating my own functions but i know now. Thank you for reading and i would appreciate any suggestions!
import random player_hp = 50 player_normal_attack = random.randint(1, 100 + 10) player_normal_damage = random.randint(1, 6) player_normal_damage_crit = random.randint(1, 6 * 2) player_strong_attack = random.randint(1, 100 - 10) player_strong_damage = random.randint(1, 6 + 5) player_strong_damage_crit = random.randint(1, 6 * 2 +5) player_defense = random.randint(1, 100) king_Hp = 50 king_normal_attack = random.randint(1, 100 + 10) king_normal_damage_crit = random.randint(1, 6 * 2) king_normal_damage = random.randint(1, 6) king_strong_attack = random.randint(1, 100 - 10) king_strong_damage = random.randint(1, 6 + 5) king_strong_damage_crit = random.randint(1, 6 * 2 +5) king_defense = random.randint(1, 100) king_attack_determine = random.randint(1, 100) input("Press Enter to Start... ") print("You are Via! A satyre with with fur as white as snow. You are from deep in the mountains, and have imense dexterity and agility! You have been sent to hunt a dangerous beast known as THE WILLOW KING!!!") print("He is a larged bipedal beast with the head of a deer, body of a hummand and legs of a horse. A quite devilish beast indeed!!!") input("Are you ready? ") print("You have been tracking the beast for days now, you are starving and exhausted. But you cannot stop until this fiend is slayed!!") while True: print("Perception: Success!! You see hoof tracks off to the east and a blood trail to the west") direction = input("Where do you want to go? East or West? ") if direction.lower() == "east": print("You follow these tracks to the east until you come to a dark cave.") affirm = input("Do you enter? ") if affirm.lower() == "yes": print("You come to a walk into the cave. You Smell a disgusting smell of rotten flesh. You see piles of rotten half eaten corpes and out of the shadows the beast stands! Begin Combat!") break if direction.lower() == "west": print("You follow the blood up a tall hill until you come to the entrance of a dark cave.") affirm = input("Do you enter? ") if affirm.lower() == "yes": print("you come to what appears to be a tall ridge servying the scene of the dark cave. There is a large pile of hay, it is its nest. You see the beast knawing on flesh below you. You have gotten the drop on it!") print("Begin Combat!") break if direction.lower() == "cake": print("you come to a cave. You walk inside and hear.... SURPRISE! It's a surprise party thrown by all your friends and family you have a an amazing time and eat cake and ice cream!!!") final = input("Press enter to continue... ") if direction.lower() == "east": king_Hp = king_Hp * 2 if direction.lower() == "west": king_Hp = king_Hp / 2 while player_hp or king_Hp > 0: pick_attack = input("Please select an attack. Quick or Strong? ") if pick_attack.lower() == "quick": print("You rolled", player_normal_attack, "to hit. THE WILLOW KING rolled", king_defense, "to doge!") if player_normal_attack >= king_defense: print("You Hit! an arrow sinks into the beast and deals", player_normal_damage, "damage!") king_Hp - player_normal_damage if player_normal_attack < king_defense: print("You miss! The beast doges!") or print("You miss! The beast catches the arrow") or print("You miss! The arrow goes wide") if player_normal_attack >= 95: Print("YOU CRIT!!!! YOU SINK AN ARROW DEEP INTO A VITAL ORGAN!!! YOU DEAL", player_strong_damage_crit, "DAMAGE!") king_Hp - player_normal_damage_crit if pick_attack.lower() == "strong": print("You rolled", player_strong_attack, "to hit. THE WILLOW KING rolled", king_defense, "to doge!") if player_strong_attack >= king_defense: print("You Hit! an arrow sinks into the beast and deals", player_strong_damage, "damage!") king_Hp - player_strong_damage if player_strong_attack < king_defense: print("You miss! The beast doges!") or print("You miss! The beast catches the arrow") or print( "You miss! The arrow goes wide") if player_normal_attack >= 95: Print("YOU CRIT!!!! YOU SINK AN ARROW DEEP INTO A VITAL ORGAN!!! YOU DEAL", player_strong_damage_crit, "DAMAGE!") king_Hp - player_strong_damage_crit king_attack_determine if king_attack_determine >= 50: print("The beats uses a Strong Attack and rolled", king_strong_attack, "to hit! You rolled", player_defense, "to dodge!") if king_strong_attack >= player_defense: print("It slashes into you and deals", king_strong_damage, "damage!") player_hp = king_strong_damage if king_strong_attack <= player_defense: print("You doge effortlessly out of the way!") or print("You jump over the fetid beast!!") if king_strong_attack >= 95: print("IT CRITS!!! OH NO THE FOUL BEAST HURTS YOU DEEPLY AND DEALS", king_strong_damage_crit, "DAMAGE!!!") player_hp - king_strong_damage_crit if king_attack_determine <= 49: print("The beats uses a Quick Attack and rolled", king_normal_attack, "to hit! You rolled", player_defense, "to dodge!") if king_normal_attack >= player_defense: print("It slashes into you and deals", king_normal_damage, "damage!") player_hp = king_normal_damage if king_normal_attack <= player_defense: print("You doge effortlessly out of the way!") or print("You jump over the fetid beast!!") if king_normal_attack >= 95: print("IT CRITS!!! OH NO THE FOUL BEAST HURTS YOU DEEPLY AND DEALS", king_normal_damage_crit, "DAMAGE!!!") player_hp - king_normal_damage_crit if player_hp <= 0: print("I'm sorry you lost, please try again!") if king_hp <= 0: print("With one final shot you slay the willow king! Congradts you have restored peace to your village!!! Play again sometime!!!") if final == "": print("THE END!!!!!!!!!!!!!!!!!!!!! YIPPEEEE!!!!!!!!!!!!!!!")
submitted by /u/Bean_ziggler2
[link] [comments]
r/learnpython So I made a VERY basic text based adventure rpg game. It works fine enough but one issue i found was that the random number is rolled once and then it is the same forever. How do i make it re roll in each new instance. I also thought about adding a turn counter. This was also done before i learned about creating my own functions but i know now. Thank you for reading and i would appreciate any suggestions! import random player_hp = 50 player_normal_attack = random.randint(1, 100 + 10) player_normal_damage = random.randint(1, 6) player_normal_damage_crit = random.randint(1, 6 * 2) player_strong_attack = random.randint(1, 100 – 10) player_strong_damage = random.randint(1, 6 + 5) player_strong_damage_crit = random.randint(1, 6 * 2 +5) player_defense = random.randint(1, 100) king_Hp = 50 king_normal_attack = random.randint(1, 100 + 10) king_normal_damage_crit = random.randint(1, 6 * 2) king_normal_damage = random.randint(1, 6) king_strong_attack = random.randint(1, 100 – 10) king_strong_damage = random.randint(1, 6 + 5) king_strong_damage_crit = random.randint(1, 6 * 2 +5) king_defense = random.randint(1, 100) king_attack_determine = random.randint(1, 100) input(“Press Enter to Start… “) print(“You are Via! A satyre with with fur as white as snow. You are from deep in the mountains, and have imense dexterity and agility! You have been sent to hunt a dangerous beast known as THE WILLOW KING!!!”) print(“He is a larged bipedal beast with the head of a deer, body of a hummand and legs of a horse. A quite devilish beast indeed!!!”) input(“Are you ready? “) print(“You have been tracking the beast for days now, you are starving and exhausted. But you cannot stop until this fiend is slayed!!”) while True: print(“Perception: Success!! You see hoof tracks off to the east and a blood trail to the west”) direction = input(“Where do you want to go? East or West? “) if direction.lower() == “east”: print(“You follow these tracks to the east until you come to a dark cave.”) affirm = input(“Do you enter? “) if affirm.lower() == “yes”: print(“You come to a walk into the cave. You Smell a disgusting smell of rotten flesh. You see piles of rotten half eaten corpes and out of the shadows the beast stands! Begin Combat!”) break if direction.lower() == “west”: print(“You follow the blood up a tall hill until you come to the entrance of a dark cave.”) affirm = input(“Do you enter? “) if affirm.lower() == “yes”: print(“you come to what appears to be a tall ridge servying the scene of the dark cave. There is a large pile of hay, it is its nest. You see the beast knawing on flesh below you. You have gotten the drop on it!”) print(“Begin Combat!”) break if direction.lower() == “cake”: print(“you come to a cave. You walk inside and hear…. SURPRISE! It’s a surprise party thrown by all your friends and family you have a an amazing time and eat cake and ice cream!!!”) final = input(“Press enter to continue… “) if direction.lower() == “east”: king_Hp = king_Hp * 2 if direction.lower() == “west”: king_Hp = king_Hp / 2 while player_hp or king_Hp > 0: pick_attack = input(“Please select an attack. Quick or Strong? “) if pick_attack.lower() == “quick”: print(“You rolled”, player_normal_attack, “to hit. THE WILLOW KING rolled”, king_defense, “to doge!”) if player_normal_attack >= king_defense: print(“You Hit! an arrow sinks into the beast and deals”, player_normal_damage, “damage!”) king_Hp – player_normal_damage if player_normal_attack < king_defense: print(“You miss! The beast doges!”) or print(“You miss! The beast catches the arrow”) or print(“You miss! The arrow goes wide”) if player_normal_attack >= 95: Print(“YOU CRIT!!!! YOU SINK AN ARROW DEEP INTO A VITAL ORGAN!!! YOU DEAL”, player_strong_damage_crit, “DAMAGE!”) king_Hp – player_normal_damage_crit if pick_attack.lower() == “strong”: print(“You rolled”, player_strong_attack, “to hit. THE WILLOW KING rolled”, king_defense, “to doge!”) if player_strong_attack >= king_defense: print(“You Hit! an arrow sinks into the beast and deals”, player_strong_damage, “damage!”) king_Hp – player_strong_damage if player_strong_attack < king_defense: print(“You miss! The beast doges!”) or print(“You miss! The beast catches the arrow”) or print( “You miss! The arrow goes wide”) if player_normal_attack >= 95: Print(“YOU CRIT!!!! YOU SINK AN ARROW DEEP INTO A VITAL ORGAN!!! YOU DEAL”, player_strong_damage_crit, “DAMAGE!”) king_Hp – player_strong_damage_crit king_attack_determine if king_attack_determine >= 50: print(“The beats uses a Strong Attack and rolled”, king_strong_attack, “to hit! You rolled”, player_defense, “to dodge!”) if king_strong_attack >= player_defense: print(“It slashes into you and deals”, king_strong_damage, “damage!”) player_hp = king_strong_damage if king_strong_attack <= player_defense: print(“You doge effortlessly out of the way!”) or print(“You jump over the fetid beast!!”) if king_strong_attack >= 95: print(“IT CRITS!!! OH NO THE FOUL BEAST HURTS YOU DEEPLY AND DEALS”, king_strong_damage_crit, “DAMAGE!!!”) player_hp – king_strong_damage_crit if king_attack_determine <= 49: print(“The beats uses a Quick Attack and rolled”, king_normal_attack, “to hit! You rolled”, player_defense, “to dodge!”) if king_normal_attack >= player_defense: print(“It slashes into you and deals”, king_normal_damage, “damage!”) player_hp = king_normal_damage if king_normal_attack <= player_defense: print(“You doge effortlessly out of the way!”) or print(“You jump over the fetid beast!!”) if king_normal_attack >= 95: print(“IT CRITS!!! OH NO THE FOUL BEAST HURTS YOU DEEPLY AND DEALS”, king_normal_damage_crit, “DAMAGE!!!”) player_hp – king_normal_damage_crit if player_hp <= 0: print(“I’m sorry you lost, please try again!”) if king_hp <= 0: print(“With one final shot you slay the willow king! Congradts you have restored peace to your village!!! Play again sometime!!!”) if final == “”: print(“THE END!!!!!!!!!!!!!!!!!!!!! YIPPEEEE!!!!!!!!!!!!!!!”) submitted by /u/Bean_ziggler2 [link] [comments]
So I made a VERY basic text based adventure rpg game. It works fine enough but one issue i found was that the random number is rolled once and then it is the same forever. How do i make it re roll in each new instance. I also thought about adding a turn counter. This was also done before i learned about creating my own functions but i know now. Thank you for reading and i would appreciate any suggestions!
import random player_hp = 50 player_normal_attack = random.randint(1, 100 + 10) player_normal_damage = random.randint(1, 6) player_normal_damage_crit = random.randint(1, 6 * 2) player_strong_attack = random.randint(1, 100 - 10) player_strong_damage = random.randint(1, 6 + 5) player_strong_damage_crit = random.randint(1, 6 * 2 +5) player_defense = random.randint(1, 100) king_Hp = 50 king_normal_attack = random.randint(1, 100 + 10) king_normal_damage_crit = random.randint(1, 6 * 2) king_normal_damage = random.randint(1, 6) king_strong_attack = random.randint(1, 100 - 10) king_strong_damage = random.randint(1, 6 + 5) king_strong_damage_crit = random.randint(1, 6 * 2 +5) king_defense = random.randint(1, 100) king_attack_determine = random.randint(1, 100) input("Press Enter to Start... ") print("You are Via! A satyre with with fur as white as snow. You are from deep in the mountains, and have imense dexterity and agility! You have been sent to hunt a dangerous beast known as THE WILLOW KING!!!") print("He is a larged bipedal beast with the head of a deer, body of a hummand and legs of a horse. A quite devilish beast indeed!!!") input("Are you ready? ") print("You have been tracking the beast for days now, you are starving and exhausted. But you cannot stop until this fiend is slayed!!") while True: print("Perception: Success!! You see hoof tracks off to the east and a blood trail to the west") direction = input("Where do you want to go? East or West? ") if direction.lower() == "east": print("You follow these tracks to the east until you come to a dark cave.") affirm = input("Do you enter? ") if affirm.lower() == "yes": print("You come to a walk into the cave. You Smell a disgusting smell of rotten flesh. You see piles of rotten half eaten corpes and out of the shadows the beast stands! Begin Combat!") break if direction.lower() == "west": print("You follow the blood up a tall hill until you come to the entrance of a dark cave.") affirm = input("Do you enter? ") if affirm.lower() == "yes": print("you come to what appears to be a tall ridge servying the scene of the dark cave. There is a large pile of hay, it is its nest. You see the beast knawing on flesh below you. You have gotten the drop on it!") print("Begin Combat!") break if direction.lower() == "cake": print("you come to a cave. You walk inside and hear.... SURPRISE! It's a surprise party thrown by all your friends and family you have a an amazing time and eat cake and ice cream!!!") final = input("Press enter to continue... ") if direction.lower() == "east": king_Hp = king_Hp * 2 if direction.lower() == "west": king_Hp = king_Hp / 2 while player_hp or king_Hp > 0: pick_attack = input("Please select an attack. Quick or Strong? ") if pick_attack.lower() == "quick": print("You rolled", player_normal_attack, "to hit. THE WILLOW KING rolled", king_defense, "to doge!") if player_normal_attack >= king_defense: print("You Hit! an arrow sinks into the beast and deals", player_normal_damage, "damage!") king_Hp - player_normal_damage if player_normal_attack < king_defense: print("You miss! The beast doges!") or print("You miss! The beast catches the arrow") or print("You miss! The arrow goes wide") if player_normal_attack >= 95: Print("YOU CRIT!!!! YOU SINK AN ARROW DEEP INTO A VITAL ORGAN!!! YOU DEAL", player_strong_damage_crit, "DAMAGE!") king_Hp - player_normal_damage_crit if pick_attack.lower() == "strong": print("You rolled", player_strong_attack, "to hit. THE WILLOW KING rolled", king_defense, "to doge!") if player_strong_attack >= king_defense: print("You Hit! an arrow sinks into the beast and deals", player_strong_damage, "damage!") king_Hp - player_strong_damage if player_strong_attack < king_defense: print("You miss! The beast doges!") or print("You miss! The beast catches the arrow") or print( "You miss! The arrow goes wide") if player_normal_attack >= 95: Print("YOU CRIT!!!! YOU SINK AN ARROW DEEP INTO A VITAL ORGAN!!! YOU DEAL", player_strong_damage_crit, "DAMAGE!") king_Hp - player_strong_damage_crit king_attack_determine if king_attack_determine >= 50: print("The beats uses a Strong Attack and rolled", king_strong_attack, "to hit! You rolled", player_defense, "to dodge!") if king_strong_attack >= player_defense: print("It slashes into you and deals", king_strong_damage, "damage!") player_hp = king_strong_damage if king_strong_attack <= player_defense: print("You doge effortlessly out of the way!") or print("You jump over the fetid beast!!") if king_strong_attack >= 95: print("IT CRITS!!! OH NO THE FOUL BEAST HURTS YOU DEEPLY AND DEALS", king_strong_damage_crit, "DAMAGE!!!") player_hp - king_strong_damage_crit if king_attack_determine <= 49: print("The beats uses a Quick Attack and rolled", king_normal_attack, "to hit! You rolled", player_defense, "to dodge!") if king_normal_attack >= player_defense: print("It slashes into you and deals", king_normal_damage, "damage!") player_hp = king_normal_damage if king_normal_attack <= player_defense: print("You doge effortlessly out of the way!") or print("You jump over the fetid beast!!") if king_normal_attack >= 95: print("IT CRITS!!! OH NO THE FOUL BEAST HURTS YOU DEEPLY AND DEALS", king_normal_damage_crit, "DAMAGE!!!") player_hp - king_normal_damage_crit if player_hp <= 0: print("I'm sorry you lost, please try again!") if king_hp <= 0: print("With one final shot you slay the willow king! Congradts you have restored peace to your village!!! Play again sometime!!!") if final == "": print("THE END!!!!!!!!!!!!!!!!!!!!! YIPPEEEE!!!!!!!!!!!!!!!")
submitted by /u/Bean_ziggler2
[link] [comments]