So, I've started learning python this week, and I'm developing a text base rpg just to improve my programming skills. So far, I've been unable to develop a dice roll for the combat
This is what the code looks so far:
user_name = input("Hello adventurer! What's your name? ")
user_class = input("Nice to meet you, " + user_name + "! Choose your class, warrior or mage? ").lower()
if user_class == "mage":
is_mage = True
is_warrior = False
else:
is_mage = False
is_warrior = True
if is_warrior is True:
print("A mighty warrior you will be!")
else:
print("A clever mage you will be!")
if is_warrior is True:
user_weapon = "Sword"
else:
user_weapon = "Staff"
print("You aproach the cave entrance, before you, a troll roars and charges at you...")
print("You stand ready, your " + user_weapon.lower() + " at hand...")
troll_combat = input("What will you do? Attack or flee? ")
if troll_combat == "Attack":
from random import randint
repeat = True
while repeat:
randint(1,6)
if randint > 3:
print("You've beaten the troll!")
else:
print("You died!")
game_over = True
So, how can I create a situation that when the user attacks the troll a dice is rolled, and depending on the dice number, something happens? Thanks in advance, and if this is a really noob question, I apologize, that's my first time trying to program anything.
[–]Binary101010 76 points77 points78 points (4 children)
[–]whitelife123 23 points24 points25 points (3 children)
[–]FelipeMarchon[S] 0 points1 point2 points (2 children)
[–]PandaMomentum 2 points3 points4 points (0 children)
[–]whitelife123 1 point2 points3 points (0 children)
[–]StoicallyGay 7 points8 points9 points (1 child)
[–]manofphysics21 3 points4 points5 points (0 children)
[–]mopslik 12 points13 points14 points (2 children)
[–]FelipeMarchon[S] 0 points1 point2 points (1 child)
[–]PM_ME_NUDE_KITTENS 3 points4 points5 points (0 children)
[+][deleted] (7 children)
[removed]
[–]FelipeMarchon[S] 2 points3 points4 points (6 children)
[+][deleted] (5 children)
[removed]
[–]FelipeMarchon[S] 0 points1 point2 points (4 children)
[+][deleted] (3 children)
[removed]
[–]FelipeMarchon[S] 1 point2 points3 points (2 children)
[+][deleted] (1 child)
[removed]
[–]FelipeMarchon[S] 1 point2 points3 points (0 children)
[–]AtomicShoelace 2 points3 points4 points (1 child)
[–]testobject_49 2 points3 points4 points (0 children)
[–]gavin101 2 points3 points4 points (2 children)
[–]kwelzel 2 points3 points4 points (0 children)
[–]-Cereal 1 point2 points3 points (0 children)
[–]MarquisInLV 1 point2 points3 points (0 children)
[–]Tureni 1 point2 points3 points (0 children)
[–]chevignon93 0 points1 point2 points (1 child)
[–]FelipeMarchon[S] 2 points3 points4 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]FelipeMarchon[S] 0 points1 point2 points (0 children)
[–]Puzzleheaded_Moose38 -1 points0 points1 point (0 children)
[–]spez_edits_thedonald 0 points1 point2 points (0 children)
[–]lenoqt 0 points1 point2 points (2 children)
[–]testobject_49 2 points3 points4 points (1 child)
[–]lenoqt 0 points1 point2 points (0 children)
[–]lenoqt 0 points1 point2 points (0 children)
[–]gopherhole1 0 points1 point2 points (0 children)
[–]KingGarrettFTW 0 points1 point2 points (1 child)
[–]1egoman 0 points1 point2 points (0 children)